diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-03-13 17:09:26 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2022-03-13 17:09:45 -0400 |
commit | df32eb66cfc74e9579517f8c9926aa3ebccac517 (patch) | |
tree | 96957ee648c2c8f635af121c829e940d6e40563e | |
parent | 3eb5d8738b1dabce2109cbffb8e4f4965c212d44 (diff) |
bcachefs: Repair code for read_time=0new_allocator
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r-- | fs/bcachefs/alloc_background.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index a9150238d2d1..0c33424393be 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -588,6 +588,22 @@ static int bch2_check_alloc_key(struct btree_trans *trans, } if (bucket_state(a) == BUCKET_cached) { + if (fsck_err_on(!a.read_time, c, + "cached bucket with read_time 0\n" + " %s", + (printbuf_reset(&buf), + bch2_bkey_val_to_text(&buf, c, alloc_k), buf.buf))) { + + a.read_time = atomic64_read(&c->io_clock[READ].now); + + ret = bch2_lru_change(trans, a.dev, a.bucket, + 0, &a.read_time) ?: + bch2_alloc_write(trans, alloc_iter, &a, BTREE_TRIGGER_NORUN); + bch2_trans_commit(trans, NULL, NULL, 0); + if (ret) + goto err; + } + k = bch2_btree_iter_peek_slot(&lru_iter); ret = bkey_err(k); if (ret) |