BTRFS_SETGET_STACK_FUNCS(stack_timespec_sec, struct btrfs_timespec, sec, 64);
 BTRFS_SETGET_STACK_FUNCS(stack_timespec_nsec, struct btrfs_timespec, nsec, 32);
 
-BTRFS_SETGET_FUNCS(stripe_extent_encoding, struct btrfs_stripe_extent, encoding, 8);
 BTRFS_SETGET_FUNCS(raid_stride_devid, struct btrfs_raid_stride, devid, 64);
 BTRFS_SETGET_FUNCS(raid_stride_physical, struct btrfs_raid_stride, physical, 64);
-BTRFS_SETGET_STACK_FUNCS(stack_stripe_extent_encoding,
-                        struct btrfs_stripe_extent, encoding, 8);
 BTRFS_SETGET_STACK_FUNCS(stack_raid_stride_devid, struct btrfs_raid_stride, devid, 64);
 BTRFS_SETGET_STACK_FUNCS(stack_raid_stride_physical, struct btrfs_raid_stride, physical, 64);
 
 
                                  struct btrfs_stripe_extent *stripe)
 {
        const int num_stripes = btrfs_num_raid_stripes(item_size);
-       const u8 encoding = btrfs_stripe_extent_encoding(eb, stripe);
-
-       pr_info("\t\t\tencoding: %s\n",
-               (encoding && encoding < BTRFS_NR_RAID_TYPES) ?
-               btrfs_raid_array[encoding].raid_name : "unknown");
 
        for (int i = 0; i < num_stripes; i++)
                pr_info("\t\t\tstride %d devid %llu physical %llu\n",
 
        struct btrfs_key stripe_key;
        struct btrfs_root *stripe_root = fs_info->stripe_root;
        const int num_stripes = btrfs_bg_type_to_factor(bioc->map_type);
-       u8 encoding = btrfs_bg_flags_to_raid_index(bioc->map_type);
        struct btrfs_stripe_extent *stripe_extent;
        const size_t item_size = struct_size(stripe_extent, strides, num_stripes);
        int ret;
 
        trace_btrfs_insert_one_raid_extent(fs_info, bioc->logical, bioc->size,
                                           num_stripes);
-       btrfs_set_stack_stripe_extent_encoding(stripe_extent, encoding);
        for (int i = 0; i < num_stripes; i++) {
                u64 devid = bioc->stripes[i].dev->devid;
                u64 physical = bioc->stripes[i].physical;
        struct extent_buffer *leaf;
        const u64 end = logical + *length;
        int num_stripes;
-       u8 encoding;
        u64 offset;
        u64 found_logical;
        u64 found_length;
 
        num_stripes = btrfs_num_raid_stripes(btrfs_item_size(leaf, slot));
        stripe_extent = btrfs_item_ptr(leaf, slot, struct btrfs_stripe_extent);
-       encoding = btrfs_stripe_extent_encoding(leaf, stripe_extent);
-
-       if (encoding != btrfs_bg_flags_to_raid_index(map_type)) {
-               ret = -EUCLEAN;
-               btrfs_handle_fs_error(fs_info, ret,
-                                     "on-disk stripe encoding %d doesn't match RAID index %d",
-                                     encoding,
-                                     btrfs_bg_flags_to_raid_index(map_type));
-               goto out;
-       }
 
        for (int i = 0; i < num_stripes; i++) {
                struct btrfs_raid_stride *stride = &stripe_extent->strides[i];
 
 
 static inline int btrfs_num_raid_stripes(u32 item_size)
 {
-       return (item_size - offsetof(struct btrfs_stripe_extent, strides)) /
-               sizeof(struct btrfs_raid_stride);
+       return item_size / sizeof(struct btrfs_raid_stride);
 }
 
 #endif
 
 static int check_raid_stripe_extent(const struct extent_buffer *leaf,
                                    const struct btrfs_key *key, int slot)
 {
-       struct btrfs_stripe_extent *stripe_extent =
-               btrfs_item_ptr(leaf, slot, struct btrfs_stripe_extent);
-
        if (unlikely(!IS_ALIGNED(key->objectid, leaf->fs_info->sectorsize))) {
                generic_err(leaf, slot,
 "invalid key objectid for raid stripe extent, have %llu expect aligned to %u",
                return -EUCLEAN;
        }
 
-       switch (btrfs_stripe_extent_encoding(leaf, stripe_extent)) {
-       case BTRFS_STRIPE_RAID0:
-       case BTRFS_STRIPE_RAID1:
-       case BTRFS_STRIPE_DUP:
-       case BTRFS_STRIPE_RAID10:
-       case BTRFS_STRIPE_RAID5:
-       case BTRFS_STRIPE_RAID6:
-       case BTRFS_STRIPE_RAID1C3:
-       case BTRFS_STRIPE_RAID1C4:
-               break;
-       default:
-               generic_err(leaf, slot, "invalid raid stripe encoding %u",
-                           btrfs_stripe_extent_encoding(leaf, stripe_extent));
-               return -EUCLEAN;
-       }
-
        return 0;
 }
 
 
        __le64 physical;
 } __attribute__ ((__packed__));
 
-/* The stripe_extent::encoding, 1:1 mapping of enum btrfs_raid_types. */
-#define BTRFS_STRIPE_RAID0     1
-#define BTRFS_STRIPE_RAID1     2
-#define BTRFS_STRIPE_DUP       3
-#define BTRFS_STRIPE_RAID10    4
-#define BTRFS_STRIPE_RAID5     5
-#define BTRFS_STRIPE_RAID6     6
-#define BTRFS_STRIPE_RAID1C3   7
-#define BTRFS_STRIPE_RAID1C4   8
-
 struct btrfs_stripe_extent {
-       __u8 encoding;
-       __u8 reserved[7];
        /* An array of raid strides this stripe is composed of. */
-       struct btrfs_raid_stride strides[];
+       __DECLARE_FLEX_ARRAY(struct btrfs_raid_stride, strides);
 } __attribute__ ((__packed__));
 
 #define BTRFS_HEADER_FLAG_WRITTEN      (1ULL << 0)