diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-04-01 04:44:55 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:08:59 +0300 |
commit | 241e26369e1267be376490152ee2c52021b4321a (patch) | |
tree | 3959554638d2d03f6d25d8433d1964b1b3532424 /fs/bcachefs/btree_key_cache.h | |
parent | 9d8022db1ccfff6aaf1de6158c2a26b667c70a15 (diff) | |
download | linux-241e26369e1267be376490152ee2c52021b4321a.tar.xz |
bcachefs: Don't flush btree writes more aggressively because of btree key cache
We need to flush the btree key cache when it's too dirty, because
otherwise the shrinker won't be able to reclaim memory - this is done by
journal reclaim. But journal reclaim also kicks btree node writes: this
meant that btree node writes were getting kicked much too often just
because we needed to flush btree key cache keys.
This patch splits journal pins into two different lists, and teaches
journal reclaim to not flush btree node writes when it only needs to
flush key cache keys.
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 | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/fs/bcachefs/btree_key_cache.h b/fs/bcachefs/btree_key_cache.h index 4e1e5a9c7656..7e2b0a08f745 100644 --- a/fs/bcachefs/btree_key_cache.h +++ b/fs/bcachefs/btree_key_cache.h @@ -1,15 +1,6 @@ #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); @@ -29,6 +20,9 @@ static inline bool bch2_btree_key_cache_must_wait(struct bch_fs *c) test_bit(JOURNAL_RECLAIM_STARTED, &c->journal.flags); } +int bch2_btree_key_cache_journal_flush(struct journal *, + struct journal_entry_pin *, u64); + struct bkey_cached * bch2_btree_key_cache_find(struct bch_fs *, enum btree_id, struct bpos); |