From patchwork Fri Apr 7 18:31:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= X-Patchwork-Id: 9670195 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 319F9602A0 for ; Fri, 7 Apr 2017 18:32:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29F4526AE3 for ; Fri, 7 Apr 2017 18:32:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1EDE527A98; Fri, 7 Apr 2017 18:32:18 +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.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham 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 A101226AE3 for ; Fri, 7 Apr 2017 18:32:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933071AbdDGScQ (ORCPT ); Fri, 7 Apr 2017 14:32:16 -0400 Received: from mail-wr0-f179.google.com ([209.85.128.179]:36760 "EHLO mail-wr0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755863AbdDGSbZ (ORCPT ); Fri, 7 Apr 2017 14:31:25 -0400 Received: by mail-wr0-f179.google.com with SMTP id c55so40942122wrc.3 for ; Fri, 07 Apr 2017 11:31:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Nvzm9qJ6wLiioPkqTnfgwA2sQFDkIvzBqtnv/WU+8j4=; b=CxTkPrSe75wGwy54hqYom+wMvDm5hdB4kMbrLo939xzJ8gA+/PULDtIkZH0K+G+J3f orkzDxZk0Y5gEy3AnqcoQSBQmNn+iOfTdZ88JUFR92D0zTkyHAZWM51aS43F7FF1Arcu 6G5w6piMY2YSQYfRm3Cz0oteudhXx84qv/vcyFZmiuM2S4vZicWAfa+ysRBqubhVDUVz WfXVlvkwFgKQFt3E48SzTj5BoYWb1SJWWX/npUHJoRxqu6gUrCXDVKuE6CAHZPhDnCFc l+wxJ+fUC3uFdW2kOPHAG2ypw/nBxV7VrPjcHhedGiYqgCSToyGBoJ7Q7ZnZm5weRX0n oo7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Nvzm9qJ6wLiioPkqTnfgwA2sQFDkIvzBqtnv/WU+8j4=; b=E/YKoleq/fG0FTaQI/T3xx19EvvtWdhUmATZyZHzZ7rTF29YorQSqmdmhugUGLRhoe /QWFXfTEtpqIS/nBBWlwrYi2pzhofdAVBc/crOkpAocWJeSggQgMAPpvmWttAoDp8M6s 3KMKRhjPd3xu7pNosUPTuXkkrbD2w8wbol72n2lvhldsp899GHSVP9YQjM/z2gDCwHdU 2/nRPOIEMzGF8MsLu3hOMUic3cJTROsb7nKH8potGWV2SV6okMHUJDcq1i+OAa02FgX6 rvA8mraZUCFo21oMvbKisZsazTk9AXv4W7xB48R9Vd+6PUrJ0ZfVv3xjMscTeavxO7X6 VPgw== X-Gm-Message-State: AN3rC/6s7pXMViFeH03waSsrA9A3h/nanllWuxF3BpwarGZUgt5AtLHoho3Km72mi2dAoQ== X-Received: by 10.223.160.48 with SMTP id k45mr5779844wrk.153.1491589883761; Fri, 07 Apr 2017 11:31:23 -0700 (PDT) Received: from uHalley.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id w76sm5210910wrb.49.2017.04.07.11.31.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 07 Apr 2017 11:31:23 -0700 (PDT) From: "=?UTF-8?q?Javier=20Gonz=C3=A1lez?=" X-Google-Original-From: =?UTF-8?q?Javier=20Gonz=C3=A1lez?= To: mb@lightnvm.io Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Javier=20Gonz=C3=A1lez?= Subject: [PATCH 4/4] lightnvm: allow to init targets on factory mode Date: Fri, 7 Apr 2017 20:31:14 +0200 Message-Id: <1491589874-26818-4-git-send-email-javier@cnexlabs.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491589874-26818-1-git-send-email-javier@cnexlabs.com> References: <1491589874-26818-1-git-send-email-javier@cnexlabs.com> MIME-Version: 1.0 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 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 --- 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 28e69a7..e4530c2 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -279,7 +279,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; @@ -1243,8 +1243,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 4e4c299..2c04ff3 100644 --- a/drivers/lightnvm/rrpc.c +++ b/drivers/lightnvm/rrpc.c @@ -1515,7 +1515,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 bebea80..e88f7ef 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 */