diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-06-25 05:22:20 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 23:10:05 +0200 |
commit | 454377d8432fdfaa5ebfca05a9bfa3af311d5b9a (patch) | |
tree | 571655c4ee6074b6dc7d743471a2ce32ca309a39 /fs/bcachefs/fsck.c | |
parent | bcachefs: Fix check_pos_snapshot_overwritten() (diff) | |
download | linux-454377d8432fdfaa5ebfca05a9bfa3af311d5b9a.tar.xz linux-454377d8432fdfaa5ebfca05a9bfa3af311d5b9a.zip |
bcachefs: Improve error message for overlapping extents
We now print out the full previous extent we overlapping with, to aid in
debugging and searching through the journal.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/fsck.c')
-rw-r--r-- | fs/bcachefs/fsck.c | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index 194e8d474e86..40804012a990 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -1143,6 +1143,25 @@ struct extent_end { typedef DARRAY(struct extent_end) extent_ends; +static int get_print_extent(struct btree_trans *trans, struct bpos pos, struct printbuf *out) +{ + struct btree_iter iter; + struct bkey_s_c k; + int ret; + + k = bch2_bkey_get_iter(trans, &iter, BTREE_ID_extents, pos, + BTREE_ITER_SLOTS| + BTREE_ITER_ALL_SNAPSHOTS| + BTREE_ITER_NOT_EXTENTS); + ret = bkey_err(k); + if (ret) + return ret; + + bch2_bkey_val_to_text(out, trans->c, k); + bch2_trans_iter_exit(trans, &iter); + return 0; +} + static int check_overlapping_extents(struct btree_trans *trans, struct snapshots_seen *seen, extent_ends *extent_ends, @@ -1165,12 +1184,19 @@ static int check_overlapping_extents(struct btree_trans *trans, i->snapshot, &i->seen)) continue; - if (fsck_err_on(i->offset > bkey_start_offset(k.k), c, - "overlapping extents: extent in snapshot %u ends at %llu overlaps with\n%s", - i->snapshot, - i->offset, - (printbuf_reset(&buf), - bch2_bkey_val_to_text(&buf, c, k), buf.buf))) { + if (i->offset <= bkey_start_offset(k.k)) + continue; + + printbuf_reset(&buf); + prt_str(&buf, "overlapping extents:\n "); + bch2_bkey_val_to_text(&buf, c, k); + prt_str(&buf, "\n "); + + ret = get_print_extent(trans, SPOS(k.k->p.inode, i->offset, i->snapshot), &buf); + if (ret) + break; + + if (fsck_err(c, buf.buf)) { struct bkey_i *update = bch2_trans_kmalloc(trans, bkey_bytes(k.k)); if ((ret = PTR_ERR_OR_ZERO(update))) goto err; |