summaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_key_cache.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2020-12-19 15:39:10 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:50 -0400
commite323edd6d39094ce021dbb20e513b03ae6ebecbe (patch)
treec904c0afdc29ff891dd220d74db1dcd6fe23660b /fs/bcachefs/btree_key_cache.h
parentd483dd17e2bfd6858498d39eb92abd232d7b8e97 (diff)
downloadlwn-e323edd6d39094ce021dbb20e513b03ae6ebecbe.tar.gz
lwn-e323edd6d39094ce021dbb20e513b03ae6ebecbe.zip
bcachefs: Fix for spinning in journal reclaim on startup
We normally avoid having too many dirty keys in the btree key cache, to ensure that we can always shrink our caches to reclaim memory if needed. But this check was causing us to go into an infinite loop on startup, in the btree insert path before journal reclaim was started. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_key_cache.h')
-rw-r--r--fs/bcachefs/btree_key_cache.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/bcachefs/btree_key_cache.h b/fs/bcachefs/btree_key_cache.h
index dad3e344dcf9..2f8b5521718a 100644
--- a/fs/bcachefs/btree_key_cache.h
+++ b/fs/bcachefs/btree_key_cache.h
@@ -16,7 +16,8 @@ static inline bool bch2_btree_key_cache_must_wait(struct bch_fs *c)
size_t nr_keys = READ_ONCE(c->btree_key_cache.nr_keys);
size_t max_dirty = 4096 + (nr_keys * 3) / 4;
- return nr_dirty > max_dirty;
+ return nr_dirty > max_dirty &&
+ test_bit(JOURNAL_RECLAIM_STARTED, &c->journal.flags);
}
struct bkey_cached *