Commit 4af3f75d authored by Javier González's avatar Javier González Committed by Jens Axboe

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: default avatarJavier González <javier@cnexlabs.com>
Signed-off-by: default avatarMatias Bjørling <matias@cnexlabs.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent e85292fe
...@@ -280,7 +280,7 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create) ...@@ -280,7 +280,7 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
tdisk->fops = &nvm_fops; tdisk->fops = &nvm_fops;
tdisk->queue = tqueue; tdisk->queue = tqueue;
targetdata = tt->init(tgt_dev, tdisk); targetdata = tt->init(tgt_dev, tdisk, create->flags);
if (IS_ERR(targetdata)) if (IS_ERR(targetdata))
goto err_init; goto err_init;
...@@ -1244,8 +1244,16 @@ static long nvm_ioctl_dev_create(struct file *file, void __user *arg) ...@@ -1244,8 +1244,16 @@ static long nvm_ioctl_dev_create(struct file *file, void __user *arg)
create.tgtname[DISK_NAME_LEN - 1] = '\0'; create.tgtname[DISK_NAME_LEN - 1] = '\0';
if (create.flags != 0) { if (create.flags != 0) {
pr_err("nvm: no flags supported\n"); __u32 flags = create.flags;
return -EINVAL;
/* 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); return __nvm_configure_create(&create);
......
...@@ -1506,7 +1506,8 @@ static int rrpc_luns_configure(struct rrpc *rrpc) ...@@ -1506,7 +1506,8 @@ static int rrpc_luns_configure(struct rrpc *rrpc)
static struct nvm_tgt_type tt_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 *bqueue = dev->q;
struct request_queue *tqueue = tdisk->queue; struct request_queue *tqueue = tdisk->queue;
......
...@@ -436,7 +436,8 @@ static inline int ppa_cmp_blk(struct ppa_addr ppa1, struct ppa_addr ppa2) ...@@ -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 blk_qc_t (nvm_tgt_make_rq_fn)(struct request_queue *, struct bio *);
typedef sector_t (nvm_tgt_capacity_fn)(void *); 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 void (nvm_tgt_exit_fn)(void *);
typedef int (nvm_tgt_sysfs_init_fn)(struct gendisk *); typedef int (nvm_tgt_sysfs_init_fn)(struct gendisk *);
typedef void (nvm_tgt_sysfs_exit_fn)(struct gendisk *); typedef void (nvm_tgt_sysfs_exit_fn)(struct gendisk *);
......
...@@ -85,6 +85,10 @@ struct nvm_ioctl_create_conf { ...@@ -85,6 +85,10 @@ struct nvm_ioctl_create_conf {
}; };
}; };
enum {
NVM_TARGET_FACTORY = 1 << 0, /* Init target in factory mode */
};
struct nvm_ioctl_create { struct nvm_ioctl_create {
char dev[DISK_NAME_LEN]; /* open-channel SSD device */ char dev[DISK_NAME_LEN]; /* open-channel SSD device */
char tgttype[NVM_TTYPE_NAME_MAX]; /* target type name */ char tgttype[NVM_TTYPE_NAME_MAX]; /* target type name */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment