Skip to content

Commit 2fde0e4

Browse files
javigonaxboe
authored andcommitted
lightnvm: add free and bad lun info to show luns
Add free block, used block, and bad block information to the show debug interface. This information is used to debug how targets track blocks. Also, change debug function name to make it more generic. Signed-off-by: Javier Gonzalez <javier@cnexlabs.com> Signed-off-by: Matias Bjørling <m@bjorling.me> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent 0b59733 commit 2fde0e4

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

drivers/lightnvm/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ static int nvm_configure_show(const char *val)
544544
if (!dev->mt)
545545
return 0;
546546

547-
dev->mt->free_blocks_print(dev);
547+
dev->mt->lun_info_print(dev);
548548

549549
return 0;
550550
}

drivers/lightnvm/gennvm.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -464,15 +464,24 @@ static struct nvm_lun *gennvm_get_lun(struct nvm_dev *dev, int lunid)
464464
return &gn->luns[lunid].vlun;
465465
}
466466

467-
static void gennvm_free_blocks_print(struct nvm_dev *dev)
467+
static void gennvm_lun_info_print(struct nvm_dev *dev)
468468
{
469469
struct gen_nvm *gn = dev->mp;
470470
struct gen_lun *lun;
471471
unsigned int i;
472472

473-
gennvm_for_each_lun(gn, lun, i)
474-
pr_info("%s: lun%8u\t%u\n",
475-
dev->name, i, lun->vlun.nr_free_blocks);
473+
474+
gennvm_for_each_lun(gn, lun, i) {
475+
spin_lock(&lun->vlun.lock);
476+
477+
pr_info("%s: lun%8u\t%u\t%u\t%u\n",
478+
dev->name, i,
479+
lun->vlun.nr_free_blocks,
480+
lun->vlun.nr_inuse_blocks,
481+
lun->vlun.nr_bad_blocks);
482+
483+
spin_unlock(&lun->vlun.lock);
484+
}
476485
}
477486

478487
static struct nvmm_type gennvm = {
@@ -490,7 +499,7 @@ static struct nvmm_type gennvm = {
490499
.erase_blk = gennvm_erase_blk,
491500

492501
.get_lun = gennvm_get_lun,
493-
.free_blocks_print = gennvm_free_blocks_print,
502+
.lun_info_print = gennvm_lun_info_print,
494503
};
495504

496505
static int __init gennvm_module_init(void)

include/linux/lightnvm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ typedef int (nvmm_end_io_fn)(struct nvm_rq *, int);
380380
typedef int (nvmm_erase_blk_fn)(struct nvm_dev *, struct nvm_block *,
381381
unsigned long);
382382
typedef struct nvm_lun *(nvmm_get_lun_fn)(struct nvm_dev *, int);
383-
typedef void (nvmm_free_blocks_print_fn)(struct nvm_dev *);
383+
typedef void (nvmm_lun_info_print_fn)(struct nvm_dev *);
384384

385385
struct nvmm_type {
386386
const char *name;
@@ -404,7 +404,7 @@ struct nvmm_type {
404404
nvmm_get_lun_fn *get_lun;
405405

406406
/* Statistics */
407-
nvmm_free_blocks_print_fn *free_blocks_print;
407+
nvmm_lun_info_print_fn *lun_info_print;
408408
struct list_head list;
409409
};
410410

0 commit comments

Comments
 (0)