bcachefs: Make reconstruct_alloc quieter

We shouldn't be printing out fsck errors for expected errors - this
helps make test logs more readable, and makes it easier to see what the
actual failure was.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2023-03-19 14:29:51 -04:00
parent 3e36e572f1
commit 330970c2c6
2 changed files with 39 additions and 36 deletions

View File

@ -572,15 +572,15 @@ static int bch2_check_fix_ptrs(struct btree_trans *trans, enum btree_id btree_id
struct bucket *g = PTR_GC_BUCKET(ca, &p.ptr); struct bucket *g = PTR_GC_BUCKET(ca, &p.ptr);
enum bch_data_type data_type = bch2_bkey_ptr_data_type(*k, &entry->ptr); enum bch_data_type data_type = bch2_bkey_ptr_data_type(*k, &entry->ptr);
if (c->opts.reconstruct_alloc || if (!g->gen_valid &&
fsck_err_on(!g->gen_valid, c, (c->opts.reconstruct_alloc ||
"bucket %u:%zu data type %s ptr gen %u missing in alloc btree\n" fsck_err(c, "bucket %u:%zu data type %s ptr gen %u missing in alloc btree\n"
"while marking %s", "while marking %s",
p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr), p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr),
bch2_data_types[ptr_data_type(k->k, &p.ptr)], bch2_data_types[ptr_data_type(k->k, &p.ptr)],
p.ptr.gen, p.ptr.gen,
(printbuf_reset(&buf), (printbuf_reset(&buf),
bch2_bkey_val_to_text(&buf, c, *k), buf.buf))) { bch2_bkey_val_to_text(&buf, c, *k), buf.buf)))) {
if (!p.ptr.cached) { if (!p.ptr.cached) {
g->gen_valid = true; g->gen_valid = true;
g->gen = p.ptr.gen; g->gen = p.ptr.gen;
@ -589,14 +589,15 @@ static int bch2_check_fix_ptrs(struct btree_trans *trans, enum btree_id btree_id
} }
} }
if (fsck_err_on(gen_cmp(p.ptr.gen, g->gen) > 0, c, if (gen_cmp(p.ptr.gen, g->gen) > 0 &&
"bucket %u:%zu data type %s ptr gen in the future: %u > %u\n" (c->opts.reconstruct_alloc ||
"while marking %s", fsck_err(c, "bucket %u:%zu data type %s ptr gen in the future: %u > %u\n"
p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr), "while marking %s",
bch2_data_types[ptr_data_type(k->k, &p.ptr)], p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr),
p.ptr.gen, g->gen, bch2_data_types[ptr_data_type(k->k, &p.ptr)],
(printbuf_reset(&buf), p.ptr.gen, g->gen,
bch2_bkey_val_to_text(&buf, c, *k), buf.buf))) { (printbuf_reset(&buf),
bch2_bkey_val_to_text(&buf, c, *k), buf.buf)))) {
if (!p.ptr.cached) { if (!p.ptr.cached) {
g->gen_valid = true; g->gen_valid = true;
g->gen = p.ptr.gen; g->gen = p.ptr.gen;
@ -609,25 +610,26 @@ static int bch2_check_fix_ptrs(struct btree_trans *trans, enum btree_id btree_id
} }
} }
if (fsck_err_on(gen_cmp(g->gen, p.ptr.gen) > BUCKET_GC_GEN_MAX, c, if (gen_cmp(g->gen, p.ptr.gen) > BUCKET_GC_GEN_MAX &&
"bucket %u:%zu gen %u data type %s: ptr gen %u too stale\n" (c->opts.reconstruct_alloc ||
"while marking %s", fsck_err(c, "bucket %u:%zu gen %u data type %s: ptr gen %u too stale\n"
p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr), g->gen, "while marking %s",
bch2_data_types[ptr_data_type(k->k, &p.ptr)], p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr), g->gen,
p.ptr.gen, bch2_data_types[ptr_data_type(k->k, &p.ptr)],
(printbuf_reset(&buf), p.ptr.gen,
bch2_bkey_val_to_text(&buf, c, *k), buf.buf))) (printbuf_reset(&buf),
bch2_bkey_val_to_text(&buf, c, *k), buf.buf))))
do_update = true; do_update = true;
if (fsck_err_on(!p.ptr.cached && if (!p.ptr.cached && gen_cmp(p.ptr.gen, g->gen) < 0 &&
gen_cmp(p.ptr.gen, g->gen) < 0, c, (c->opts.reconstruct_alloc ||
"bucket %u:%zu data type %s stale dirty ptr: %u < %u\n" fsck_err(c, "bucket %u:%zu data type %s stale dirty ptr: %u < %u\n"
"while marking %s", "while marking %s",
p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr), p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr),
bch2_data_types[ptr_data_type(k->k, &p.ptr)], bch2_data_types[ptr_data_type(k->k, &p.ptr)],
p.ptr.gen, g->gen, p.ptr.gen, g->gen,
(printbuf_reset(&buf), (printbuf_reset(&buf),
bch2_bkey_val_to_text(&buf, c, *k), buf.buf))) bch2_bkey_val_to_text(&buf, c, *k), buf.buf))))
do_update = true; do_update = true;
if (data_type != BCH_DATA_btree && p.ptr.gen != g->gen) if (data_type != BCH_DATA_btree && p.ptr.gen != g->gen)
@ -757,7 +759,7 @@ static int bch2_check_fix_ptrs(struct btree_trans *trans, enum btree_id btree_id
if (level) if (level)
bch2_btree_node_update_key_early(trans, btree_id, level - 1, *k, new); bch2_btree_node_update_key_early(trans, btree_id, level - 1, *k, new);
if (c->opts.verbose) { if (0) {
printbuf_reset(&buf); printbuf_reset(&buf);
bch2_bkey_val_to_text(&buf, c, *k); bch2_bkey_val_to_text(&buf, c, *k);
bch_info(c, "updated %s", buf.buf); bch_info(c, "updated %s", buf.buf);

View File

@ -148,7 +148,8 @@ static int bch2_check_lru_key(struct btree_trans *trans,
goto out; goto out;
} }
if (fsck_err(c, "incorrect lru entry: lru %s time %llu\n" if (c->opts.reconstruct_alloc ||
fsck_err(c, "incorrect lru entry: lru %s time %llu\n"
" %s\n" " %s\n"
" for %s", " for %s",
bch2_lru_types[type], bch2_lru_types[type],