Commit 54b2db3d authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix infinite loop in bch2_btree_cache_scan()

When attempting to free btree nodes, we might not be able to free all
the nodes that were requested. But the code was looping until it had
freed _all_ the nodes requested, when it should have only been
attempting to free nr nodes.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent f74a5051
...@@ -309,7 +309,7 @@ static unsigned long bch2_btree_cache_scan(struct shrinker *shrink, ...@@ -309,7 +309,7 @@ static unsigned long bch2_btree_cache_scan(struct shrinker *shrink,
touched++; touched++;
if (freed >= nr) if (touched >= nr)
break; break;
if (!btree_node_reclaim(c, b)) { if (!btree_node_reclaim(c, b)) {
...@@ -323,7 +323,7 @@ static unsigned long bch2_btree_cache_scan(struct shrinker *shrink, ...@@ -323,7 +323,7 @@ static unsigned long bch2_btree_cache_scan(struct shrinker *shrink,
list_for_each_entry_safe(b, t, &bc->live, list) { list_for_each_entry_safe(b, t, &bc->live, list) {
touched++; touched++;
if (freed >= nr) { if (touched >= nr) {
/* Save position */ /* Save position */
if (&t->list != &bc->live) if (&t->list != &bc->live)
list_move_tail(&bc->live, &t->list); list_move_tail(&bc->live, &t->list);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment