lightnvm: keep track of block counts

Maintain number of in use blocks, free blocks, and bad blocks in a per
lun basis. This allows the upper layers to get information about the
state of each lun.

Also, account for blocks reserved to the device on the free block count.
nr_free_blocks matches now the actual number of blocks on the free list
when the device is booted.

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>
This commit is contained in:
Javier Gonzalez
2015-11-20 13:47:56 +01:00
committed by Jens Axboe
parent 47b3115ae7
commit 0b59733b95
2 changed files with 15 additions and 1 deletions

View File

@@ -213,7 +213,9 @@ struct nvm_lun {
int lun_id;
int chnl_id;
unsigned int nr_inuse_blocks; /* Number of used blocks */
unsigned int nr_free_blocks; /* Number of unused blocks */
unsigned int nr_bad_blocks; /* Number of bad blocks */
struct nvm_block *blocks;
spinlock_t lock;