Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

btrfs: remove raid-stripe-tree encoding field from stripe_extent

Remove the encoding field from 'struct btrfs_stripe_extent'. It was
originally intended to encode the RAID type as well as if we're a data
or a parity stripe.

But the RAID type can be inferred form the block-group and the data vs.
parity differentiation can be done easier with adding a new key type
for parity stripes in the RAID stripe tree.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Johannes Thumshirn and committed by
David Sterba
2422547e e2c18873

+2 -55
-3
fs/btrfs/accessors.h
··· 315 315 BTRFS_SETGET_STACK_FUNCS(stack_timespec_sec, struct btrfs_timespec, sec, 64); 316 316 BTRFS_SETGET_STACK_FUNCS(stack_timespec_nsec, struct btrfs_timespec, nsec, 32); 317 317 318 - BTRFS_SETGET_FUNCS(stripe_extent_encoding, struct btrfs_stripe_extent, encoding, 8); 319 318 BTRFS_SETGET_FUNCS(raid_stride_devid, struct btrfs_raid_stride, devid, 64); 320 319 BTRFS_SETGET_FUNCS(raid_stride_physical, struct btrfs_raid_stride, physical, 64); 321 - BTRFS_SETGET_STACK_FUNCS(stack_stripe_extent_encoding, 322 - struct btrfs_stripe_extent, encoding, 8); 323 320 BTRFS_SETGET_STACK_FUNCS(stack_raid_stride_devid, struct btrfs_raid_stride, devid, 64); 324 321 BTRFS_SETGET_STACK_FUNCS(stack_raid_stride_physical, struct btrfs_raid_stride, physical, 64); 325 322
-5
fs/btrfs/print-tree.c
··· 208 208 struct btrfs_stripe_extent *stripe) 209 209 { 210 210 const int num_stripes = btrfs_num_raid_stripes(item_size); 211 - const u8 encoding = btrfs_stripe_extent_encoding(eb, stripe); 212 - 213 - pr_info("\t\t\tencoding: %s\n", 214 - (encoding && encoding < BTRFS_NR_RAID_TYPES) ? 215 - btrfs_raid_array[encoding].raid_name : "unknown"); 216 211 217 212 for (int i = 0; i < num_stripes; i++) 218 213 pr_info("\t\t\tstride %d devid %llu physical %llu\n",
-13
fs/btrfs/raid-stripe-tree.c
··· 80 80 struct btrfs_key stripe_key; 81 81 struct btrfs_root *stripe_root = fs_info->stripe_root; 82 82 const int num_stripes = btrfs_bg_type_to_factor(bioc->map_type); 83 - u8 encoding = btrfs_bg_flags_to_raid_index(bioc->map_type); 84 83 struct btrfs_stripe_extent *stripe_extent; 85 84 const size_t item_size = struct_size(stripe_extent, strides, num_stripes); 86 85 int ret; ··· 93 94 94 95 trace_btrfs_insert_one_raid_extent(fs_info, bioc->logical, bioc->size, 95 96 num_stripes); 96 - btrfs_set_stack_stripe_extent_encoding(stripe_extent, encoding); 97 97 for (int i = 0; i < num_stripes; i++) { 98 98 u64 devid = bioc->stripes[i].dev->devid; 99 99 u64 physical = bioc->stripes[i].physical; ··· 157 159 struct extent_buffer *leaf; 158 160 const u64 end = logical + *length; 159 161 int num_stripes; 160 - u8 encoding; 161 162 u64 offset; 162 163 u64 found_logical; 163 164 u64 found_length; ··· 219 222 220 223 num_stripes = btrfs_num_raid_stripes(btrfs_item_size(leaf, slot)); 221 224 stripe_extent = btrfs_item_ptr(leaf, slot, struct btrfs_stripe_extent); 222 - encoding = btrfs_stripe_extent_encoding(leaf, stripe_extent); 223 - 224 - if (encoding != btrfs_bg_flags_to_raid_index(map_type)) { 225 - ret = -EUCLEAN; 226 - btrfs_handle_fs_error(fs_info, ret, 227 - "on-disk stripe encoding %d doesn't match RAID index %d", 228 - encoding, 229 - btrfs_bg_flags_to_raid_index(map_type)); 230 - goto out; 231 - } 232 225 233 226 for (int i = 0; i < num_stripes; i++) { 234 227 struct btrfs_raid_stride *stride = &stripe_extent->strides[i];
+1 -2
fs/btrfs/raid-stripe-tree.h
··· 48 48 49 49 static inline int btrfs_num_raid_stripes(u32 item_size) 50 50 { 51 - return (item_size - offsetof(struct btrfs_stripe_extent, strides)) / 52 - sizeof(struct btrfs_raid_stride); 51 + return item_size / sizeof(struct btrfs_raid_stride); 53 52 } 54 53 55 54 #endif
-19
fs/btrfs/tree-checker.c
··· 1682 1682 static int check_raid_stripe_extent(const struct extent_buffer *leaf, 1683 1683 const struct btrfs_key *key, int slot) 1684 1684 { 1685 - struct btrfs_stripe_extent *stripe_extent = 1686 - btrfs_item_ptr(leaf, slot, struct btrfs_stripe_extent); 1687 - 1688 1685 if (unlikely(!IS_ALIGNED(key->objectid, leaf->fs_info->sectorsize))) { 1689 1686 generic_err(leaf, slot, 1690 1687 "invalid key objectid for raid stripe extent, have %llu expect aligned to %u", ··· 1692 1695 if (unlikely(!btrfs_fs_incompat(leaf->fs_info, RAID_STRIPE_TREE))) { 1693 1696 generic_err(leaf, slot, 1694 1697 "RAID_STRIPE_EXTENT present but RAID_STRIPE_TREE incompat bit unset"); 1695 - return -EUCLEAN; 1696 - } 1697 - 1698 - switch (btrfs_stripe_extent_encoding(leaf, stripe_extent)) { 1699 - case BTRFS_STRIPE_RAID0: 1700 - case BTRFS_STRIPE_RAID1: 1701 - case BTRFS_STRIPE_DUP: 1702 - case BTRFS_STRIPE_RAID10: 1703 - case BTRFS_STRIPE_RAID5: 1704 - case BTRFS_STRIPE_RAID6: 1705 - case BTRFS_STRIPE_RAID1C3: 1706 - case BTRFS_STRIPE_RAID1C4: 1707 - break; 1708 - default: 1709 - generic_err(leaf, slot, "invalid raid stripe encoding %u", 1710 - btrfs_stripe_extent_encoding(leaf, stripe_extent)); 1711 1698 return -EUCLEAN; 1712 1699 } 1713 1700
+1 -13
include/uapi/linux/btrfs_tree.h
··· 747 747 __le64 physical; 748 748 } __attribute__ ((__packed__)); 749 749 750 - /* The stripe_extent::encoding, 1:1 mapping of enum btrfs_raid_types. */ 751 - #define BTRFS_STRIPE_RAID0 1 752 - #define BTRFS_STRIPE_RAID1 2 753 - #define BTRFS_STRIPE_DUP 3 754 - #define BTRFS_STRIPE_RAID10 4 755 - #define BTRFS_STRIPE_RAID5 5 756 - #define BTRFS_STRIPE_RAID6 6 757 - #define BTRFS_STRIPE_RAID1C3 7 758 - #define BTRFS_STRIPE_RAID1C4 8 759 - 760 750 struct btrfs_stripe_extent { 761 - __u8 encoding; 762 - __u8 reserved[7]; 763 751 /* An array of raid strides this stripe is composed of. */ 764 - struct btrfs_raid_stride strides[]; 752 + __DECLARE_FLEX_ARRAY(struct btrfs_raid_stride, strides); 765 753 } __attribute__ ((__packed__)); 766 754 767 755 #define BTRFS_HEADER_FLAG_WRITTEN (1ULL << 0)