Skip to content

Commit c087232

Browse files
adam900710kdave
authored andcommitted
btrfs: print-tree: debugging output enhancement
This patch enhances the following things: - tree block header * add generation and owner output for node and leaf - node pointer generation output - allow btrfs_print_tree() to not follow nodes * just like btrfs-progs Please note that, although function btrfs_print_tree() is not called by anyone right now, it's still a pretty useful function to debug kernel. So that function is still kept for later use. Signed-off-by: Qu Wenruo <[email protected]> Reviewed-by: Lu Fengqi <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 5e388e9 commit c087232

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

fs/btrfs/print-tree.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,10 @@ void btrfs_print_leaf(struct extent_buffer *l)
189189
fs_info = l->fs_info;
190190
nr = btrfs_header_nritems(l);
191191

192-
btrfs_info(fs_info, "leaf %llu total ptrs %d free space %d",
193-
btrfs_header_bytenr(l), nr,
194-
btrfs_leaf_free_space(fs_info, l));
192+
btrfs_info(fs_info,
193+
"leaf %llu gen %llu total ptrs %d free space %d owner %llu",
194+
btrfs_header_bytenr(l), btrfs_header_generation(l), nr,
195+
btrfs_leaf_free_space(fs_info, l), btrfs_header_owner(l));
195196
for (i = 0 ; i < nr ; i++) {
196197
item = btrfs_item_nr(i);
197198
btrfs_item_key_to_cpu(l, &key, i);
@@ -325,7 +326,7 @@ void btrfs_print_leaf(struct extent_buffer *l)
325326
}
326327
}
327328

328-
void btrfs_print_tree(struct extent_buffer *c)
329+
void btrfs_print_tree(struct extent_buffer *c, bool follow)
329330
{
330331
struct btrfs_fs_info *fs_info;
331332
int i; u32 nr;
@@ -342,15 +343,19 @@ void btrfs_print_tree(struct extent_buffer *c)
342343
return;
343344
}
344345
btrfs_info(fs_info,
345-
"node %llu level %d total ptrs %d free spc %u",
346-
btrfs_header_bytenr(c), level, nr,
347-
(u32)BTRFS_NODEPTRS_PER_BLOCK(fs_info) - nr);
346+
"node %llu level %d gen %llu total ptrs %d free spc %u owner %llu",
347+
btrfs_header_bytenr(c), level, btrfs_header_generation(c),
348+
nr, (u32)BTRFS_NODEPTRS_PER_BLOCK(fs_info) - nr,
349+
btrfs_header_owner(c));
348350
for (i = 0; i < nr; i++) {
349351
btrfs_node_key_to_cpu(c, &key, i);
350-
pr_info("\tkey %d (%llu %u %llu) block %llu\n",
352+
pr_info("\tkey %d (%llu %u %llu) block %llu gen %llu\n",
351353
i, key.objectid, key.type, key.offset,
352-
btrfs_node_blockptr(c, i));
354+
btrfs_node_blockptr(c, i),
355+
btrfs_node_ptr_generation(c, i));
353356
}
357+
if (!follow)
358+
return;
354359
for (i = 0; i < nr; i++) {
355360
struct btrfs_key first_key;
356361
struct extent_buffer *next;
@@ -372,7 +377,7 @@ void btrfs_print_tree(struct extent_buffer *c)
372377
if (btrfs_header_level(next) !=
373378
level - 1)
374379
BUG();
375-
btrfs_print_tree(next);
380+
btrfs_print_tree(next, follow);
376381
free_extent_buffer(next);
377382
}
378383
}

fs/btrfs/print-tree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
#define BTRFS_PRINT_TREE_H
88

99
void btrfs_print_leaf(struct extent_buffer *l);
10-
void btrfs_print_tree(struct extent_buffer *c);
10+
void btrfs_print_tree(struct extent_buffer *c, bool follow);
1111

1212
#endif

0 commit comments

Comments
 (0)