Skip to content

Commit

Permalink
lightnvm: remove get_lun operation on gennvm
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Javier González authored and Jens Axboe committed Nov 29, 2016
1 parent 8e79b5c commit 0ac4072
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 30 deletions.
13 changes: 1 addition & 12 deletions drivers/lightnvm/gennvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
23 changes: 11 additions & 12 deletions drivers/lightnvm/rrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1410,12 +1408,13 @@ static int rrpc_luns_configure(struct rrpc *rrpc)
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;

Expand Down Expand Up @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions include/linux/lightnvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 sector_t (nvm_tgt_capacity_fn)(void *);
typedef void *(nvm_tgt_init_fn)(struct nvm_tgt_dev *, struct gendisk *, int,
int);
typedef void *(nvm_tgt_init_fn)(struct nvm_tgt_dev *, struct gendisk *,
struct list_head *lun_list);
typedef void (nvm_tgt_exit_fn)(void *);

struct nvm_tgt_type {
Expand Down Expand Up @@ -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_erase_blk_fn)(struct nvm_dev *, struct nvm_block *, 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 int (nvmm_get_area_fn)(struct nvm_dev *, sector_t *, sector_t);
Expand All @@ -563,9 +562,6 @@ struct nvmm_type {
/* Bad block mgmt */
nvmm_mark_blk_fn *mark_blk;

/* Configuration management */
nvmm_get_lun_fn *get_lun;

/* Statistics */
nvmm_lun_info_print_fn *lun_info_print;

Expand Down

0 comments on commit 0ac4072

Please sign in to comment.