bcache: fix using of loop variable in memory shrink
authorTang Junhui <tang.junhui@zte.com.cn>
Mon, 19 Mar 2018 00:36:22 +0000 (17:36 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 19 Mar 2018 02:15:20 +0000 (20:15 -0600)
commitca71df31661a0518ed58a1a59cf1993962153ebb
treeb1804803052dbad87886ce0284a93369fa915f7a
parentf3641c3abd1da978ee969b0203b71b86ec1bfa93
bcache: fix using of loop variable in memory shrink

In bch_mca_scan(), There are some confusion and logical error in the use of
loop variables. In this patch, we clarify them as:
1) nr: the number of btree nodes needs to scan, which will decrease after
we scan a btree node, and should not be less than 0;
2) i: the number of btree nodes have scanned, includes both
btree_cache_freeable and btree_cache, which should not be bigger than
btree_cache_used;
3) freed: the number of btree nodes have freed.

Signed-off-by: Tang Junhui <tang.junhui@zte.com.cn>
Reviewed-by: Michael Lyle <mlyle@lyle.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/btree.c