Commit 18c9883e authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: fix bch2_invalidate_one_bucket2() during journal replay

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 61f321fc
...@@ -939,7 +939,7 @@ static int bch2_invalidate_one_bucket2(struct bch_fs *c, struct bch_dev *ca, ...@@ -939,7 +939,7 @@ static int bch2_invalidate_one_bucket2(struct bch_fs *c, struct bch_dev *ca,
else else
memset(&u, 0, sizeof(u)); memset(&u, 0, sizeof(u));
invalidating_cached_data = u.cached_sectors != 0; invalidating_cached_data = m.cached_sectors != 0;
//BUG_ON(u.dirty_sectors); //BUG_ON(u.dirty_sectors);
u.data_type = 0; u.data_type = 0;
...@@ -947,7 +947,13 @@ static int bch2_invalidate_one_bucket2(struct bch_fs *c, struct bch_dev *ca, ...@@ -947,7 +947,13 @@ static int bch2_invalidate_one_bucket2(struct bch_fs *c, struct bch_dev *ca,
u.cached_sectors = 0; u.cached_sectors = 0;
u.read_time = c->bucket_clock[READ].hand; u.read_time = c->bucket_clock[READ].hand;
u.write_time = c->bucket_clock[WRITE].hand; u.write_time = c->bucket_clock[WRITE].hand;
u.gen++;
/*
* The allocator has to start before journal replay is finished - thus,
* we have to trust the in memory bucket @m, not the version in the
* btree:
*/
u.gen = m.gen + 1;
a = bkey_alloc_init(&alloc_key.k); a = bkey_alloc_init(&alloc_key.k);
a->k.p = iter->pos; a->k.p = iter->pos;
...@@ -963,6 +969,7 @@ static int bch2_invalidate_one_bucket2(struct bch_fs *c, struct bch_dev *ca, ...@@ -963,6 +969,7 @@ static int bch2_invalidate_one_bucket2(struct bch_fs *c, struct bch_dev *ca,
ret = bch2_btree_insert_at(c, NULL, ret = bch2_btree_insert_at(c, NULL,
invalidating_cached_data ? journal_seq : NULL, invalidating_cached_data ? journal_seq : NULL,
BTREE_INSERT_ATOMIC| BTREE_INSERT_ATOMIC|
BTREE_INSERT_NOUNLOCK|
BTREE_INSERT_NOCHECK_RW| BTREE_INSERT_NOCHECK_RW|
BTREE_INSERT_NOFAIL| BTREE_INSERT_NOFAIL|
BTREE_INSERT_USE_RESERVE| BTREE_INSERT_USE_RESERVE|
...@@ -982,6 +989,10 @@ static int bch2_invalidate_one_bucket2(struct bch_fs *c, struct bch_dev *ca, ...@@ -982,6 +989,10 @@ static int bch2_invalidate_one_bucket2(struct bch_fs *c, struct bch_dev *ca,
if (!top->nr) if (!top->nr)
heap_pop(&ca->alloc_heap, e, bucket_alloc_cmp, NULL); heap_pop(&ca->alloc_heap, e, bucket_alloc_cmp, NULL);
/* with btree still locked: */
if (ca->buckets_written)
set_bit(b, ca->buckets_written);
/* /*
* Make sure we flush the last journal entry that updated this * Make sure we flush the last journal entry that updated this
* bucket (i.e. deleting the last reference) before writing to * bucket (i.e. deleting the last reference) before writing to
......
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