bcachefs: Improve an error message

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2020-02-26 20:39:06 -05:00 committed by Kent Overstreet
parent b807a0c8ba
commit f1f5f114cd

View file

@ -708,15 +708,15 @@ static int validate_bset(struct bch_fs *c, struct btree *b,
unsigned *whiteout_u64s, int write, unsigned *whiteout_u64s, int write,
bool have_retry) bool have_retry)
{ {
struct bkey_packed *k, *prev = NULL; struct bkey_packed *k;
struct bpos prev_pos = POS_MIN; struct bkey prev = KEY(0, 0, 0);
struct bpos prev_data = POS_MIN; struct bpos prev_data = POS_MIN;
bool seen_non_whiteout = false; bool seen_non_whiteout = false;
unsigned version; unsigned version;
const char *err; const char *err;
int ret = 0; int ret = 0;
if (i == &b->data->keys) { if (!b->written) {
/* These indicate that we read the wrong btree node: */ /* These indicate that we read the wrong btree node: */
btree_err_on(BTREE_NODE_ID(b->data) != b->c.btree_id, btree_err_on(BTREE_NODE_ID(b->data) != b->c.btree_id,
BTREE_ERR_MUST_RETRY, c, b, i, BTREE_ERR_MUST_RETRY, c, b, i,
@ -852,25 +852,28 @@ static int validate_bset(struct bch_fs *c, struct btree *b,
if (!seen_non_whiteout && if (!seen_non_whiteout &&
(!bkey_whiteout(k) || (!bkey_whiteout(k) ||
(bkey_cmp(prev_pos, bkey_start_pos(u.k)) > 0))) { (bkey_cmp(prev.p, bkey_start_pos(u.k)) > 0))) {
*whiteout_u64s = k->_data - i->_data; *whiteout_u64s = k->_data - i->_data;
seen_non_whiteout = true; seen_non_whiteout = true;
} else if (bkey_cmp(prev_data, bkey_start_pos(u.k)) > 0 || } else if (bkey_cmp(prev_data, bkey_start_pos(u.k)) > 0 ||
bkey_cmp(prev_pos, u.k->p) > 0) { bkey_cmp(prev.p, u.k->p) > 0) {
char buf1[80];
char buf2[80];
bch2_bkey_to_text(&PBUF(buf1), &prev);
bch2_bkey_to_text(&PBUF(buf2), u.k);
bch2_dump_bset(b, i, 0);
btree_err(BTREE_ERR_FATAL, c, b, i, btree_err(BTREE_ERR_FATAL, c, b, i,
"keys out of order: %llu:%llu > %llu:%llu", "keys out of order: %s > %s",
prev_pos.inode, buf1, buf2);
prev_pos.offset,
u.k->p.inode,
bkey_start_offset(u.k));
/* XXX: repair this */ /* XXX: repair this */
} }
if (!bkey_deleted(u.k)) if (!bkey_deleted(u.k))
prev_data = u.k->p; prev_data = u.k->p;
prev_pos = u.k->p; prev = *u.k;
prev = k;
k = bkey_next_skip_noops(k, vstruct_last(i)); k = bkey_next_skip_noops(k, vstruct_last(i));
} }