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>
This commit is contained in:
parent
5d32c5bb07
commit
f51e84fe24
@ -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;
|
||||
|
@ -240,6 +240,7 @@ void bch2_journal_space_available(struct journal *j)
|
||||
u64s_remaining -= (u64) total << 3;
|
||||
u64s_remaining = max(0LL, u64s_remaining);
|
||||
u64s_remaining /= 2;
|
||||
u64s_remaining = min_t(u64, u64s_remaining, U32_MAX);
|
||||
out:
|
||||
j->cur_entry_sectors = !ret ? j->space[journal_space_discarded].next_entry : 0;
|
||||
j->cur_entry_error = ret;
|
||||
|
Loading…
Reference in New Issue
Block a user