Commit 6fb076e6 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix spurious inconsistency in recovery

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent ed8413fd
...@@ -232,7 +232,9 @@ int bch2_alloc_read(struct bch_fs *c, struct journal_keys *journal_keys) ...@@ -232,7 +232,9 @@ int bch2_alloc_read(struct bch_fs *c, struct journal_keys *journal_keys)
bch2_trans_init(&trans, c); bch2_trans_init(&trans, c);
for_each_btree_key(&trans, iter, BTREE_ID_ALLOC, POS_MIN, 0, k, ret) for_each_btree_key(&trans, iter, BTREE_ID_ALLOC, POS_MIN, 0, k, ret)
bch2_mark_key(c, k, true, 0, NULL, 0, 0); bch2_mark_key(c, k, true, 0, NULL, 0,
BCH_BUCKET_MARK_NOATOMIC|
BCH_BUCKET_MARK_ALLOC_READ);
ret = bch2_trans_exit(&trans) ?: ret; ret = bch2_trans_exit(&trans) ?: ret;
if (ret) { if (ret) {
...@@ -243,7 +245,9 @@ int bch2_alloc_read(struct bch_fs *c, struct journal_keys *journal_keys) ...@@ -243,7 +245,9 @@ int bch2_alloc_read(struct bch_fs *c, struct journal_keys *journal_keys)
for_each_journal_key(*journal_keys, j) for_each_journal_key(*journal_keys, j)
if (j->btree_id == BTREE_ID_ALLOC) if (j->btree_id == BTREE_ID_ALLOC)
bch2_mark_key(c, bkey_i_to_s_c(j->k), bch2_mark_key(c, bkey_i_to_s_c(j->k),
true, 0, NULL, 0, 0); true, 0, NULL, 0,
BCH_BUCKET_MARK_NOATOMIC|
BCH_BUCKET_MARK_ALLOC_READ);
percpu_down_write(&c->mark_lock); percpu_down_write(&c->mark_lock);
bch2_dev_usage_from_buckets(c); bch2_dev_usage_from_buckets(c);
......
...@@ -657,7 +657,7 @@ static int bch2_mark_alloc(struct bch_fs *c, struct bkey_s_c k, ...@@ -657,7 +657,7 @@ static int bch2_mark_alloc(struct bch_fs *c, struct bkey_s_c k,
g = __bucket(ca, k.k->p.offset, gc); g = __bucket(ca, k.k->p.offset, gc);
u = bch2_alloc_unpack(k); u = bch2_alloc_unpack(k);
old = bucket_data_cmpxchg(c, ca, fs_usage, g, m, ({ old = bucket_cmpxchg(g, m, ({
m.gen = u.gen; m.gen = u.gen;
m.data_type = u.data_type; m.data_type = u.data_type;
m.dirty_sectors = u.dirty_sectors; m.dirty_sectors = u.dirty_sectors;
...@@ -669,6 +669,9 @@ static int bch2_mark_alloc(struct bch_fs *c, struct bkey_s_c k, ...@@ -669,6 +669,9 @@ static int bch2_mark_alloc(struct bch_fs *c, struct bkey_s_c k,
} }
})); }));
if (!(flags & BCH_BUCKET_MARK_ALLOC_READ))
bch2_dev_usage_update(c, ca, fs_usage, old, m, gc);
g->io_time[READ] = u.read_time; g->io_time[READ] = u.read_time;
g->io_time[WRITE] = u.write_time; g->io_time[WRITE] = u.write_time;
g->oldest_gen = u.oldest_gen; g->oldest_gen = u.oldest_gen;
......
...@@ -251,6 +251,7 @@ void bch2_mark_metadata_bucket(struct bch_fs *, struct bch_dev *, ...@@ -251,6 +251,7 @@ void bch2_mark_metadata_bucket(struct bch_fs *, struct bch_dev *,
#define BCH_BUCKET_MARK_GC (1 << 0) #define BCH_BUCKET_MARK_GC (1 << 0)
#define BCH_BUCKET_MARK_NOATOMIC (1 << 1) #define BCH_BUCKET_MARK_NOATOMIC (1 << 1)
#define BCH_BUCKET_MARK_ALLOC_READ (1 << 2)
int bch2_mark_key_locked(struct bch_fs *, struct bkey_s_c, int bch2_mark_key_locked(struct bch_fs *, struct bkey_s_c,
bool, s64, struct bch_fs_usage *, bool, s64, struct bch_fs_usage *,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment