Commit a39c74be authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix gc updating stripes info

The primary stripes radix tree can be sparse, which was causing an
assertion to pop because the one use for gc isn't. Fix this by changing
the algorithm to copy between the two radix trees.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 2ef220cb
...@@ -580,7 +580,7 @@ static int bch2_gc_done(struct bch_fs *c, ...@@ -580,7 +580,7 @@ static int bch2_gc_done(struct bch_fs *c,
if (verify) \ if (verify) \
fsck_err(c, "stripe %zu has wrong "_msg \ fsck_err(c, "stripe %zu has wrong "_msg \
": got %u, should be %u", \ ": got %u, should be %u", \
dst_iter.pos, ##__VA_ARGS__, \ iter.pos, ##__VA_ARGS__, \
dst->_f, src->_f); \ dst->_f, src->_f); \
dst->_f = src->_f; \ dst->_f = src->_f; \
dst->dirty = true; \ dst->dirty = true; \
...@@ -603,13 +603,11 @@ static int bch2_gc_done(struct bch_fs *c, ...@@ -603,13 +603,11 @@ static int bch2_gc_done(struct bch_fs *c,
copy_field(_f, "fs has wrong " _msg, ##__VA_ARGS__) copy_field(_f, "fs has wrong " _msg, ##__VA_ARGS__)
if (!metadata_only) { if (!metadata_only) {
struct genradix_iter dst_iter = genradix_iter_init(&c->stripes[0], 0); struct genradix_iter iter = genradix_iter_init(&c->stripes[1], 0);
struct genradix_iter src_iter = genradix_iter_init(&c->stripes[1], 0);
struct stripe *dst, *src; struct stripe *dst, *src;
while ((dst = genradix_iter_peek(&dst_iter, &c->stripes[0])) && while ((src = genradix_iter_peek(&iter, &c->stripes[1]))) {
(src = genradix_iter_peek(&src_iter, &c->stripes[1]))) { dst = genradix_ptr_alloc(&c->stripes[0], iter.pos, GFP_KERNEL);
BUG_ON(src_iter.pos != dst_iter.pos);
copy_stripe_field(alive, "alive"); copy_stripe_field(alive, "alive");
copy_stripe_field(sectors, "sectors"); copy_stripe_field(sectors, "sectors");
...@@ -623,8 +621,7 @@ static int bch2_gc_done(struct bch_fs *c, ...@@ -623,8 +621,7 @@ static int bch2_gc_done(struct bch_fs *c,
copy_stripe_field(block_sectors[i], copy_stripe_field(block_sectors[i],
"block_sectors[%u]", i); "block_sectors[%u]", i);
genradix_iter_advance(&dst_iter, &c->stripes[0]); genradix_iter_advance(&iter, &c->stripes[1]);
genradix_iter_advance(&src_iter, &c->stripes[1]);
} }
} }
......
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