Skip to content

Commit 4af3f75

Browse files
Javier Gonzálezaxboe
authored andcommitted
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 <[email protected]> Signed-off-by: Matias Bjørling <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent e85292f commit 4af3f75

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

drivers/lightnvm/core.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
280280
tdisk->fops = &nvm_fops;
281281
tdisk->queue = tqueue;
282282

283-
targetdata = tt->init(tgt_dev, tdisk);
283+
targetdata = tt->init(tgt_dev, tdisk, create->flags);
284284
if (IS_ERR(targetdata))
285285
goto err_init;
286286

@@ -1244,8 +1244,16 @@ static long nvm_ioctl_dev_create(struct file *file, void __user *arg)
12441244
create.tgtname[DISK_NAME_LEN - 1] = '\0';
12451245

12461246
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+
}
12491257
}
12501258

12511259
return __nvm_configure_create(&create);

drivers/lightnvm/rrpc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,8 @@ static int rrpc_luns_configure(struct rrpc *rrpc)
15061506

15071507
static struct nvm_tgt_type tt_rrpc;
15081508

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)
15101511
{
15111512
struct request_queue *bqueue = dev->q;
15121513
struct request_queue *tqueue = tdisk->queue;

include/linux/lightnvm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,8 @@ static inline int ppa_cmp_blk(struct ppa_addr ppa1, struct ppa_addr ppa2)
436436

437437
typedef blk_qc_t (nvm_tgt_make_rq_fn)(struct request_queue *, struct bio *);
438438
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);
440441
typedef void (nvm_tgt_exit_fn)(void *);
441442
typedef int (nvm_tgt_sysfs_init_fn)(struct gendisk *);
442443
typedef void (nvm_tgt_sysfs_exit_fn)(struct gendisk *);

include/uapi/linux/lightnvm.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ struct nvm_ioctl_create_conf {
8585
};
8686
};
8787

88+
enum {
89+
NVM_TARGET_FACTORY = 1 << 0, /* Init target in factory mode */
90+
};
91+
8892
struct nvm_ioctl_create {
8993
char dev[DISK_NAME_LEN]; /* open-channel SSD device */
9094
char tgttype[NVM_TTYPE_NAME_MAX]; /* target type name */

0 commit comments

Comments
 (0)