From 7003589dabcdfd10345ede31044ce5e13ee65e7f Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sun, 10 Apr 2022 19:59:26 -0400 Subject: 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 --- fs/bcachefs/lru.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'fs/bcachefs/lru.c') diff --git a/fs/bcachefs/lru.c b/fs/bcachefs/lru.c index d8180bc1c6b1..49a0f0d69664 100644 --- a/fs/bcachefs/lru.c +++ b/fs/bcachefs/lru.c @@ -30,7 +30,7 @@ void bch2_lru_to_text(struct printbuf *out, struct bch_fs *c, pr_buf(out, "idx %llu", le64_to_cpu(lru->idx)); } -static int lru_delete(struct btree_trans *trans, u64 id, u64 idx, u64 time) +int bch2_lru_delete(struct btree_trans *trans, u64 id, u64 idx, u64 time) { struct btree_iter iter; struct bkey_s_c k; @@ -72,7 +72,7 @@ err: return ret; } -static int lru_set(struct btree_trans *trans, u64 lru_id, u64 idx, u64 *time) +int bch2_lru_set(struct btree_trans *trans, u64 lru_id, u64 idx, u64 *time) { struct btree_iter iter; struct bkey_s_c k; @@ -119,8 +119,8 @@ int bch2_lru_change(struct btree_trans *trans, u64 id, u64 idx, if (old_time == *new_time) return 0; - return lru_delete(trans, id, idx, old_time) ?: - lru_set(trans, id, idx, new_time); + return bch2_lru_delete(trans, id, idx, old_time) ?: + bch2_lru_set(trans, id, idx, new_time); } static int bch2_check_lru_key(struct btree_trans *trans, -- cgit