Skip to content

Commit cf67f46

Browse files
author
Kent Overstreet
committed
bcachefs: __bch2_btree_pos_to_text()
Factor out a version of bch2_btree_pos_to_text() that doesn't take a pointer to a in-memory btree node, to be used for btree node scrub. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 0a46ea9 commit cf67f46

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

fs/bcachefs/btree_cache.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,18 +1402,24 @@ void bch2_btree_id_level_to_text(struct printbuf *out, enum btree_id btree, unsi
14021402
prt_printf(out, " level=%u", level);
14031403
}
14041404

1405-
void bch2_btree_pos_to_text(struct printbuf *out, struct bch_fs *c, const struct btree *b)
1405+
void __bch2_btree_pos_to_text(struct printbuf *out, struct bch_fs *c,
1406+
enum btree_id btree, unsigned level, struct bkey_s_c k)
14061407
{
1407-
bch2_btree_id_to_text(out, b->c.btree_id);
1408-
prt_printf(out, " level %u/", b->c.level);
1409-
struct btree_root *r = bch2_btree_id_root(c, b->c.btree_id);
1408+
bch2_btree_id_to_text(out, btree);
1409+
prt_printf(out, " level %u/", level);
1410+
struct btree_root *r = bch2_btree_id_root(c, btree);
14101411
if (r)
14111412
prt_printf(out, "%u", r->level);
14121413
else
14131414
prt_printf(out, "(unknown)");
14141415
prt_printf(out, "\n ");
14151416

1416-
bch2_bkey_val_to_text(out, c, bkey_i_to_s_c(&b->key));
1417+
bch2_bkey_val_to_text(out, c, k);
1418+
}
1419+
1420+
void bch2_btree_pos_to_text(struct printbuf *out, struct bch_fs *c, const struct btree *b)
1421+
{
1422+
__bch2_btree_pos_to_text(out, c, b->c.btree_id, b->c.level, bkey_i_to_s_c(&b->key));
14171423
}
14181424

14191425
void bch2_btree_node_to_text(struct printbuf *out, struct bch_fs *c, const struct btree *b)

fs/bcachefs/btree_cache.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ const char *bch2_btree_id_str(enum btree_id); /* avoid */
147147
void bch2_btree_id_to_text(struct printbuf *, enum btree_id);
148148
void bch2_btree_id_level_to_text(struct printbuf *, enum btree_id, unsigned);
149149

150+
void __bch2_btree_pos_to_text(struct printbuf *, struct bch_fs *,
151+
enum btree_id, unsigned, struct bkey_s_c);
150152
void bch2_btree_pos_to_text(struct printbuf *, struct bch_fs *, const struct btree *);
151153
void bch2_btree_node_to_text(struct printbuf *, struct bch_fs *, const struct btree *);
152154
void bch2_btree_cache_to_text(struct printbuf *, const struct btree_cache *);

0 commit comments

Comments
 (0)