Commit 2f081584 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Improve the backpointer to missing extent message

We now print the pos where the backpointer was found in the btree, as
well as the exact bucket:bucket_offset of the data, to aid in grepping
through logs.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 40a18fe2
......@@ -298,11 +298,12 @@ int bch2_bucket_backpointer_mod_nowritebuffer(struct btree_trans *trans,
/*
* Find the next backpointer >= *bp_offset:
*/
int bch2_get_next_backpointer(struct btree_trans *trans,
struct bpos bucket, int gen,
u64 *bp_offset,
struct bch_backpointer *dst,
unsigned iter_flags)
int __bch2_get_next_backpointer(struct btree_trans *trans,
struct bpos bucket, int gen,
u64 *bp_offset,
struct bpos *bp_pos_ret,
struct bch_backpointer *dst,
unsigned iter_flags)
{
struct bch_fs *c = trans->c;
struct bpos bp_pos, bp_end_pos;
......@@ -352,6 +353,7 @@ int bch2_get_next_backpointer(struct btree_trans *trans,
*dst = *bkey_s_c_to_backpointer(k).v;
*bp_offset = dst->bucket_offset + BACKPOINTER_OFFSET_MAX;
*bp_pos_ret = k.k->p;
goto out;
}
done:
......@@ -362,6 +364,19 @@ int bch2_get_next_backpointer(struct btree_trans *trans,
return ret;
}
int bch2_get_next_backpointer(struct btree_trans *trans,
struct bpos bucket, int gen,
u64 *bp_offset,
struct bch_backpointer *dst,
unsigned iter_flags)
{
struct bpos bp_pos;
return __bch2_get_next_backpointer(trans, bucket, gen,
bp_offset, &bp_pos,
dst, iter_flags);
}
static void backpointer_not_found(struct btree_trans *trans,
struct bpos bucket,
u64 bp_offset,
......@@ -952,7 +967,7 @@ static int check_one_backpointer(struct btree_trans *trans,
struct printbuf buf = PRINTBUF;
int ret;
ret = bch2_get_next_backpointer(trans, bucket, -1, bp_offset, &bp, 0);
ret = __bch2_get_next_backpointer(trans, bucket, -1, bp_offset, &bp_pos, &bp, 0);
if (ret || *bp_offset == U64_MAX)
return ret;
......@@ -968,23 +983,17 @@ static int check_one_backpointer(struct btree_trans *trans,
if (ret)
return ret;
bp_pos = bucket_pos_to_bp(c, bucket,
max(*bp_offset, BACKPOINTER_OFFSET_MAX) - BACKPOINTER_OFFSET_MAX);
if (!k.k && !bpos_eq(*last_flushed_pos, bp_pos)) {
*last_flushed_pos = bp_pos;
pr_info("flushing at %llu:%llu",
last_flushed_pos->inode,
last_flushed_pos->offset);
ret = bch2_btree_write_buffer_flush_sync(trans) ?:
-BCH_ERR_transaction_restart_write_buffer_flush;
goto out;
}
if (fsck_err_on(!k.k, c,
"%s backpointer points to missing extent\n%s",
*bp_offset < BACKPOINTER_OFFSET_MAX ? "alloc" : "btree",
"backpointer for %llu:%llu:%llu (btree pos %llu:%llu) points to missing extent\n %s",
bucket.inode, bucket.offset, (u64) bp.bucket_offset,
bp_pos.inode, bp_pos.offset,
(bch2_backpointer_to_text(&buf, &bp), buf.buf))) {
ret = bch2_backpointer_del_by_offset(trans, bucket, *bp_offset, bp);
if (ret == -ENOENT)
......
......@@ -48,7 +48,7 @@ static inline struct bpos bucket_pos_to_bp(const struct bch_fs *c,
(bucket_to_sector(ca, bucket.offset) <<
MAX_EXTENT_COMPRESS_RATIO_SHIFT) + bucket_offset);
BUG_ON(!bkey_eq(bucket, bp_pos_to_bucket(c, ret)));
EBUG_ON(!bkey_eq(bucket, bp_pos_to_bucket(c, ret)));
return ret;
}
......
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