Commit 0ac4072e authored by Javier González's avatar Javier González Committed by Jens Axboe

lightnvm: remove get_lun operation on gennvm

Since LUNs are managed internally on the target, there is no need for
the media manager to implement a get_lun operation.
Signed-off-by: default avatarJavier González <javier@cnexlabs.com>
Signed-off-by: default avatarMatias Bjørling <m@bjorling.me>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 8e79b5cb
...@@ -159,7 +159,7 @@ static int gen_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create) ...@@ -159,7 +159,7 @@ static int gen_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
tdisk->fops = &gen_fops; tdisk->fops = &gen_fops;
tdisk->queue = tqueue; tdisk->queue = tqueue;
targetdata = tt->init(tgt_dev, tdisk, s->lun_begin, s->lun_end); targetdata = tt->init(tgt_dev, tdisk, &t->lun_list);
if (IS_ERR(targetdata)) if (IS_ERR(targetdata))
goto err_init; goto err_init;
...@@ -613,16 +613,6 @@ static int gen_erase_blk(struct nvm_dev *dev, struct nvm_block *blk, int flags) ...@@ -613,16 +613,6 @@ static int gen_erase_blk(struct nvm_dev *dev, struct nvm_block *blk, int flags)
return nvm_erase_ppa(dev, &addr, 1, flags); return nvm_erase_ppa(dev, &addr, 1, flags);
} }
static struct nvm_lun *gen_get_lun(struct nvm_dev *dev, int lunid)
{
struct gen_dev *gn = dev->mp;
if (unlikely(lunid >= dev->geo.nr_luns))
return NULL;
return &gn->luns[lunid];
}
static void gen_lun_info_print(struct nvm_dev *dev) static void gen_lun_info_print(struct nvm_dev *dev)
{ {
struct gen_dev *gn = dev->mp; struct gen_dev *gn = dev->mp;
...@@ -655,7 +645,6 @@ static struct nvmm_type gen = { ...@@ -655,7 +645,6 @@ static struct nvmm_type gen = {
.mark_blk = gen_mark_blk, .mark_blk = gen_mark_blk,
.get_lun = gen_get_lun,
.lun_info_print = gen_lun_info_print, .lun_info_print = gen_lun_info_print,
.get_area = gen_get_area, .get_area = gen_get_area,
......
...@@ -1199,10 +1199,11 @@ static void rrpc_luns_free(struct rrpc *rrpc) ...@@ -1199,10 +1199,11 @@ static void rrpc_luns_free(struct rrpc *rrpc)
kfree(rrpc->luns); kfree(rrpc->luns);
} }
static int rrpc_luns_init(struct rrpc *rrpc, int lun_begin, int lun_end) static int rrpc_luns_init(struct rrpc *rrpc, struct list_head *lun_list)
{ {
struct nvm_tgt_dev *dev = rrpc->dev; struct nvm_tgt_dev *dev = rrpc->dev;
struct nvm_geo *geo = &dev->geo; struct nvm_geo *geo = &dev->geo;
struct nvm_lun *lun;
struct rrpc_lun *rlun; struct rrpc_lun *rlun;
int i, j, ret = -EINVAL; int i, j, ret = -EINVAL;
...@@ -1218,16 +1219,11 @@ static int rrpc_luns_init(struct rrpc *rrpc, int lun_begin, int lun_end) ...@@ -1218,16 +1219,11 @@ static int rrpc_luns_init(struct rrpc *rrpc, int lun_begin, int lun_end)
if (!rrpc->luns) if (!rrpc->luns)
return -ENOMEM; return -ENOMEM;
/* 1:1 mapping */ i = 0;
for (i = 0; i < rrpc->nr_luns; i++) {
int lunid = lun_begin + i;
struct nvm_lun *lun;
lun = dev->mt->get_lun(dev->parent, lunid); /* 1:1 mapping */
if (!lun) list_for_each_entry(lun, lun_list, list) {
goto err; rlun = &rrpc->luns[i++];
rlun = &rrpc->luns[i];
rlun->parent = lun; rlun->parent = lun;
rlun->blocks = vzalloc(sizeof(struct rrpc_block) * rlun->blocks = vzalloc(sizeof(struct rrpc_block) *
geo->blks_per_lun); geo->blks_per_lun);
...@@ -1256,6 +1252,8 @@ static int rrpc_luns_init(struct rrpc *rrpc, int lun_begin, int lun_end) ...@@ -1256,6 +1252,8 @@ static int rrpc_luns_init(struct rrpc *rrpc, int lun_begin, int lun_end)
spin_lock_init(&rlun->lock); spin_lock_init(&rlun->lock);
} }
WARN_ON(i != rrpc->nr_luns);
return 0; return 0;
err: err:
return ret; return ret;
...@@ -1410,12 +1408,13 @@ static int rrpc_luns_configure(struct rrpc *rrpc) ...@@ -1410,12 +1408,13 @@ 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 lun_begin, int lun_end) struct list_head *lun_list)
{ {
struct request_queue *bqueue = dev->q; struct request_queue *bqueue = dev->q;
struct request_queue *tqueue = tdisk->queue; struct request_queue *tqueue = tdisk->queue;
struct nvm_geo *geo = &dev->geo; struct nvm_geo *geo = &dev->geo;
struct rrpc *rrpc; struct rrpc *rrpc;
int lun_begin = (list_first_entry(lun_list, struct nvm_lun, list))->id;
sector_t soffset; sector_t soffset;
int ret; int ret;
...@@ -1450,7 +1449,7 @@ static void *rrpc_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk, ...@@ -1450,7 +1449,7 @@ static void *rrpc_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk,
} }
rrpc->soffset = soffset; rrpc->soffset = soffset;
ret = rrpc_luns_init(rrpc, lun_begin, lun_end); ret = rrpc_luns_init(rrpc, lun_list);
if (ret) { if (ret) {
pr_err("nvm: rrpc: could not initialize luns\n"); pr_err("nvm: rrpc: could not initialize luns\n");
goto err; goto err;
......
...@@ -504,8 +504,8 @@ static inline int ppa_to_slc(struct nvm_dev *dev, int slc_pg) ...@@ -504,8 +504,8 @@ static inline int ppa_to_slc(struct nvm_dev *dev, int slc_pg)
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 *, int, typedef void *(nvm_tgt_init_fn)(struct nvm_tgt_dev *, struct gendisk *,
int); struct list_head *lun_list);
typedef void (nvm_tgt_exit_fn)(void *); typedef void (nvm_tgt_exit_fn)(void *);
struct nvm_tgt_type { struct nvm_tgt_type {
...@@ -541,7 +541,6 @@ typedef int (nvmm_remove_tgt_fn)(struct nvm_dev *, struct nvm_ioctl_remove *); ...@@ -541,7 +541,6 @@ typedef int (nvmm_remove_tgt_fn)(struct nvm_dev *, struct nvm_ioctl_remove *);
typedef int (nvmm_submit_io_fn)(struct nvm_dev *, struct nvm_rq *); typedef int (nvmm_submit_io_fn)(struct nvm_dev *, struct nvm_rq *);
typedef int (nvmm_erase_blk_fn)(struct nvm_dev *, struct nvm_block *, int); typedef int (nvmm_erase_blk_fn)(struct nvm_dev *, struct nvm_block *, int);
typedef void (nvmm_mark_blk_fn)(struct nvm_dev *, struct ppa_addr, int); typedef void (nvmm_mark_blk_fn)(struct nvm_dev *, struct ppa_addr, int);
typedef struct nvm_lun *(nvmm_get_lun_fn)(struct nvm_dev *, int);
typedef void (nvmm_lun_info_print_fn)(struct nvm_dev *); typedef void (nvmm_lun_info_print_fn)(struct nvm_dev *);
typedef int (nvmm_get_area_fn)(struct nvm_dev *, sector_t *, sector_t); typedef int (nvmm_get_area_fn)(struct nvm_dev *, sector_t *, sector_t);
...@@ -563,9 +562,6 @@ struct nvmm_type { ...@@ -563,9 +562,6 @@ struct nvmm_type {
/* Bad block mgmt */ /* Bad block mgmt */
nvmm_mark_blk_fn *mark_blk; nvmm_mark_blk_fn *mark_blk;
/* Configuration management */
nvmm_get_lun_fn *get_lun;
/* Statistics */ /* Statistics */
nvmm_lun_info_print_fn *lun_info_print; nvmm_lun_info_print_fn *lun_info_print;
......
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