summaryrefslogtreecommitdiff
path: root/fs/bcachefs/alloc_background.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/alloc_background.c
parent84befe8ef9a07be1cd9bac4e1a1c66c667f71499 (diff)
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/alloc_background.c')
-rw-r--r--fs/bcachefs/alloc_background.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c
index 3be6f0fa89de..17b147d15320 100644
--- a/fs/bcachefs/alloc_background.c
+++ b/fs/bcachefs/alloc_background.c
@@ -583,6 +583,11 @@ int bch2_trans_mark_alloc(struct btree_trans *trans,
return ret;
}
+ if (new_a->data_type == BCH_DATA_cached &&
+ !new_a->io_time[READ])
+ new_a->io_time[READ] = max_t(u64, 1, atomic64_read(&c->io_clock[READ].now));
+
+
old_lru = alloc_lru_idx(old_a);
new_lru = alloc_lru_idx(*new_a);
@@ -592,7 +597,7 @@ int bch2_trans_mark_alloc(struct btree_trans *trans,
if (ret)
return ret;
- if (new_lru && new_a->io_time[READ] != new_lru)
+ if (new_a->data_type == BCH_DATA_cached)
new_a->io_time[READ] = new_lru;
}
@@ -869,10 +874,10 @@ static int bch2_check_alloc_to_lru_ref(struct btree_trans *trans,
if (!a.io_time[READ])
a.io_time[READ] = atomic64_read(&c->io_clock[READ].now);
- ret = bch2_lru_change(trans,
- alloc_k.k->p.inode,
- alloc_k.k->p.offset,
- 0, &a.io_time[READ]);
+ ret = bch2_lru_set(trans,
+ alloc_k.k->p.inode,
+ alloc_k.k->p.offset,
+ &a.io_time[READ]);
if (ret)
goto err;