]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
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)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commit70f1222549eba5537b0f051ff13bda1b83be8427
tree631ca4997d6ed7f9f1d5a09e7c2a55adf9d0b71a
parentaf9bbaf042467cd9b5153581eff46bf3db1d8dd2
bcache: fix using of loop variable in memory shrink

BugLink: https://bugs.launchpad.net/bugs/1784665
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>
(cherry picked from commit ca71df31661a0518ed58a1a59cf1993962153ebb)
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/md/bcache/btree.c