diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-02-07 00:51:42 +0100 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 23:09:53 +0200 |
commit | 1b30ed5fd87828b5e29647510eefb18a363e4d19 (patch) | |
tree | 37cc6ade2fc2047dde253df12c14b8dae3e00d1a /fs/bcachefs/alloc_background.c | |
parent | bcachefs: Fix integer overflow warnings on 32 bit (diff) | |
download | linux-1b30ed5fd87828b5e29647510eefb18a363e4d19.tar.xz linux-1b30ed5fd87828b5e29647510eefb18a363e4d19.zip |
bcachefs: Use btree write buffer for LRU btree
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/alloc_background.c')
-rw-r--r-- | fs/bcachefs/alloc_background.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index 81bd56152fd0..af3e55fdd54a 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -9,6 +9,7 @@ #include "btree_update.h" #include "btree_update_interior.h" #include "btree_gc.h" +#include "btree_write_buffer.h" #include "buckets.h" #include "buckets_waiting_for_journal.h" #include "clock.h" @@ -1775,15 +1776,11 @@ static int invalidate_one_bucket(struct btree_trans *trans, if (ret) goto out; - if (lru_pos_time(lru_iter->pos) != alloc_lru_idx(a->v)) { - prt_str(&buf, "alloc key does not point back to lru entry when invalidating bucket:"); - goto err; - } + /* We expect harmless races here due to the btree write buffer: */ + if (lru_pos_time(lru_iter->pos) != alloc_lru_idx(a->v)) + goto out; - if (a->v.data_type != BCH_DATA_cached) { - prt_str(&buf, "lru entry points to non cached bucket:"); - goto err; - } + BUG_ON(a->v.data_type != BCH_DATA_cached); if (!a->v.cached_sectors) bch_err(c, "invalidating empty bucket, confused"); @@ -1845,6 +1842,10 @@ static void bch2_do_invalidates_work(struct work_struct *work) bch2_trans_init(&trans, c, 0, 0); + ret = bch2_btree_write_buffer_flush(&trans); + if (ret) + goto err; + for_each_member_device(ca, c, i) { s64 nr_to_invalidate = should_invalidate_buckets(ca, bch2_dev_usage_read(ca)); @@ -1860,7 +1861,7 @@ static void bch2_do_invalidates_work(struct work_struct *work) break; } } - +err: bch2_trans_exit(&trans); bch2_write_ref_put(c, BCH_WRITE_REF_invalidate); } |