summaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_gc.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-04-10 19:59:26 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:31 -0400
commit7003589dabcdfd10345ede31044ce5e13ee65e7f (patch)
treec34b49a991b90bea0cdfab392e20063e40d2c4a8 /fs/bcachefs/btree_gc.c
parent84befe8ef9a07be1cd9bac4e1a1c66c667f71499 (diff)
downloadlwn-7003589dabcdfd10345ede31044ce5e13ee65e7f.tar.gz
lwn-7003589dabcdfd10345ede31044ce5e13ee65e7f.zip
bcachefs: Ensure buckets have io_time[READ] set
It's an error if a bucket is in state BCH_DATA_cached but not on the LRU btree - i.e io_time[READ] == 0 - so, make sure it's set before adding it. Also, make some of the LRU code a bit clearer and more direct. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/btree_gc.c')
-rw-r--r--fs/bcachefs/btree_gc.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c
index 0b1717120cc3..5199f0240fcd 100644
--- a/fs/bcachefs/btree_gc.c
+++ b/fs/bcachefs/btree_gc.c
@@ -1405,6 +1405,13 @@ static int bch2_alloc_write_key(struct btree_trans *trans,
a->v = new;
+ /*
+ * The trigger normally makes sure this is set, but we're not running
+ * triggers:
+ */
+ if (a->v.data_type == BCH_DATA_cached && !a->v.io_time[READ])
+ a->v.io_time[READ] = max_t(u64, 1, atomic64_read(&c->io_clock[READ].now));
+
ret = bch2_trans_update(trans, iter, &a->k_i, BTREE_TRIGGER_NORUN);
fsck_err:
return ret;