Update bcachefs sources to a059319fee bcachefs: Put some repair messages behind opts->verbose

This commit is contained in:
Kent Overstreet 2022-07-11 23:07:34 -04:00
parent a29cb4b9f8
commit dce1de5426
6 changed files with 62 additions and 52 deletions

View File

@ -1 +1 @@
95ff72a6c1291f6838e5cfa81a7426aaff482cde a059319fee8038f4e7fc9cf92595341f3d5d7a79

View File

@ -731,12 +731,13 @@ static int bch2_check_alloc_key(struct btree_trans *trans,
if (ret) if (ret)
goto err; goto err;
if (fsck_err_on(k.k->type != discard_key_type, c, if (k.k->type != discard_key_type &&
"incorrect key in need_discard btree (got %s should be %s)\n" (c->opts.reconstruct_alloc ||
fsck_err(c, "incorrect key in need_discard btree (got %s should be %s)\n"
" %s", " %s",
bch2_bkey_types[k.k->type], bch2_bkey_types[k.k->type],
bch2_bkey_types[discard_key_type], bch2_bkey_types[discard_key_type],
(bch2_bkey_val_to_text(&buf, c, alloc_k), buf.buf))) { (bch2_bkey_val_to_text(&buf, c, alloc_k), buf.buf)))) {
struct bkey_i *update = struct bkey_i *update =
bch2_trans_kmalloc(trans, sizeof(*update)); bch2_trans_kmalloc(trans, sizeof(*update));
@ -758,13 +759,14 @@ static int bch2_check_alloc_key(struct btree_trans *trans,
if (ret) if (ret)
goto err; goto err;
if (fsck_err_on(k.k->type != freespace_key_type, c, if (k.k->type != freespace_key_type &&
"incorrect key in freespace btree (got %s should be %s)\n" (c->opts.reconstruct_alloc ||
fsck_err(c, "incorrect key in freespace btree (got %s should be %s)\n"
" %s", " %s",
bch2_bkey_types[k.k->type], bch2_bkey_types[k.k->type],
bch2_bkey_types[freespace_key_type], bch2_bkey_types[freespace_key_type],
(printbuf_reset(&buf), (printbuf_reset(&buf),
bch2_bkey_val_to_text(&buf, c, alloc_k), buf.buf))) { bch2_bkey_val_to_text(&buf, c, alloc_k), buf.buf)))) {
struct bkey_i *update = struct bkey_i *update =
bch2_trans_kmalloc(trans, sizeof(*update)); bch2_trans_kmalloc(trans, sizeof(*update));

View File

@ -700,6 +700,7 @@ missing:
bch2_bkey_val_to_text(&buf, c, alloc_k); bch2_bkey_val_to_text(&buf, c, alloc_k);
if (c->sb.version < bcachefs_metadata_version_backpointers || if (c->sb.version < bcachefs_metadata_version_backpointers ||
c->opts.reconstruct_alloc ||
fsck_err(c, "%s", buf.buf)) { fsck_err(c, "%s", buf.buf)) {
struct bkey_i_alloc_v4 *a = bch2_alloc_to_v4_mut(trans, alloc_k); struct bkey_i_alloc_v4 *a = bch2_alloc_to_v4_mut(trans, alloc_k);

View File

@ -564,7 +564,8 @@ static int bch2_check_fix_ptrs(struct bch_fs *c, 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 (fsck_err_on(!g->gen_valid, c, if (c->opts.reconstruct_alloc ||
fsck_err_on(!g->gen_valid, c,
"bucket %u:%zu data type %s ptr gen %u missing in alloc btree\n" "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),
@ -748,6 +749,7 @@ found:
if (level) if (level)
bch2_btree_node_update_key_early(c, btree_id, level - 1, *k, new); bch2_btree_node_update_key_early(c, btree_id, level - 1, *k, new);
if (c->opts.verbose) {
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);
@ -755,6 +757,7 @@ found:
printbuf_reset(&buf); printbuf_reset(&buf);
bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(new)); bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(new));
bch_info(c, "new key %s", buf.buf); bch_info(c, "new key %s", buf.buf);
}
*k = bkey_i_to_s_c(new); *k = bkey_i_to_s_c(new);
} }
@ -1177,29 +1180,28 @@ static int bch2_gc_done(struct bch_fs *c,
{ {
struct bch_dev *ca = NULL; struct bch_dev *ca = NULL;
struct printbuf buf = PRINTBUF; struct printbuf buf = PRINTBUF;
bool verify = !metadata_only && (!initial || bool verify = !metadata_only &&
(c->sb.compat & (1ULL << BCH_COMPAT_alloc_info))); !c->opts.reconstruct_alloc &&
(!initial || (c->sb.compat & (1ULL << BCH_COMPAT_alloc_info)));
unsigned i, dev; unsigned i, dev;
int ret = 0; int ret = 0;
percpu_down_write(&c->mark_lock); percpu_down_write(&c->mark_lock);
#define copy_field(_f, _msg, ...) \ #define copy_field(_f, _msg, ...) \
if (dst->_f != src->_f) { \ if (dst->_f != src->_f && \
if (verify) \ (!verify || \
fsck_err(c, _msg ": got %llu, should be %llu" \ fsck_err(c, _msg ": got %llu, should be %llu" \
, ##__VA_ARGS__, dst->_f, src->_f); \ , ##__VA_ARGS__, dst->_f, src->_f))) \
dst->_f = src->_f; \ dst->_f = src->_f
}
#define copy_stripe_field(_f, _msg, ...) \ #define copy_stripe_field(_f, _msg, ...) \
if (dst->_f != src->_f) { \ if (dst->_f != src->_f && \
if (verify) \ (!verify || \
fsck_err(c, "stripe %zu has wrong "_msg \ fsck_err(c, "stripe %zu has wrong "_msg \
": got %u, should be %u", \ ": got %u, should be %u", \
iter.pos, ##__VA_ARGS__, \ iter.pos, ##__VA_ARGS__, \
dst->_f, src->_f); \ dst->_f, src->_f))) \
dst->_f = src->_f; \ dst->_f = src->_f
}
#define copy_dev_field(_f, _msg, ...) \ #define copy_dev_field(_f, _msg, ...) \
copy_field(_f, "dev %u has wrong " _msg, dev, ##__VA_ARGS__) copy_field(_f, "dev %u has wrong " _msg, dev, ##__VA_ARGS__)
#define copy_fs_field(_f, _msg, ...) \ #define copy_fs_field(_f, _msg, ...) \
@ -1377,7 +1379,8 @@ static int bch2_alloc_write_key(struct btree_trans *trans,
return 0; return 0;
#define copy_bucket_field(_f) \ #define copy_bucket_field(_f) \
if (fsck_err_on(new._f != gc._f, c, \ if (c->opts.reconstruct_alloc || \
fsck_err_on(new._f != gc._f, c, \
"bucket %llu:%llu gen %u data type %s has wrong " #_f \ "bucket %llu:%llu gen %u data type %s has wrong " #_f \
": got %u, should be %u", \ ": got %u, should be %u", \
iter->pos.inode, iter->pos.offset, \ iter->pos.inode, iter->pos.offset, \

View File

@ -193,6 +193,8 @@ bool __bch2_btree_node_relock(struct btree_trans *trans,
return true; return true;
} }
fail: fail:
if (b != BTREE_ITER_NO_NODE_CACHED &&
b != BTREE_ITER_NO_NODE_INIT)
trace_btree_node_relock_fail(trans->fn, _RET_IP_, trace_btree_node_relock_fail(trans->fn, _RET_IP_,
path->btree_id, path->btree_id,
&path->pos, &path->pos,
@ -363,7 +365,6 @@ bool __bch2_btree_node_lock(struct btree_trans *trans,
if (btree_node_locked(linked, level) && if (btree_node_locked(linked, level) &&
bpos_cmp(pos, btree_node_pos((void *) linked->l[level].b, bpos_cmp(pos, btree_node_pos((void *) linked->l[level].b,
linked->cached)) <= 0) { linked->cached)) <= 0) {
BUG_ON(trans->in_traverse_all);
reason = 7; reason = 7;
goto deadlock; goto deadlock;
} }

View File

@ -148,13 +148,15 @@ void bch2_moving_ctxt_exit(struct moving_context *ctxt)
{ {
move_ctxt_wait_event(ctxt, NULL, list_empty(&ctxt->reads)); move_ctxt_wait_event(ctxt, NULL, list_empty(&ctxt->reads));
closure_sync(&ctxt->cl); closure_sync(&ctxt->cl);
progress_list_del(ctxt->c, ctxt->stats);
EBUG_ON(atomic_read(&ctxt->write_sectors)); EBUG_ON(atomic_read(&ctxt->write_sectors));
if (ctxt->stats) {
progress_list_del(ctxt->c, ctxt->stats);
trace_move_data(ctxt->c, trace_move_data(ctxt->c,
atomic64_read(&ctxt->stats->sectors_moved), atomic64_read(&ctxt->stats->sectors_moved),
atomic64_read(&ctxt->stats->keys_moved)); atomic64_read(&ctxt->stats->keys_moved));
}
} }
void bch2_moving_ctxt_init(struct moving_context *ctxt, void bch2_moving_ctxt_init(struct moving_context *ctxt,
@ -172,13 +174,14 @@ void bch2_moving_ctxt_init(struct moving_context *ctxt,
ctxt->wp = wp; ctxt->wp = wp;
ctxt->wait_on_copygc = wait_on_copygc; ctxt->wait_on_copygc = wait_on_copygc;
progress_list_add(c, stats);
closure_init_stack(&ctxt->cl); closure_init_stack(&ctxt->cl);
INIT_LIST_HEAD(&ctxt->reads); INIT_LIST_HEAD(&ctxt->reads);
init_waitqueue_head(&ctxt->wait); init_waitqueue_head(&ctxt->wait);
if (stats) if (stats) {
progress_list_add(c, stats);
stats->data_type = BCH_DATA_user; stats->data_type = BCH_DATA_user;
}
} }
void bch_move_stats_init(struct bch_move_stats *stats, char *name) void bch_move_stats_init(struct bch_move_stats *stats, char *name)