aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lightnvm
diff options
context:
space:
mode:
authorWenwei Tao <ww.tao0320@gmail.com>2016-05-06 14:03:00 -0400
committerJens Axboe <axboe@fb.com>2016-05-06 14:51:10 -0400
commit66e3d07f75c6472d7198920488330634c118b255 (patch)
tree21054b481154bd7e0a1250023f7051eef3f0bb3a /drivers/lightnvm
parent7f7c5d03c0e8e177d1ed1c6412ae035e8eff35de (diff)
lightnvm: calculate rrpc total blocks and sectors up front
Calculate rrpc total blocks and sectors up front, make sense to use them. For example, we use rrpc->nr_sects to calculate rrpc area size, but it makes no sense if we don't initialize it up front, since it would be zero until we finish rrpc luns init. Signed-off-by: Wenwei Tao <ww.tao0320@gmail.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/rrpc.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/lightnvm/rrpc.c b/drivers/lightnvm/rrpc.c
index 3ab6495c3fd8..c0e303cd9d60 100644
--- a/drivers/lightnvm/rrpc.c
+++ b/drivers/lightnvm/rrpc.c
@@ -1207,10 +1207,6 @@ static int rrpc_luns_init(struct rrpc *rrpc, int lun_begin, int lun_end)
1207 1207
1208 INIT_WORK(&rlun->ws_gc, rrpc_lun_gc); 1208 INIT_WORK(&rlun->ws_gc, rrpc_lun_gc);
1209 spin_lock_init(&rlun->lock); 1209 spin_lock_init(&rlun->lock);
1210
1211 rrpc->total_blocks += dev->blks_per_lun;
1212 rrpc->nr_sects += dev->sec_per_lun;
1213
1214 } 1210 }
1215 1211
1216 return 0; 1212 return 0;
@@ -1388,6 +1384,8 @@ static void *rrpc_init(struct nvm_dev *dev, struct gendisk *tdisk,
1388 INIT_WORK(&rrpc->ws_requeue, rrpc_requeue); 1384 INIT_WORK(&rrpc->ws_requeue, rrpc_requeue);
1389 1385
1390 rrpc->nr_luns = lun_end - lun_begin + 1; 1386 rrpc->nr_luns = lun_end - lun_begin + 1;
1387 rrpc->total_blocks = (unsigned long)dev->blks_per_lun * rrpc->nr_luns;
1388 rrpc->nr_sects = (unsigned long long)dev->sec_per_lun * rrpc->nr_luns;
1391 1389
1392 /* simple round-robin strategy */ 1390 /* simple round-robin strategy */
1393 atomic_set(&rrpc->next_lun, -1); 1391 atomic_set(&rrpc->next_lun, -1);