From 8606fe4bcb8ff88a67a939911af9336499486c85 Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Mon, 30 Apr 2018 11:15:44 +0800 Subject: btrfs-progs: Allow tree to be printed without an fs_info For btrfs_print_tree() and btrfs_print_leaf(), the usage of fs_info is mainly for nodesize and sectorsize. However for nodesize, we can get it from @eb->len without the need for fs_info at all. For nodesize, introduce new helper BTRFS_NODEPTR_PER_EXTENT_BUFFER() to get nodesize from @eb directly. And with the help of previous modified btrfs_leaf_free_space(), btrfs_print_tree() can live without fs_info at all. For btrfs_print_leaf(), we modify print_extent_csum() to accept NULL fs_info by skipping csum length calculation. With all these modification, btrfs_print_tree/leaf() can be called without accessing @fs_info at all, and make it more flexible to handle binary tree block dump, or inside gdb. Signed-off-by: Qu Wenruo Reviewed-by: Su Yue Signed-off-by: David Sterba --- ctree.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'ctree.h') diff --git a/ctree.h b/ctree.h index 7e67d1fc..697895a9 100644 --- a/ctree.h +++ b/ctree.h @@ -1202,6 +1202,12 @@ static inline u32 BTRFS_NODEPTRS_PER_BLOCK(const struct btrfs_fs_info *info) return BTRFS_LEAF_DATA_SIZE(info) / sizeof(struct btrfs_key_ptr); } +static inline u32 BTRFS_NODEPTRS_PER_EXTENT_BUFFER(const struct extent_buffer *eb) +{ + BUG_ON(eb->fs_info && eb->fs_info->nodesize != eb->len); + return __BTRFS_LEAF_DATA_SIZE(eb->len) / sizeof(struct btrfs_key_ptr); +} + #define BTRFS_FILE_EXTENT_INLINE_DATA_START \ (offsetof(struct btrfs_file_extent_item, disk_bytenr)) static inline u32 BTRFS_MAX_INLINE_DATA_SIZE(const struct btrfs_fs_info *info) -- cgit v1.2.3