aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier González <jg@lightnvm.io>2017-04-15 14:55:45 -0400
committerJens Axboe <axboe@fb.com>2017-04-16 12:06:25 -0400
commit4af3f75d7992dd0dc49da95fbc039fa3806fba4f (patch)
treec180773ceb2e5e1b3ca1edd06a9cc84c41525f3d
parente85292feb98ca8ba4dcd6b5d33e1214a4b54512d (diff)
lightnvm: allow to init targets on factory mode
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> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--drivers/lightnvm/core.c14
-rw-r--r--drivers/lightnvm/rrpc.c3
-rw-r--r--include/linux/lightnvm.h3
-rw-r--r--include/uapi/linux/lightnvm.h4
4 files changed, 19 insertions, 5 deletions
diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index 5f84d2a418f6..a63b563b1a8a 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)
280 tdisk->fops = &nvm_fops; 280 tdisk->fops = &nvm_fops;
281 tdisk->queue = tqueue; 281 tdisk->queue = tqueue;
282 282
283 targetdata = tt->init(tgt_dev, tdisk); 283 targetdata = tt->init(tgt_dev, tdisk, create->flags);
284 if (IS_ERR(targetdata)) 284 if (IS_ERR(targetdata))
285 goto err_init; 285 goto err_init;
286 286
@@ -1244,8 +1244,16 @@ static long nvm_ioctl_dev_create(struct file *file, void __user *arg)
1244 create.tgtname[DISK_NAME_LEN - 1] = '\0'; 1244 create.tgtname[DISK_NAME_LEN - 1] = '\0';
1245 1245
1246 if (create.flags != 0) { 1246 if (create.flags != 0) {
1247 pr_err("nvm: no flags supported\n"); 1247 __u32 flags = create.flags;
1248 return -EINVAL; 1248
1249 /* Check for valid flags */
1250 if (flags & NVM_TARGET_FACTORY)
1251 flags &= ~NVM_TARGET_FACTORY;
1252
1253 if (flags) {
1254 pr_err("nvm: flag not supported\n");
1255 return -EINVAL;
1256 }
1249 } 1257 }
1250 1258
1251 return __nvm_configure_create(&create); 1259 return __nvm_configure_create(&create);
diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c
index a8acf9e06401..5dba54470c2a 100644
--- a/drivers/lightnvm/rrpc.c
+++ b/drivers/lightnvm/rrpc.c
@@ -1506,7 +1506,8 @@ err:
1506 1506
1507static struct nvm_tgt_type tt_rrpc; 1507static struct nvm_tgt_type tt_rrpc;
1508 1508
1509static void *rrpc_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk) 1509static void *rrpc_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk,
1510 int flags)
1510{ 1511{
1511 struct request_queue *bqueue = dev->q; 1512 struct request_queue *bqueue = dev->q;
1512 struct request_queue *tqueue = tdisk->queue; 1513 struct request_queue *tqueue = tdisk->queue;
diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h
index eff7d1f312a8..7dfa56ebbc6d 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)
436 436
437typedef blk_qc_t (nvm_tgt_make_rq_fn)(struct request_queue *, struct bio *); 437typedef blk_qc_t (nvm_tgt_make_rq_fn)(struct request_queue *, struct bio *);
438typedef sector_t (nvm_tgt_capacity_fn)(void *); 438typedef sector_t (nvm_tgt_capacity_fn)(void *);
439typedef void *(nvm_tgt_init_fn)(struct nvm_tgt_dev *, struct gendisk *); 439typedef void *(nvm_tgt_init_fn)(struct nvm_tgt_dev *, struct gendisk *,
440 int flags);
440typedef void (nvm_tgt_exit_fn)(void *); 441typedef void (nvm_tgt_exit_fn)(void *);
441typedef int (nvm_tgt_sysfs_init_fn)(struct gendisk *); 442typedef int (nvm_tgt_sysfs_init_fn)(struct gendisk *);
442typedef void (nvm_tgt_sysfs_exit_fn)(struct gendisk *); 443typedef void (nvm_tgt_sysfs_exit_fn)(struct gendisk *);
diff --git a/include/uapi/linux/lightnvm.h b/include/uapi/linux/lightnvm.h
index fd19f36b3129..c8aec4b9e73b 100644
--- a/include/uapi/linux/lightnvm.h
+++ b/include/uapi/linux/lightnvm.h
@@ -85,6 +85,10 @@ struct nvm_ioctl_create_conf {
85 }; 85 };
86}; 86};
87 87
88enum {
89 NVM_TARGET_FACTORY = 1 << 0, /* Init target in factory mode */
90};
91
88struct nvm_ioctl_create { 92struct nvm_ioctl_create {
89 char dev[DISK_NAME_LEN]; /* open-channel SSD device */ 93 char dev[DISK_NAME_LEN]; /* open-channel SSD device */
90 char tgttype[NVM_TTYPE_NAME_MAX]; /* target type name */ 94 char tgttype[NVM_TTYPE_NAME_MAX]; /* target type name */