diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2020-12-05 21:03:57 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:49 -0400 |
commit | f51e84fe24d8d170bfbba626e76ee08b1ab7b283 (patch) | |
tree | ecef2e025336fd350113b49044ccb3eed6c198e8 /fs/bcachefs/btree_key_cache.h | |
parent | 5d32c5bb076e76232e56fd44c537046abd54d32c (diff) | |
download | lwn-f51e84fe24d8d170bfbba626e76ee08b1ab7b283.tar.gz lwn-f51e84fe24d8d170bfbba626e76ee08b1ab7b283.zip |
bcachefs: Fix btree key cache dirty checks
Had a type that meant we were triggering journal reclaim _much_ more
aggressively than needed. Also, fix a potential integer overflow.
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 | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/bcachefs/btree_key_cache.h b/fs/bcachefs/btree_key_cache.h index d7d31a0662c3..dad3e344dcf9 100644 --- a/fs/bcachefs/btree_key_cache.h +++ b/fs/bcachefs/btree_key_cache.h @@ -4,8 +4,8 @@ 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 = 4096 + nr_keys / 2; + size_t nr_keys = READ_ONCE(c->btree_key_cache.nr_keys); + size_t max_dirty = 1024 + nr_keys / 2; return max_t(ssize_t, 0, nr_dirty - max_dirty); } @@ -13,7 +13,7 @@ static inline size_t bch2_nr_btree_keys_need_flush(struct bch_fs *c) 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 nr_keys = READ_ONCE(c->btree_key_cache.nr_keys); size_t max_dirty = 4096 + (nr_keys * 3) / 4; return nr_dirty > max_dirty; |