bcachefs: Fix spurious inconsistency in recovery

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2019-05-14 14:37:11 -04:00 committed by Kent Overstreet
parent ed8413fdab
commit 6fb076e60d
3 changed files with 11 additions and 3 deletions

View file

@ -232,7 +232,9 @@ int bch2_alloc_read(struct bch_fs *c, struct journal_keys *journal_keys)
bch2_trans_init(&trans, c);
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;
if (ret) {
@ -243,7 +245,9 @@ int bch2_alloc_read(struct bch_fs *c, struct journal_keys *journal_keys)
for_each_journal_key(*journal_keys, j)
if (j->btree_id == BTREE_ID_ALLOC)
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);
bch2_dev_usage_from_buckets(c);

View file

@ -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);
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.data_type = u.data_type;
m.dirty_sectors = u.dirty_sectors;
@ -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[WRITE] = u.write_time;
g->oldest_gen = u.oldest_gen;

View file

@ -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_NOATOMIC (1 << 1)
#define BCH_BUCKET_MARK_ALLOC_READ (1 << 2)
int bch2_mark_key_locked(struct bch_fs *, struct bkey_s_c,
bool, s64, struct bch_fs_usage *,