Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Javier González and committed by
Jens Axboe
4af3f75d e85292fe

+19 -5
+11 -3
drivers/lightnvm/core.c
··· 280 280 tdisk->fops = &nvm_fops; 281 281 tdisk->queue = tqueue; 282 282 283 - targetdata = tt->init(tgt_dev, tdisk); 283 + targetdata = tt->init(tgt_dev, tdisk, create->flags); 284 284 if (IS_ERR(targetdata)) 285 285 goto err_init; 286 286 ··· 1244 1244 create.tgtname[DISK_NAME_LEN - 1] = '\0'; 1245 1245 1246 1246 if (create.flags != 0) { 1247 - pr_err("nvm: no flags supported\n"); 1248 - return -EINVAL; 1247 + __u32 flags = create.flags; 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 1259 return __nvm_configure_create(&create);
+2 -1
drivers/lightnvm/rrpc.c
··· 1506 1506 1507 1507 static struct nvm_tgt_type tt_rrpc; 1508 1508 1509 - static void *rrpc_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk) 1509 + static void *rrpc_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk, 1510 + int flags) 1510 1511 { 1511 1512 struct request_queue *bqueue = dev->q; 1512 1513 struct request_queue *tqueue = tdisk->queue;
+2 -1
include/linux/lightnvm.h
··· 436 436 437 437 typedef blk_qc_t (nvm_tgt_make_rq_fn)(struct request_queue *, struct bio *); 438 438 typedef sector_t (nvm_tgt_capacity_fn)(void *); 439 - typedef void *(nvm_tgt_init_fn)(struct nvm_tgt_dev *, struct gendisk *); 439 + typedef void *(nvm_tgt_init_fn)(struct nvm_tgt_dev *, struct gendisk *, 440 + int flags); 440 441 typedef void (nvm_tgt_exit_fn)(void *); 441 442 typedef int (nvm_tgt_sysfs_init_fn)(struct gendisk *); 442 443 typedef void (nvm_tgt_sysfs_exit_fn)(struct gendisk *);
+4
include/uapi/linux/lightnvm.h
··· 85 85 }; 86 86 }; 87 87 88 + enum { 89 + NVM_TARGET_FACTORY = 1 << 0, /* Init target in factory mode */ 90 + }; 91 + 88 92 struct nvm_ioctl_create { 89 93 char dev[DISK_NAME_LEN]; /* open-channel SSD device */ 90 94 char tgttype[NVM_TTYPE_NAME_MAX]; /* target type name */