Commit d57c9add authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Improve error message for stripe block sector counts wrong

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 9d32097f
...@@ -1687,6 +1687,7 @@ static int bch2_gc_write_stripes_key(struct btree_trans *trans, ...@@ -1687,6 +1687,7 @@ static int bch2_gc_write_stripes_key(struct btree_trans *trans,
struct printbuf buf = PRINTBUF; struct printbuf buf = PRINTBUF;
const struct bch_stripe *s; const struct bch_stripe *s;
struct gc_stripe *m; struct gc_stripe *m;
bool bad = false;
unsigned i; unsigned i;
int ret = 0; int ret = 0;
...@@ -1696,19 +1697,21 @@ static int bch2_gc_write_stripes_key(struct btree_trans *trans, ...@@ -1696,19 +1697,21 @@ static int bch2_gc_write_stripes_key(struct btree_trans *trans,
s = bkey_s_c_to_stripe(k).v; s = bkey_s_c_to_stripe(k).v;
m = genradix_ptr(&c->gc_stripes, k.k->p.offset); m = genradix_ptr(&c->gc_stripes, k.k->p.offset);
for (i = 0; i < s->nr_blocks; i++) for (i = 0; i < s->nr_blocks; i++) {
if (stripe_blockcount_get(s, i) != (m ? m->block_sectors[i] : 0)) u32 old = stripe_blockcount_get(s, i);
goto inconsistent; u32 new = (m ? m->block_sectors[i] : 0);
return 0;
inconsistent: if (old != new) {
if (fsck_err_on(true, c, prt_printf(&buf, "stripe block %u has wrong sector count: got %u, should be %u\n",
"stripe block %u has wrong sector count:\n" i, old, new);
" %s\n" bad = true;
" got %u, should be %u", i, }
(printbuf_reset(&buf), }
bch2_bkey_val_to_text(&buf, c, k), buf.buf),
stripe_blockcount_get(s, i), if (bad)
m ? m->block_sectors[i] : 0)) { bch2_bkey_val_to_text(&buf, c, k);
if (fsck_err_on(bad, c, "%s", buf.buf)) {
struct bkey_i_stripe *new; struct bkey_i_stripe *new;
new = bch2_trans_kmalloc(trans, bkey_bytes(k.k)); new = bch2_trans_kmalloc(trans, bkey_bytes(k.k));
......
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