Skip to content

Commit 656e33c

Browse files
MatiasBjorlingaxboe
authored andcommitted
lightnvm: move device L2P detection to core
A 1.2 device is able to manage the logical to physical mapping table internally or leave it to the host. A target only supports one of those approaches, and therefore must check on initialization. Move this check to core to avoid each target implement the check. Signed-off-by: Matias Bjørling <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 4b5d56e commit 656e33c

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

drivers/lightnvm/core.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,11 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
355355
return -EINVAL;
356356
}
357357

358+
if ((tt->flags & NVM_TGT_F_HOST_L2P) != (dev->geo.dom & NVM_RSP_L2P)) {
359+
pr_err("nvm: device is incompatible with target L2P type.\n");
360+
return -EINVAL;
361+
}
362+
358363
if (nvm_target_exists(create->tgtname)) {
359364
pr_err("nvm: target name already exists (%s)\n",
360365
create->tgtname);

drivers/lightnvm/pblk-init.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,13 +1210,6 @@ static void *pblk_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk,
12101210
return ERR_PTR(-EINVAL);
12111211
}
12121212

1213-
if (geo->version == NVM_OCSSD_SPEC_12 && geo->dom & NVM_RSP_L2P) {
1214-
pblk_err(pblk, "host-side L2P table not supported. (%x)\n",
1215-
geo->dom);
1216-
kfree(pblk);
1217-
return ERR_PTR(-EINVAL);
1218-
}
1219-
12201213
spin_lock_init(&pblk->resubmit_lock);
12211214
spin_lock_init(&pblk->trans_lock);
12221215
spin_lock_init(&pblk->lock);

include/linux/lightnvm.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,15 @@ typedef void (nvm_tgt_exit_fn)(void *, bool);
495495
typedef int (nvm_tgt_sysfs_init_fn)(struct gendisk *);
496496
typedef void (nvm_tgt_sysfs_exit_fn)(struct gendisk *);
497497

498+
enum {
499+
NVM_TGT_F_DEV_L2P = 0,
500+
NVM_TGT_F_HOST_L2P = 1 << 0,
501+
};
502+
498503
struct nvm_tgt_type {
499504
const char *name;
500505
unsigned int version[3];
506+
int flags;
501507

502508
/* target entry points */
503509
nvm_tgt_make_rq_fn *make_rq;

0 commit comments

Comments
 (0)