Skip to content

Commit 09e913f

Browse files
Hongbo LiKent Overstreet
authored andcommitted
bcachefs: fix the count of nr_freed_pcpu after changing bc->freed_nonpcpu list
When allocating bkey_cached from bc->freed_pcpu list, it missed decreasing the count of nr_freed_pcpu which would cause the mismatch between the value of nr_freed_pcpu and the list items. This problem also exists in moving new bkey_cached to bc->freed_pcpu list. If these happened, the bug info may appear in bch2_fs_btree_key_cache_exit by the follow code: BUG_ON(list_count_nodes(&bc->freed_pcpu) != bc->nr_freed_pcpu); BUG_ON(list_count_nodes(&bc->freed_nonpcpu) != bc->nr_freed_nonpcpu); Fixes: c65c13f ("bcachefs: Run btree key cache shrinker less aggressively") Signed-off-by: Hongbo Li <lihongbo22@huawei.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 30e615a commit 09e913f

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

fs/bcachefs/btree_key_cache.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ static void bkey_cached_move_to_freelist(struct btree_key_cache *bc,
169169
} else {
170170
mutex_lock(&bc->lock);
171171
list_move_tail(&ck->list, &bc->freed_pcpu);
172+
bc->nr_freed_pcpu++;
172173
mutex_unlock(&bc->lock);
173174
}
174175
}
@@ -245,6 +246,7 @@ bkey_cached_alloc(struct btree_trans *trans, struct btree_path *path,
245246
if (!list_empty(&bc->freed_pcpu)) {
246247
ck = list_last_entry(&bc->freed_pcpu, struct bkey_cached, list);
247248
list_del_init(&ck->list);
249+
bc->nr_freed_pcpu--;
248250
}
249251
mutex_unlock(&bc->lock);
250252
}

0 commit comments

Comments
 (0)