Skip to content

Commit 2422547

Browse files
morbidrsakdave
authored andcommitted
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 <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent e2c1887 commit 2422547

File tree

6 files changed

+2
-55
lines changed

6 files changed

+2
-55
lines changed

fs/btrfs/accessors.h

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

318-
BTRFS_SETGET_FUNCS(stripe_extent_encoding, struct btrfs_stripe_extent, encoding, 8);
319318
BTRFS_SETGET_FUNCS(raid_stride_devid, struct btrfs_raid_stride, devid, 64);
320319
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);
323320
BTRFS_SETGET_STACK_FUNCS(stack_raid_stride_devid, struct btrfs_raid_stride, devid, 64);
324321
BTRFS_SETGET_STACK_FUNCS(stack_raid_stride_physical, struct btrfs_raid_stride, physical, 64);
325322

fs/btrfs/print-tree.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,6 @@ static void print_raid_stripe_key(const struct extent_buffer *eb, u32 item_size,
208208
struct btrfs_stripe_extent *stripe)
209209
{
210210
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");
216211

217212
for (int i = 0; i < num_stripes; i++)
218213
pr_info("\t\t\tstride %d devid %llu physical %llu\n",

fs/btrfs/raid-stripe-tree.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ static int btrfs_insert_one_raid_extent(struct btrfs_trans_handle *trans,
8080
struct btrfs_key stripe_key;
8181
struct btrfs_root *stripe_root = fs_info->stripe_root;
8282
const int num_stripes = btrfs_bg_type_to_factor(bioc->map_type);
83-
u8 encoding = btrfs_bg_flags_to_raid_index(bioc->map_type);
8483
struct btrfs_stripe_extent *stripe_extent;
8584
const size_t item_size = struct_size(stripe_extent, strides, num_stripes);
8685
int ret;
@@ -94,7 +93,6 @@ static int btrfs_insert_one_raid_extent(struct btrfs_trans_handle *trans,
9493

9594
trace_btrfs_insert_one_raid_extent(fs_info, bioc->logical, bioc->size,
9695
num_stripes);
97-
btrfs_set_stack_stripe_extent_encoding(stripe_extent, encoding);
9896
for (int i = 0; i < num_stripes; i++) {
9997
u64 devid = bioc->stripes[i].dev->devid;
10098
u64 physical = bioc->stripes[i].physical;
@@ -159,7 +157,6 @@ int btrfs_get_raid_extent_offset(struct btrfs_fs_info *fs_info,
159157
struct extent_buffer *leaf;
160158
const u64 end = logical + *length;
161159
int num_stripes;
162-
u8 encoding;
163160
u64 offset;
164161
u64 found_logical;
165162
u64 found_length;
@@ -222,16 +219,6 @@ int btrfs_get_raid_extent_offset(struct btrfs_fs_info *fs_info,
222219

223220
num_stripes = btrfs_num_raid_stripes(btrfs_item_size(leaf, slot));
224221
stripe_extent = btrfs_item_ptr(leaf, slot, struct btrfs_stripe_extent);
225-
encoding = btrfs_stripe_extent_encoding(leaf, stripe_extent);
226-
227-
if (encoding != btrfs_bg_flags_to_raid_index(map_type)) {
228-
ret = -EUCLEAN;
229-
btrfs_handle_fs_error(fs_info, ret,
230-
"on-disk stripe encoding %d doesn't match RAID index %d",
231-
encoding,
232-
btrfs_bg_flags_to_raid_index(map_type));
233-
goto out;
234-
}
235222

236223
for (int i = 0; i < num_stripes; i++) {
237224
struct btrfs_raid_stride *stride = &stripe_extent->strides[i];

fs/btrfs/raid-stripe-tree.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ static inline bool btrfs_need_stripe_tree_update(struct btrfs_fs_info *fs_info,
4848

4949
static inline int btrfs_num_raid_stripes(u32 item_size)
5050
{
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);
5352
}
5453

5554
#endif

fs/btrfs/tree-checker.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,9 +1682,6 @@ static int check_inode_ref(struct extent_buffer *leaf,
16821682
static int check_raid_stripe_extent(const struct extent_buffer *leaf,
16831683
const struct btrfs_key *key, int slot)
16841684
{
1685-
struct btrfs_stripe_extent *stripe_extent =
1686-
btrfs_item_ptr(leaf, slot, struct btrfs_stripe_extent);
1687-
16881685
if (unlikely(!IS_ALIGNED(key->objectid, leaf->fs_info->sectorsize))) {
16891686
generic_err(leaf, slot,
16901687
"invalid key objectid for raid stripe extent, have %llu expect aligned to %u",
@@ -1698,22 +1695,6 @@ static int check_raid_stripe_extent(const struct extent_buffer *leaf,
16981695
return -EUCLEAN;
16991696
}
17001697

1701-
switch (btrfs_stripe_extent_encoding(leaf, stripe_extent)) {
1702-
case BTRFS_STRIPE_RAID0:
1703-
case BTRFS_STRIPE_RAID1:
1704-
case BTRFS_STRIPE_DUP:
1705-
case BTRFS_STRIPE_RAID10:
1706-
case BTRFS_STRIPE_RAID5:
1707-
case BTRFS_STRIPE_RAID6:
1708-
case BTRFS_STRIPE_RAID1C3:
1709-
case BTRFS_STRIPE_RAID1C4:
1710-
break;
1711-
default:
1712-
generic_err(leaf, slot, "invalid raid stripe encoding %u",
1713-
btrfs_stripe_extent_encoding(leaf, stripe_extent));
1714-
return -EUCLEAN;
1715-
}
1716-
17171698
return 0;
17181699
}
17191700

include/uapi/linux/btrfs_tree.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -747,21 +747,9 @@ struct btrfs_raid_stride {
747747
__le64 physical;
748748
} __attribute__ ((__packed__));
749749

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-
760750
struct btrfs_stripe_extent {
761-
__u8 encoding;
762-
__u8 reserved[7];
763751
/* 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);
765753
} __attribute__ ((__packed__));
766754

767755
#define BTRFS_HEADER_FLAG_WRITTEN (1ULL << 0)

0 commit comments

Comments
 (0)