From patchwork Sat Apr 15 18:55:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 9682395 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C5AA060138 for ; Sat, 15 Apr 2017 18:59:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B694325223 for ; Sat, 15 Apr 2017 18:59:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB8F928305; Sat, 15 Apr 2017 18:59:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFDD825223 for ; Sat, 15 Apr 2017 18:59:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754715AbdDOS4l (ORCPT ); Sat, 15 Apr 2017 14:56:41 -0400 Received: from mail-dm3nam03on0041.outbound.protection.outlook.com ([104.47.41.41]:38016 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755369AbdDOS4h (ORCPT ); Sat, 15 Apr 2017 14:56:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cnexlabs.onmicrosoft.com; s=selector1-cnexlabs-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=SqLIfS3a+GXPWLzL0HrkmP76olm+BvgR2h+1KqxjZGg=; b=doaIwgdO7zHzkpUCJXpb4VP/VNo472fZ08xeytifEv/sqvqr5NQdtKMtjGDZ7MYr8CvNhw5iGY06tvYdy5YFIgxlQO6uJEUKwR1o8f6XeXZWix4TeBrmYlFvbv8Ade0LT6DYMi3/S58kHWMtN5Qe8e/KXs6OvnA0eXV4mkKR1Uc= Authentication-Results: fb.com; dkim=none (message not signed) header.d=none; fb.com; dmarc=none action=none header.from=cnexlabs.com; Received: from skyninja.cnexlabs.com (193.106.164.211) by CY4PR06MB2774.namprd06.prod.outlook.com (10.175.117.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Sat, 15 Apr 2017 18:56:27 +0000 From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: CC: , , =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Javier=20Gonz=C3=A1lez?= , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 11/19] lightnvm: allow to init targets on factory mode Date: Sat, 15 Apr 2017 20:55:45 +0200 Message-ID: <20170415185553.16098-12-matias@cnexlabs.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170415185553.16098-1-matias@cnexlabs.com> References: <20170415185553.16098-1-matias@cnexlabs.com> MIME-Version: 1.0 X-Originating-IP: [193.106.164.211] X-ClientProxiedBy: AM5PR0701CA0069.eurprd07.prod.outlook.com (10.169.145.159) To CY4PR06MB2774.namprd06.prod.outlook.com (10.175.117.142) X-MS-Office365-Filtering-Correlation-Id: 2eaef994-ffae-487a-0a7c-08d484311fe4 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:CY4PR06MB2774; X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2774; 3:6TvhHW7MU1vryVOSml8uebzZ5EnBpa03BOKuBqUivcjw74lb+GcvOUQKPbs3c8sV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A5yQB7yqYMeefRkRKaKTdMxVL5gm01URlCg20uNVTlxUR+R2CjNm2PIOoIUPdpMJ9achddnBQBK7/1APflfRpZEBHX0+qJ73Q+0ORF6F7gN0Y2e0+DZcWmVgKkatcOx+DrZQAFeYwEp6ySf6Ass= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(6041248)(20161123564025)(20161123562025)(20161123560025)(201703131423075)(201703061421075)(20161123555025)(6072148); SRVR:CY4PR06MB2774; BCL:0; PCL:0; RULEID:; SRVR:CY4PR06MB2774; X-Microsoft-Exchange-Diagnostics: 1; CY4PR06MB2774; 4:6vvoCCgLR5x09a3vr731bbg+4CdA5QT6G3TBT2nCtSgkEOGxuBu7//wiBU5VesviEybFKzjG4RyZT9hf0fcXAsZ1IAjmAPxrUYtn8gMkVXJ8O9d4n3X+WXfL2N6aOZ33QTsJfw18qapMeCkZWOjO3dsDOO+ge8sGT1VjIedgj4++0pYXBALVtbTEGy88dFuurm3lyEBy1uZAbJmfpJ+ob6j/Ni/bhl/H4ez1+h1nxovQn0B0h0h1Ip7eZ0uZScSRNrJtsHJWbj/ddNWLjYe5BA4ue0bjIQW/IjxUm+cdTy7bu94fKpC5otakL+LmR1fs4ZpBZyjI1kZ7ch7X7RCbb6n7Xd4b8yENJ626gyvw6eAflY8FbN31i5nuKIVZ/aqWwQY304wNWIziWJCHDB5CE4HJuqoPAfhOOrcrxdeuz4ts4EmFAxG3mm4NBPoS/z4kAjQYzC/TorWxQuh1UChTucRw6V1IGH6D6jgkOlpCX8GcuRq1JGJUTCZXHfyT2aZyRcb9Z7CP2W7OdQFNrnhPQy+U0yTYSs8jlsxenBuq9sp6TxqsyVAs9VdqoqfE37IoIxGSMyvxy7WqJosxe9+9Ocjc81COjpyFp+iB1omRuOSqrMvAyt64YwELgHNq3EGYBD3buugPV0c4ErGmh5AUXpanX3cUvIb1VmLNk6790DpXt+p1lzQBlncNSRIwcvyT X-Forefront-PRVS: 02788FF38E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39400400002)(39450400003)(86362001)(305945005)(1076002)(6916009)(6666003)(25786009)(2950100002)(6486002)(2906002)(3846002)(6116002)(2870700001)(54906002)(189998001)(53936002)(53416004)(107886003)(110136004)(5660300001)(38730400002)(50986999)(76176999)(2351001)(4326008)(66066001)(5820100001)(23676002)(81166006)(47776003)(42186005)(36756003)(33646002)(50226002)(8676002)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR06MB2774; H:skyninja.cnexlabs.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTRQUjA2TUIyNzc0OzIzOjRxcExQQ1JsdzVFWjU2RXlVaGxQTkc2dFE5?= =?utf-8?B?TGxSVVh3YjZIdXJZUWZ6Uk55bTc4RTR4eEp3dnQ3Z1BmL0RYSXR5M3NGdEQx?= =?utf-8?B?ZkhaRWpkWTFad3BQOTlyQXB1THhmVEdYdG5XaDM0U2tEV3c2bk92YnZUOXVw?= =?utf-8?B?dDdrVTUxdWh0MXViT1pXaDlXRXhNSjJ0NHRPSWUwTC81WFlpQ1RXb21zSGRR?= =?utf-8?B?YVpnRVJsazBrTVBvNW9kRXdoWldia1V6S1hRY2hBTWo3NWVuUHBlUGJtV0p4?= =?utf-8?B?WEVnemZkNW9yNGF1alZ2dGVYdFl2MDVsTzdydWNidDJnaGMvYytndTk3T3hs?= =?utf-8?B?c3lJOXdwRHRqSStvQU9ZT045ZExHTkhaa3gwc29LdElsSUY3alBpUS9PeG8y?= =?utf-8?B?YkRBYmlqaG1rVzk1MC9INEY2N2wrZm5QMno2S0R6aXE0aTFDT2FQOFkwSWc3?= =?utf-8?B?QnRLMU53TThCUXJZenRlTUhlZkZaczVKQXpub0Q3R2sxaWtFYkVNaDc1T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9nWQIsHEQYgtwRI+tG25Nzw+zA== X-OriginatorOrg: cnexlabs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2017 18:56:27.7645 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR06MB2774 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Javier González Target initialization has two responsibilities: creating the target partition and instantiating the target. This patch enables to create a factory partition (e.g., do not trigger recovery on the given target). This is useful for target development and for being able to restore the device state at any moment in time without requiring a full-device erase. Signed-off-by: Javier González Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 14 +++++++++++--- drivers/lightnvm/rrpc.c | 3 ++- include/linux/lightnvm.h | 3 ++- include/uapi/linux/lightnvm.h | 4 ++++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 5f84d2a..a63b563 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -280,7 +280,7 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create) tdisk->fops = &nvm_fops; tdisk->queue = tqueue; - targetdata = tt->init(tgt_dev, tdisk); + targetdata = tt->init(tgt_dev, tdisk, create->flags); if (IS_ERR(targetdata)) goto err_init; @@ -1244,8 +1244,16 @@ static long nvm_ioctl_dev_create(struct file *file, void __user *arg) create.tgtname[DISK_NAME_LEN - 1] = '\0'; if (create.flags != 0) { - pr_err("nvm: no flags supported\n"); - return -EINVAL; + __u32 flags = create.flags; + + /* Check for valid flags */ + if (flags & NVM_TARGET_FACTORY) + flags &= ~NVM_TARGET_FACTORY; + + if (flags) { + pr_err("nvm: flag not supported\n"); + return -EINVAL; + } } return __nvm_configure_create(&create); diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c index a8acf9e..5dba544 100644 --- a/drivers/lightnvm/rrpc.c +++ b/drivers/lightnvm/rrpc.c @@ -1506,7 +1506,8 @@ static int rrpc_luns_configure(struct rrpc *rrpc) static struct nvm_tgt_type tt_rrpc; -static void *rrpc_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk) +static void *rrpc_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk, + int flags) { struct request_queue *bqueue = dev->q; struct request_queue *tqueue = tdisk->queue; diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index eff7d1f..7dfa56e 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -436,7 +436,8 @@ static inline int ppa_cmp_blk(struct ppa_addr ppa1, struct ppa_addr ppa2) typedef blk_qc_t (nvm_tgt_make_rq_fn)(struct request_queue *, struct bio *); typedef sector_t (nvm_tgt_capacity_fn)(void *); -typedef void *(nvm_tgt_init_fn)(struct nvm_tgt_dev *, struct gendisk *); +typedef void *(nvm_tgt_init_fn)(struct nvm_tgt_dev *, struct gendisk *, + int flags); typedef void (nvm_tgt_exit_fn)(void *); typedef int (nvm_tgt_sysfs_init_fn)(struct gendisk *); typedef void (nvm_tgt_sysfs_exit_fn)(struct gendisk *); diff --git a/include/uapi/linux/lightnvm.h b/include/uapi/linux/lightnvm.h index fd19f36..c8aec4b 100644 --- a/include/uapi/linux/lightnvm.h +++ b/include/uapi/linux/lightnvm.h @@ -85,6 +85,10 @@ struct nvm_ioctl_create_conf { }; }; +enum { + NVM_TARGET_FACTORY = 1 << 0, /* Init target in factory mode */ +}; + struct nvm_ioctl_create { char dev[DISK_NAME_LEN]; /* open-channel SSD device */ char tgttype[NVM_TTYPE_NAME_MAX]; /* target type name */