diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-03-28 20:57:59 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:58 -0400 |
commit | c5f51cdd5f1c0368c73637bea045d6d20c6f87c2 (patch) | |
tree | ebeb5611e27de7b00a27e9699a946a62bcd2f037 /fs/bcachefs/btree_key_cache.h | |
parent | 883d9701f1589461ae9c9214303a8c175ffb79c5 (diff) | |
download | lwn-c5f51cdd5f1c0368c73637bea045d6d20c6f87c2.tar.gz lwn-c5f51cdd5f1c0368c73637bea045d6d20c6f87c2.zip |
bcachefs: Have journal reclaim thread flush more aggressively
This adds a new watermark for the journal reclaim when flushing btree
key cache entries - it should try and stay ahead of where foreground
threads doing transaction commits will enter direct journal reclaim.
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 | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/bcachefs/btree_key_cache.h b/fs/bcachefs/btree_key_cache.h index 02715cd258ab..4e1e5a9c7656 100644 --- a/fs/bcachefs/btree_key_cache.h +++ b/fs/bcachefs/btree_key_cache.h @@ -1,6 +1,15 @@ #ifndef _BCACHEFS_BTREE_KEY_CACHE_H #define _BCACHEFS_BTREE_KEY_CACHE_H +static inline size_t bch2_nr_btree_keys_want_flush(struct bch_fs *c) +{ + size_t nr_dirty = atomic_long_read(&c->btree_key_cache.nr_dirty); + size_t nr_keys = atomic_long_read(&c->btree_key_cache.nr_keys); + size_t max_dirty = nr_keys / 4; + + return max_t(ssize_t, 0, nr_dirty - max_dirty); +} + static inline size_t bch2_nr_btree_keys_need_flush(struct bch_fs *c) { size_t nr_dirty = atomic_long_read(&c->btree_key_cache.nr_dirty); |