Skip to content

Commit edde81f

Browse files
morbidrsakdave
authored andcommitted
btrfs: add raid stripe tree pretty printer
Decode raid-stripe-tree entries on btrfs_print_tree(). Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 568220f commit edde81f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

fs/btrfs/print-tree.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "print-tree.h"
1010
#include "accessors.h"
1111
#include "tree-checker.h"
12+
#include "volumes.h"
13+
#include "raid-stripe-tree.h"
1214

1315
struct root_name_map {
1416
u64 id;
@@ -28,6 +30,7 @@ static const struct root_name_map root_map[] = {
2830
{ BTRFS_FREE_SPACE_TREE_OBJECTID, "FREE_SPACE_TREE" },
2931
{ BTRFS_BLOCK_GROUP_TREE_OBJECTID, "BLOCK_GROUP_TREE" },
3032
{ BTRFS_DATA_RELOC_TREE_OBJECTID, "DATA_RELOC_TREE" },
33+
{ BTRFS_RAID_STRIPE_TREE_OBJECTID, "RAID_STRIPE_TREE" },
3134
};
3235

3336
const char *btrfs_root_name(const struct btrfs_key *key, char *buf)
@@ -189,6 +192,22 @@ static void print_uuid_item(const struct extent_buffer *l, unsigned long offset,
189192
}
190193
}
191194

195+
static void print_raid_stripe_key(const struct extent_buffer *eb, u32 item_size,
196+
struct btrfs_stripe_extent *stripe)
197+
{
198+
const int num_stripes = btrfs_num_raid_stripes(item_size);
199+
const u8 encoding = btrfs_stripe_extent_encoding(eb, stripe);
200+
201+
pr_info("\t\t\tencoding: %s\n",
202+
(encoding && encoding < BTRFS_NR_RAID_TYPES) ?
203+
btrfs_raid_array[encoding].raid_name : "unknown");
204+
205+
for (int i = 0; i < num_stripes; i++)
206+
pr_info("\t\t\tstride %d devid %llu physical %llu\n",
207+
i, btrfs_raid_stride_devid(eb, &stripe->strides[i]),
208+
btrfs_raid_stride_physical(eb, &stripe->strides[i]));
209+
}
210+
192211
/*
193212
* Helper to output refs and locking status of extent buffer. Useful to debug
194213
* race condition related problems.
@@ -349,6 +368,10 @@ void btrfs_print_leaf(const struct extent_buffer *l)
349368
print_uuid_item(l, btrfs_item_ptr_offset(l, i),
350369
btrfs_item_size(l, i));
351370
break;
371+
case BTRFS_RAID_STRIPE_KEY:
372+
print_raid_stripe_key(l, btrfs_item_size(l, i),
373+
btrfs_item_ptr(l, i, struct btrfs_stripe_extent));
374+
break;
352375
}
353376
}
354377
}

0 commit comments

Comments
 (0)