Skip to content

Commit b7f6705

Browse files
Chandan Rajendramasoncl
authored andcommitted
Btrfs: Force stripesize to the value of sectorsize
Btrfs code currently assumes stripesize to be same as sectorsize. However Btrfs-progs (until commit df05c7ed455f519e6e15e46196392e4757257305) has been setting btrfs_super_block->stripesize to a value of 4096. This commit makes sure that the value of btrfs_super_block->stripesize is a power of 2. Later, it unconditionally sets btrfs_root->stripesize to sectorsize. Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Chris Mason <clm@fb.com>
1 parent c0d2f61 commit b7f6705

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

fs/btrfs/disk-io.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2806,7 +2806,7 @@ int open_ctree(struct super_block *sb,
28062806

28072807
nodesize = btrfs_super_nodesize(disk_super);
28082808
sectorsize = btrfs_super_sectorsize(disk_super);
2809-
stripesize = btrfs_super_stripesize(disk_super);
2809+
stripesize = sectorsize;
28102810
fs_info->dirty_metadata_batch = nodesize * (1 + ilog2(nr_cpu_ids));
28112811
fs_info->delalloc_batch = sectorsize * 512 * (1 + ilog2(nr_cpu_ids));
28122812

@@ -4133,9 +4133,7 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
41334133
btrfs_super_bytes_used(sb));
41344134
ret = -EINVAL;
41354135
}
4136-
if (!is_power_of_2(btrfs_super_stripesize(sb)) ||
4137-
((btrfs_super_stripesize(sb) != sectorsize) &&
4138-
(btrfs_super_stripesize(sb) != 4096))) {
4136+
if (!is_power_of_2(btrfs_super_stripesize(sb))) {
41394137
btrfs_err(fs_info, "invalid stripesize %u",
41404138
btrfs_super_stripesize(sb));
41414139
ret = -EINVAL;

fs/btrfs/volumes.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4694,12 +4694,12 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
46944694

46954695
if (type & BTRFS_BLOCK_GROUP_RAID5) {
46964696
raid_stripe_len = find_raid56_stripe_len(ndevs - 1,
4697-
btrfs_super_stripesize(info->super_copy));
4697+
extent_root->stripesize);
46984698
data_stripes = num_stripes - 1;
46994699
}
47004700
if (type & BTRFS_BLOCK_GROUP_RAID6) {
47014701
raid_stripe_len = find_raid56_stripe_len(ndevs - 2,
4702-
btrfs_super_stripesize(info->super_copy));
4702+
extent_root->stripesize);
47034703
data_stripes = num_stripes - 2;
47044704
}
47054705

0 commit comments

Comments
 (0)