Skip to content

Commit 4dc1c3d

Browse files
fdmananakdave
authored andcommitted
btrfs: print-tree: print range information for extent csum items
Currently we don't print anything for extent csum items other than the generic line with the key, item offset and item size. While one can still determine the range the extent csum covers by doing a few simple computations, it makes it more time consuming to analyse a leaf dump. So add a line that prints information about the range covered by the checksum using the same format as btrfs-progs. This is useful when debugging log tree issues since we log extent csum items for new extents. Reviewed-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 7d2197b commit 4dc1c3d

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

fs/btrfs/print-tree.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,18 @@ static void print_dir_log_index_item(const struct extent_buffer *eb, int i)
325325
pr_info("\t\tdir log end %llu\n", btrfs_dir_log_end(eb, dlog));
326326
}
327327

328+
static void print_extent_csum(const struct extent_buffer *eb, int i)
329+
{
330+
const struct btrfs_fs_info *fs_info = eb->fs_info;
331+
const u32 size = btrfs_item_size(eb, i);
332+
const u32 csum_bytes = (size / fs_info->csum_size) * fs_info->sectorsize;
333+
struct btrfs_key key;
334+
335+
btrfs_item_key_to_cpu(eb, &key, i);
336+
pr_info("\t\trange start %llu end %llu length %u\n",
337+
key.offset, key.offset + csum_bytes, csum_bytes);
338+
}
339+
328340
void btrfs_print_leaf(const struct extent_buffer *l)
329341
{
330342
struct btrfs_fs_info *fs_info;
@@ -373,6 +385,9 @@ void btrfs_print_leaf(const struct extent_buffer *l)
373385
case BTRFS_DIR_LOG_INDEX_KEY:
374386
print_dir_log_index_item(l, i);
375387
break;
388+
case BTRFS_EXTENT_CSUM_KEY:
389+
print_extent_csum(l, i);
390+
break;
376391
case BTRFS_ROOT_ITEM_KEY:
377392
ri = btrfs_item_ptr(l, i, struct btrfs_root_item);
378393
pr_info("\t\troot data bytenr %llu refs %u\n",

0 commit comments

Comments
 (0)