static void gen_blocks_free(struct nvm_dev *dev)
{
struct gen_dev *gn = dev->mp;
- struct gen_lun *lun;
+ struct nvm_lun *lun;
int i;
gen_for_each_lun(gn, lun, i) {
- if (!lun->vlun.blocks)
+ if (!lun->blocks)
break;
- vfree(lun->vlun.blocks);
+ vfree(lun->blocks);
}
}
static int gen_luns_init(struct nvm_dev *dev, struct gen_dev *gn)
{
- struct gen_lun *lun;
+ struct nvm_lun *lun;
int i;
- gn->luns = kcalloc(dev->nr_luns, sizeof(struct gen_lun), GFP_KERNEL);
+ gn->luns = kcalloc(dev->nr_luns, sizeof(struct nvm_lun), GFP_KERNEL);
if (!gn->luns)
return -ENOMEM;
gen_for_each_lun(gn, lun, i) {
- spin_lock_init(&lun->vlun.lock);
INIT_LIST_HEAD(&lun->free_list);
INIT_LIST_HEAD(&lun->used_list);
INIT_LIST_HEAD(&lun->bb_list);
- lun->reserved_blocks = 2; /* for GC only */
- lun->vlun.id = i;
- lun->vlun.lun_id = i % dev->luns_per_chnl;
- lun->vlun.chnl_id = i / dev->luns_per_chnl;
- lun->vlun.nr_free_blocks = dev->blks_per_lun;
+ spin_lock_init(&lun->lock);
+
+ lun->id = i;
+ lun->lun_id = i % dev->luns_per_chnl;
+ lun->chnl_id = i / dev->luns_per_chnl;
+ lun->nr_free_blocks = dev->blks_per_lun;
}
return 0;
}
u8 *blks, int nr_blks)
{
struct nvm_dev *dev = gn->dev;
- struct gen_lun *lun;
+ struct nvm_lun *lun;
struct nvm_block *blk;
int i;
if (blks[i] == NVM_BLK_T_FREE)
continue;
- blk = &lun->vlun.blocks[i];
+ blk = &lun->blocks[i];
list_move_tail(&blk->list, &lun->bb_list);
- lun->vlun.nr_free_blocks--;
+ blk->state = NVM_BLK_ST_BAD;
+ lun->nr_free_blocks--;
}
return 0;
struct nvm_dev *dev = private;
struct gen_dev *gn = dev->mp;
u64 elba = slba + nlb;
- struct gen_lun *lun;
+ struct nvm_lun *lun;
struct nvm_block *blk;
u64 i;
int lun_id;
/* Calculate block offset into lun */
pba = pba - (dev->sec_per_lun * lun_id);
- blk = &lun->vlun.blocks[div_u64(pba, dev->sec_per_blk)];
+ blk = &lun->blocks[div_u64(pba, dev->sec_per_blk)];
if (!blk->state) {
/* at this point, we don't know anything about the
*/
list_move_tail(&blk->list, &lun->used_list);
blk->state = NVM_BLK_ST_TGT;
- lun->vlun.nr_free_blocks--;
+ lun->nr_free_blocks--;
}
}
static int gen_blocks_init(struct nvm_dev *dev, struct gen_dev *gn)
{
- struct gen_lun *lun;
+ struct nvm_lun *lun;
struct nvm_block *block;
sector_t lun_iter, blk_iter, cur_block_id = 0;
int ret, nr_blks;
return -ENOMEM;
gen_for_each_lun(gn, lun, lun_iter) {
- lun->vlun.blocks = vzalloc(sizeof(struct nvm_block) *
+ lun->blocks = vzalloc(sizeof(struct nvm_block) *
dev->blks_per_lun);
- if (!lun->vlun.blocks) {
+ if (!lun->blocks) {
kfree(blks);
return -ENOMEM;
}
for (blk_iter = 0; blk_iter < dev->blks_per_lun; blk_iter++) {
- block = &lun->vlun.blocks[blk_iter];
+ block = &lun->blocks[blk_iter];
INIT_LIST_HEAD(&block->list);
- block->lun = &lun->vlun;
+ block->lun = lun;
block->id = cur_block_id++;
list_add_tail(&block->list, &lun->free_list);
struct ppa_addr ppa;
ppa.ppa = 0;
- ppa.g.ch = lun->vlun.chnl_id;
- ppa.g.lun = lun->vlun.lun_id;
+ ppa.g.ch = lun->chnl_id;
+ ppa.g.lun = lun->lun_id;
ret = nvm_get_bb_tbl(dev, ppa, blks);
if (ret)
}
static struct nvm_block *gen_get_blk(struct nvm_dev *dev,
- struct nvm_lun *vlun, unsigned long flags)
+ struct nvm_lun *lun, unsigned long flags)
{
- struct gen_lun *lun = container_of(vlun, struct gen_lun, vlun);
struct nvm_block *blk = NULL;
int is_gc = flags & NVM_IOTYPE_GC;
- spin_lock(&vlun->lock);
+ spin_lock(&lun->lock);
if (list_empty(&lun->free_list)) {
pr_err_ratelimited("gen: lun %u have no free pages available",
- lun->vlun.id);
+ lun->id);
goto out;
}
- if (!is_gc && lun->vlun.nr_free_blocks < lun->reserved_blocks)
+ if (!is_gc && lun->nr_free_blocks < lun->reserved_blocks)
goto out;
blk = list_first_entry(&lun->free_list, struct nvm_block, list);
list_move_tail(&blk->list, &lun->used_list);
blk->state = NVM_BLK_ST_TGT;
- lun->vlun.nr_free_blocks--;
+ lun->nr_free_blocks--;
out:
- spin_unlock(&vlun->lock);
+ spin_unlock(&lun->lock);
return blk;
}
static void gen_put_blk(struct nvm_dev *dev, struct nvm_block *blk)
{
- struct nvm_lun *vlun = blk->lun;
- struct gen_lun *lun = container_of(vlun, struct gen_lun, vlun);
+ struct nvm_lun *lun = blk->lun;
- spin_lock(&vlun->lock);
+ spin_lock(&lun->lock);
if (blk->state & NVM_BLK_ST_TGT) {
list_move_tail(&blk->list, &lun->free_list);
- lun->vlun.nr_free_blocks++;
+ lun->nr_free_blocks++;
blk->state = NVM_BLK_ST_FREE;
} else if (blk->state & NVM_BLK_ST_BAD) {
list_move_tail(&blk->list, &lun->bb_list);
blk->id, blk->state);
list_move_tail(&blk->list, &lun->bb_list);
}
- spin_unlock(&vlun->lock);
+ spin_unlock(&lun->lock);
}
static void gen_mark_blk(struct nvm_dev *dev, struct ppa_addr ppa, int type)
{
struct gen_dev *gn = dev->mp;
- struct gen_lun *lun;
+ struct nvm_lun *lun;
struct nvm_block *blk;
pr_debug("gen: ppa (ch: %u lun: %u blk: %u pg: %u) -> %u\n",
}
lun = &gn->luns[(dev->luns_per_chnl * ppa.g.ch) + ppa.g.lun];
- blk = &lun->vlun.blocks[ppa.g.blk];
+ blk = &lun->blocks[ppa.g.blk];
/* will be moved to bb list on put_blk from target */
blk->state = type;
if (unlikely(lunid >= dev->nr_luns))
return NULL;
- return &gn->luns[lunid].vlun;
+ return &gn->luns[lunid];
}
static void gen_lun_info_print(struct nvm_dev *dev)
{
struct gen_dev *gn = dev->mp;
- struct gen_lun *lun;
+ struct nvm_lun *lun;
unsigned int i;
gen_for_each_lun(gn, lun, i) {
- spin_lock(&lun->vlun.lock);
+ spin_lock(&lun->lock);
pr_info("%s: lun%8u\t%u\n", dev->name, i,
- lun->vlun.nr_free_blocks);
+ lun->nr_free_blocks);
- spin_unlock(&lun->vlun.lock);
+ spin_unlock(&lun->lock);
}
}