summaryrefslogtreecommitdiff
path: root/drivers/lightnvm
diff options
context:
space:
mode:
authorJavier González <jg@lightnvm.io>2016-11-28 22:39:07 +0100
committerJens Axboe <axboe@fb.com>2016-11-29 12:12:51 -0700
commit0ac4072eb10c9627415eb1ca511121156e20012c (patch)
treea2581ae27e54d08e0f95bdff8712fd5daade109e /drivers/lightnvm
parent8e79b5cb1d3b8eceaf6862995952dd4de431dd99 (diff)
downloadlinux-0ac4072eb10c9627415eb1ca511121156e20012c.tar.gz
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: Javier González <javier@cnexlabs.com> Signed-off-by: Matias Bjørling <m@bjorling.me> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/lightnvm')
-rw-r--r--drivers/lightnvm/gennvm.c13
-rw-r--r--drivers/lightnvm/rrpc.c23
2 files changed, 12 insertions, 24 deletions
diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c
index 8791a2aaa9e3..3cf5d5947070 100644
--- a/drivers/lightnvm/gennvm.c
+++ b/drivers/lightnvm/gennvm.c
@@ -159,7 +159,7 @@ static int gen_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
tdisk->fops = &gen_fops;
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))
goto err_init;
@@ -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);
}
-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)
{
struct gen_dev *gn = dev->mp;
@@ -655,7 +645,6 @@ static struct nvmm_type gen = {
.mark_blk = gen_mark_blk,
- .get_lun = gen_get_lun,
.lun_info_print = gen_lun_info_print,
.get_area = gen_get_area,
diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c
index 5377c7a987aa..165b9d396493 100644
--- a/drivers/lightnvm/rrpc.c
+++ b/drivers/lightnvm/rrpc.c
@@ -1199,10 +1199,11 @@ static void rrpc_luns_free(struct rrpc *rrpc)
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_geo *geo = &dev->geo;
+ struct nvm_lun *lun;
struct rrpc_lun *rlun;
int i, j, ret = -EINVAL;
@@ -1218,16 +1219,11 @@ static int rrpc_luns_init(struct rrpc *rrpc, int lun_begin, int lun_end)
if (!rrpc->luns)
return -ENOMEM;
- /* 1:1 mapping */
- for (i = 0; i < rrpc->nr_luns; i++) {
- int lunid = lun_begin + i;
- struct nvm_lun *lun;
+ i = 0;
- lun = dev->mt->get_lun(dev->parent, lunid);
- if (!lun)
- goto err;
-
- rlun = &rrpc->luns[i];
+ /* 1:1 mapping */
+ list_for_each_entry(lun, lun_list, list) {
+ rlun = &rrpc->luns[i++];
rlun->parent = lun;
rlun->blocks = vzalloc(sizeof(struct rrpc_block) *
geo->blks_per_lun);
@@ -1256,6 +1252,8 @@ static int rrpc_luns_init(struct rrpc *rrpc, int lun_begin, int lun_end)
spin_lock_init(&rlun->lock);
}
+ WARN_ON(i != rrpc->nr_luns);
+
return 0;
err:
return ret;
@@ -1410,12 +1408,13 @@ err:
static struct nvm_tgt_type tt_rrpc;
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 *tqueue = tdisk->queue;
struct nvm_geo *geo = &dev->geo;
struct rrpc *rrpc;
+ int lun_begin = (list_first_entry(lun_list, struct nvm_lun, list))->id;
sector_t soffset;
int ret;
@@ -1450,7 +1449,7 @@ static void *rrpc_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk,
}
rrpc->soffset = soffset;
- ret = rrpc_luns_init(rrpc, lun_begin, lun_end);
+ ret = rrpc_luns_init(rrpc, lun_list);
if (ret) {
pr_err("nvm: rrpc: could not initialize luns\n");
goto err;