Commit 1ece5323 authored by Kent Overstreet's avatar Kent Overstreet
Browse files

bcachefs: Consistent indentation of multiline fsck errors



Add the new helper printbuf_indent_add_nextline(), and use it in
__bch2_fsck_err() to centralize setting the indentation of multiline
fsck errors.

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent a7cdf227
Loading
Loading
Loading
Loading
+8 −11
Original line number Diff line number Diff line
@@ -676,8 +676,7 @@ static int __need_discard_or_freespace_err(struct btree_trans *trans,
	bch2_bkey_val_to_text(&buf, c, alloc_k);

	int ret = __bch2_fsck_err(NULL, trans, flags, err_id,
				  "bucket incorrectly %sset in %s btree\n"
				  "  %s",
				  "bucket incorrectly %sset in %s btree\n%s",
				  set ? "" : "un",
				  bch2_btree_id_str(btree),
				  buf.buf);
@@ -1204,8 +1203,7 @@ int bch2_check_alloc_key(struct btree_trans *trans,

	if (fsck_err_on(a->gen != alloc_gen(k, gens_offset),
			trans, bucket_gens_key_wrong,
			"incorrect gen in bucket_gens btree (got %u should be %u)\n"
			"  %s",
			"incorrect gen in bucket_gens btree (got %u should be %u)\n%s",
			alloc_gen(k, gens_offset), a->gen,
			(printbuf_reset(&buf),
			 bch2_bkey_val_to_text(&buf, c, alloc_k), buf.buf))) {
@@ -1715,8 +1713,7 @@ static int bch2_check_alloc_to_lru_ref(struct btree_trans *trans,

	if (fsck_err_on(!a->io_time[READ],
			trans, alloc_key_cached_but_read_time_zero,
			"cached bucket with read_time 0\n"
			"  %s",
			"cached bucket with read_time 0\n%s",
		(printbuf_reset(&buf),
		 bch2_bkey_val_to_text(&buf, c, alloc_k), buf.buf))) {
		struct bkey_i_alloc_v4 *a_mut =
+12 −13
Original line number Diff line number Diff line
@@ -214,7 +214,7 @@ static int backpointer_target_not_found(struct btree_trans *trans,
		   bp.v->level ? "btree node" : "extent");
	bch2_bkey_val_to_text(&buf, c, bp.s_c);

	prt_printf(&buf, "\n  ");
	prt_newline(&buf);
	bch2_bkey_val_to_text(&buf, c, target_k);

	struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(target_k);
@@ -222,7 +222,7 @@ static int backpointer_target_not_found(struct btree_trans *trans,
	struct extent_ptr_decoded p;
	bkey_for_each_ptr_decode(target_k.k, ptrs, p, entry)
		if (p.ptr.dev == bp.k->p.inode) {
			prt_printf(&buf, "\n  ");
			prt_newline(&buf);
			struct bkey_i_backpointer bp2;
			bch2_extent_ptr_to_bp(c, bp.v->btree_id, bp.v->level, target_k, p, entry, &bp2);
			bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(&bp2.k_i));
@@ -443,12 +443,11 @@ static int check_extent_checksum(struct btree_trans *trans,
	if (ret)
		goto err;

	prt_str(&buf, "extents pointing to same space, but first extent checksum bad:");
	prt_printf(&buf, "\n  ");
	prt_printf(&buf, "extents pointing to same space, but first extent checksum bad:\n");
	bch2_btree_id_to_text(&buf, btree);
	prt_str(&buf, " ");
	bch2_bkey_val_to_text(&buf, c, extent);
	prt_printf(&buf, "\n  ");
	prt_newline(&buf);
	bch2_btree_id_to_text(&buf, o_btree);
	prt_str(&buf, " ");
	bch2_bkey_val_to_text(&buf, c, extent2);
@@ -541,7 +540,7 @@ static int check_bp_exists(struct btree_trans *trans,
		printbuf_reset(&buf);
		prt_printf(&buf, "duplicate versions of same extent, deleting smaller\n");
		bch2_bkey_val_to_text(&buf, c, orig_k);
		prt_str(&buf, "\n  ");
		prt_newline(&buf);
		bch2_bkey_val_to_text(&buf, c, other_extent);
		bch_err(c, "%s", buf.buf);

@@ -582,7 +581,7 @@ static int check_bp_exists(struct btree_trans *trans,
	printbuf_reset(&buf);
	prt_printf(&buf, "duplicate extents pointing to same space on dev %llu\n", bp->k.p.inode);
	bch2_bkey_val_to_text(&buf, c, orig_k);
	prt_str(&buf, "\n  ");
	prt_newline(&buf);
	bch2_bkey_val_to_text(&buf, c, other_extent);
	bch_err(c, "%s", buf.buf);
	ret = -BCH_ERR_fsck_repair_unimplemented;
+1 −1
Original line number Diff line number Diff line
@@ -1417,7 +1417,7 @@ void __bch2_btree_pos_to_text(struct printbuf *out, struct bch_fs *c,
		prt_printf(out, "%u", r->level);
	else
		prt_printf(out, "(unknown)");
	prt_printf(out, "\n  ");
	prt_newline(out);

	bch2_bkey_val_to_text(out, c, k);
}
+9 −10
Original line number Diff line number Diff line
@@ -280,9 +280,9 @@ static int btree_repair_node_end(struct btree_trans *trans, struct btree *b,
	if (bpos_eq(child->key.k.p, b->key.k.p))
		return 0;

	prt_printf(&buf, "  at ");
	prt_printf(&buf, "\nat: ");
	bch2_btree_id_level_to_text(&buf, b->c.btree_id, b->c.level);
	prt_printf(&buf, ":\n  parent: ");
	prt_printf(&buf, "\nparent: ");
	bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(&b->key));

	prt_str(&buf, "\nchild: ");
@@ -351,8 +351,7 @@ static int bch2_btree_repair_topology_recurse(struct btree_trans *trans, struct

		if (mustfix_fsck_err_on(bch2_err_matches(ret, EIO),
				trans, btree_node_read_error,
				"Topology repair: unreadable btree node at\n"
				"  %s",
				"Topology repair: unreadable btree node at\n%s",
				buf.buf)) {
			bch2_btree_node_evict(trans, cur_k.k);
			cur = NULL;
+1 −3
Original line number Diff line number Diff line
@@ -525,8 +525,6 @@ static void btree_err_msg(struct printbuf *out, struct bch_fs *c,
	prt_printf(out, "at btree ");
	bch2_btree_pos_to_text(out, c, b);

	printbuf_indent_add(out, 2);

	prt_printf(out, "\nnode offset %u/%u",
		   b->written, btree_ptr_sectors_written(bkey_i_to_s_c(&b->key)));
	if (i)
Loading