summaryrefslogtreecommitdiff
path: root/fs/bcachefs/alloc_background.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-02-07 02:51:42 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:53 +0300
commit1b30ed5fd87828b5e29647510eefb18a363e4d19 (patch)
tree37cc6ade2fc2047dde253df12c14b8dae3e00d1a /fs/bcachefs/alloc_background.c
parentf2c6e4b3621778103805fe4d5f384db3fcd96159 (diff)
downloadlinux-1b30ed5fd87828b5e29647510eefb18a363e4d19.tar.xz
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.c19
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);
}