From: "Matias Bjørling" <matias@cnexlabs.com>
To: <axboe@fb.com>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
"Javier González" <jg@lightnvm.io>,
"Javier González" <javier@cnexlabs.com>,
"Matias Bjørling" <matias@cnexlabs.com>
Subject: [GIT PULL 11/19] lightnvm: allow to init targets on factory mode
Date: Sat, 15 Apr 2017 20:55:45 +0200 [thread overview]
Message-ID: <20170415185553.16098-12-matias@cnexlabs.com> (raw)
In-Reply-To: <20170415185553.16098-1-matias@cnexlabs.com>
From: Javier González <jg@lightnvm.io>
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 <javier@cnexlabs.com>
Signed-off-by: Matias Bjørling <matias@cnexlabs.com>
---
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 */
--
2.9.3
next prev parent reply other threads:[~2017-04-15 18:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-15 18:55 [GIT PULL 00/19] LightNVM patches for 4.12 Matias Bjørling
2017-04-15 18:55 ` [GIT PULL 01/19] lightnvm: Fix error handling Matias Bjørling
2017-04-15 18:55 ` [GIT PULL 02/19] nvme/lightnvm: Prevent small buffer overflow in nvme_nvm_identify Matias Bjørling
2017-04-15 18:55 ` [GIT PULL 03/19] lightnvm: submit erases using the I/O path Matias Bjørling
2017-04-15 18:55 ` [GIT PULL 04/19] lightnvm: rename scrambler controller hint Matias Bjørling
2017-04-15 18:55 ` [GIT PULL 05/19] lightnvm: free reverse device map Matias Bjørling
2017-04-15 18:55 ` [GIT PULL 06/19] lightnvm: enable nvme size compile asserts Matias Bjørling
2017-04-15 18:55 ` [GIT PULL 07/19] lightnvm: don't check for failure from mempool_alloc() Matias Bjørling
2017-04-15 18:55 ` [GIT PULL 08/19] lightnvm: double-clear of dev->lun_map on target init error Matias Bjørling
2017-04-15 18:55 ` [GIT PULL 09/19] lightnvm: fix cleanup order of disk on " Matias Bjørling
2017-04-15 18:55 ` [GIT PULL 10/19] lightnvm: bad type conversion for nvme control bits Matias Bjørling
2017-04-15 18:55 ` Matias Bjørling [this message]
2017-04-15 18:55 ` [GIT PULL 12/19] lightnvm: make nvm_free static Matias Bjørling
2017-04-15 18:55 ` [GIT PULL 13/19] lightnvm: clean unused variable Matias Bjørling
2017-04-15 18:55 ` [GIT PULL 14/19] lightnvm: fix type checks on rrpc Matias Bjørling
2017-04-15 18:55 ` [GIT PULL 15/19] lightnvm: convert sprintf into strlcpy Matias Bjørling
2017-04-15 18:55 ` [GIT PULL 16/19] lightnvm: physical block device (pblk) target Matias Bjørling
2017-04-15 18:55 ` [GIT PULL 17/19] lightnvm: pblk-gc: fix an error pointer dereference in init Matias Bjørling
2017-04-15 18:55 ` [GIT PULL 18/19] lightnvm: fix some WARN() messages Matias Bjørling
2017-04-15 18:55 ` [GIT PULL 19/19] lightnvm: fix some error code in pblk-init.c Matias Bjørling
2017-04-16 20:37 ` [GIT PULL 00/19] LightNVM patches for 4.12 Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170415185553.16098-12-matias@cnexlabs.com \
--to=matias@cnexlabs.com \
--cc=axboe@fb.com \
--cc=javier@cnexlabs.com \
--cc=jg@lightnvm.io \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®