diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2020-11-19 21:40:03 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:48 -0400 |
commit | d5425a3b220a8b94ae2dd3c74af001a6b1216651 (patch) | |
tree | b1a1c328a1e22f247ec9d3702ac4ff297722df7f /fs/bcachefs/btree_key_cache.h | |
parent | 9d4582ffdb286d3513ee9ebf7961b1741d8cbc0d (diff) | |
download | lwn-d5425a3b220a8b94ae2dd3c74af001a6b1216651.tar.gz lwn-d5425a3b220a8b94ae2dd3c74af001a6b1216651.zip |
bcachefs: Throttle updates when btree key cache is too dirty
This is needed to ensure we don't deadlock because journal reclaim and
thus memory reclaim isn't making forward progress.
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.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/bcachefs/btree_key_cache.h b/fs/bcachefs/btree_key_cache.h index 7723a2178430..d7d31a0662c3 100644 --- a/fs/bcachefs/btree_key_cache.h +++ b/fs/bcachefs/btree_key_cache.h @@ -5,11 +5,20 @@ static inline size_t bch2_nr_btree_keys_need_flush(struct bch_fs *c) { size_t nr_dirty = READ_ONCE(c->btree_key_cache.nr_dirty); size_t nr_keys = READ_ONCE(c->btree_key_cache.nr_dirty); - size_t max_dirty = 1024 + (nr_keys * 3) / 4; + size_t max_dirty = 4096 + nr_keys / 2; return max_t(ssize_t, 0, nr_dirty - max_dirty); } +static inline bool bch2_btree_key_cache_must_wait(struct bch_fs *c) +{ + size_t nr_dirty = READ_ONCE(c->btree_key_cache.nr_dirty); + size_t nr_keys = READ_ONCE(c->btree_key_cache.nr_dirty); + size_t max_dirty = 4096 + (nr_keys * 3) / 4; + + return nr_dirty > max_dirty; +} + struct bkey_cached * bch2_btree_key_cache_find(struct bch_fs *, enum btree_id, struct bpos); |