Skip to content

Commit 7c549b5

Browse files
morbidrsakdave
authored andcommitted
btrfs-progs: remove raid stripe encoding
Remove the not needed encoding and reserved fields in struct raid_stripe_extent. This saves 8 bytes per stripe extent. Note: this is a format change and previously created filesystems with raid-stripe-tree will not be accessible. Similar patch is needed in kernel. Signed-off-by: Johannes Thumshirn <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent d6e23e1 commit 7c549b5

File tree

4 files changed

+2
-67
lines changed

4 files changed

+2
-67
lines changed

kernel-shared/accessors.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,8 @@ BTRFS_SETGET_FUNCS(timespec_nsec, struct btrfs_timespec, nsec, 32);
322322
BTRFS_SETGET_STACK_FUNCS(stack_timespec_sec, struct btrfs_timespec, sec, 64);
323323
BTRFS_SETGET_STACK_FUNCS(stack_timespec_nsec, struct btrfs_timespec, nsec, 32);
324324

325-
BTRFS_SETGET_FUNCS(stripe_extent_encoding, struct btrfs_stripe_extent, encoding, 8);
326325
BTRFS_SETGET_FUNCS(raid_stride_devid, struct btrfs_raid_stride, devid, 64);
327326
BTRFS_SETGET_FUNCS(raid_stride_offset, struct btrfs_raid_stride, offset, 64);
328-
BTRFS_SETGET_STACK_FUNCS(stack_stripe_extent_encoding,
329-
struct btrfs_stripe_extent, encoding, 8);
330327
BTRFS_SETGET_STACK_FUNCS(stack_raid_stride_devid, struct btrfs_raid_stride, devid, 64);
331328

332329
static inline struct btrfs_raid_stride *btrfs_raid_stride_nr(

kernel-shared/print-tree.c

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -669,42 +669,11 @@ static void print_free_space_header(struct extent_buffer *leaf, int slot)
669669
(unsigned long long)btrfs_free_space_bitmaps(leaf, header));
670670
}
671671

672-
struct raid_encoding_map {
673-
u8 encoding;
674-
char name[16];
675-
};
676-
677-
static const struct raid_encoding_map raid_map[] = {
678-
{ BTRFS_STRIPE_DUP, "DUP" },
679-
{ BTRFS_STRIPE_RAID0, "RAID0" },
680-
{ BTRFS_STRIPE_RAID1, "RAID1" },
681-
{ BTRFS_STRIPE_RAID1C3, "RAID1C3" },
682-
{ BTRFS_STRIPE_RAID1C4, "RAID1C4" },
683-
{ BTRFS_STRIPE_RAID5, "RAID5" },
684-
{ BTRFS_STRIPE_RAID6, "RAID6" },
685-
{ BTRFS_STRIPE_RAID10, "RAID10" }
686-
};
687-
688-
static const char *stripe_encoding_name(u8 encoding)
689-
{
690-
for (int i = 0; i < ARRAY_SIZE(raid_map); i++) {
691-
if (raid_map[i].encoding == encoding)
692-
return raid_map[i].name;
693-
}
694-
695-
return "UNKNOWN";
696-
}
697-
698672
static void print_raid_stripe_key(struct extent_buffer *eb,
699673
u32 item_size, struct btrfs_stripe_extent *stripe)
700674
{
701-
int num_stripes;
702-
u8 encoding = btrfs_stripe_extent_encoding(eb, stripe);
703-
704-
num_stripes = (item_size - offsetof(struct btrfs_stripe_extent, strides)) /
705-
sizeof(struct btrfs_raid_stride);
675+
int num_stripes = item_size / sizeof(struct btrfs_raid_stride);
706676

707-
printf("\t\t\tencoding: %s\n", stripe_encoding_name(encoding));
708677
for (int i = 0; i < num_stripes; i++)
709678
printf("\t\t\tstripe %d devid %llu physical %llu\n", i,
710679
(unsigned long long)btrfs_raid_stride_devid_nr(eb, stripe, i),

kernel-shared/tree-checker.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,9 +1721,6 @@ static int check_inode_ref(struct extent_buffer *leaf,
17211721
static int check_raid_stripe_extent(const struct extent_buffer *leaf,
17221722
const struct btrfs_key *key, int slot)
17231723
{
1724-
struct btrfs_stripe_extent *stripe_extent =
1725-
btrfs_item_ptr(leaf, slot, struct btrfs_stripe_extent);
1726-
17271724
if (unlikely(!IS_ALIGNED(key->objectid, leaf->fs_info->sectorsize))) {
17281725
generic_err(leaf, slot,
17291726
"invalid key objectid for raid stripe extent, have %llu expect aligned to %u",
@@ -1737,22 +1734,6 @@ static int check_raid_stripe_extent(const struct extent_buffer *leaf,
17371734
return -EUCLEAN;
17381735
}
17391736

1740-
switch (btrfs_stripe_extent_encoding(leaf, stripe_extent)) {
1741-
case BTRFS_STRIPE_RAID0:
1742-
case BTRFS_STRIPE_RAID1:
1743-
case BTRFS_STRIPE_DUP:
1744-
case BTRFS_STRIPE_RAID10:
1745-
case BTRFS_STRIPE_RAID5:
1746-
case BTRFS_STRIPE_RAID6:
1747-
case BTRFS_STRIPE_RAID1C3:
1748-
case BTRFS_STRIPE_RAID1C4:
1749-
break;
1750-
default:
1751-
generic_err(leaf, slot, "invalid raid stripe encoding %u",
1752-
btrfs_stripe_extent_encoding(leaf, stripe_extent));
1753-
return -EUCLEAN;
1754-
}
1755-
17561737
return 0;
17571738
}
17581739

kernel-shared/uapi/btrfs_tree.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -712,21 +712,9 @@ struct btrfs_raid_stride {
712712
__le64 offset;
713713
} __attribute__ ((__packed__));
714714

715-
/* The stripe_extent::encoding, 1:1 mapping of enum btrfs_raid_types */
716-
#define BTRFS_STRIPE_RAID0 1
717-
#define BTRFS_STRIPE_RAID1 2
718-
#define BTRFS_STRIPE_DUP 3
719-
#define BTRFS_STRIPE_RAID10 4
720-
#define BTRFS_STRIPE_RAID5 5
721-
#define BTRFS_STRIPE_RAID6 6
722-
#define BTRFS_STRIPE_RAID1C3 7
723-
#define BTRFS_STRIPE_RAID1C4 8
724-
725715
struct btrfs_stripe_extent {
726-
u8 encoding;
727-
u8 reserved[7];
728716
/* Array of raid strides this stripe is comprised of. */
729-
struct btrfs_raid_stride strides;
717+
__DECLARE_FLEX_ARRAY(struct btrfs_raid_stride, strides);
730718
} __attribute__ ((__packed__));
731719

732720
#define BTRFS_FREE_SPACE_EXTENT 1

0 commit comments

Comments
 (0)