diff options
author | Chandan Rajendra <chandan@linux.vnet.ibm.com> | 2016-06-23 05:46:44 -0400 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2016-06-23 13:44:42 -0400 |
commit | b7f67055d2df9b8f68f02e49d256ee3973999bd2 (patch) | |
tree | 0fcd75971843a7db70550df761c7028599192a80 | |
parent | c0d2f6104e8ab2eb75e58e72494ad4b69c5227f8 (diff) |
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>
-rw-r--r-- | fs/btrfs/disk-io.c | 6 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 4 |
2 files changed, 4 insertions, 6 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 54cca7a1572b..60ce1190307b 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -2806,7 +2806,7 @@ int open_ctree(struct super_block *sb, | |||
2806 | 2806 | ||
2807 | nodesize = btrfs_super_nodesize(disk_super); | 2807 | nodesize = btrfs_super_nodesize(disk_super); |
2808 | sectorsize = btrfs_super_sectorsize(disk_super); | 2808 | sectorsize = btrfs_super_sectorsize(disk_super); |
2809 | stripesize = btrfs_super_stripesize(disk_super); | 2809 | stripesize = sectorsize; |
2810 | fs_info->dirty_metadata_batch = nodesize * (1 + ilog2(nr_cpu_ids)); | 2810 | fs_info->dirty_metadata_batch = nodesize * (1 + ilog2(nr_cpu_ids)); |
2811 | fs_info->delalloc_batch = sectorsize * 512 * (1 + ilog2(nr_cpu_ids)); | 2811 | fs_info->delalloc_batch = sectorsize * 512 * (1 + ilog2(nr_cpu_ids)); |
2812 | 2812 | ||
@@ -4133,9 +4133,7 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info, | |||
4133 | btrfs_super_bytes_used(sb)); | 4133 | btrfs_super_bytes_used(sb)); |
4134 | ret = -EINVAL; | 4134 | ret = -EINVAL; |
4135 | } | 4135 | } |
4136 | if (!is_power_of_2(btrfs_super_stripesize(sb)) || | 4136 | if (!is_power_of_2(btrfs_super_stripesize(sb))) { |
4137 | ((btrfs_super_stripesize(sb) != sectorsize) && | ||
4138 | (btrfs_super_stripesize(sb) != 4096))) { | ||
4139 | btrfs_err(fs_info, "invalid stripesize %u", | 4137 | btrfs_err(fs_info, "invalid stripesize %u", |
4140 | btrfs_super_stripesize(sb)); | 4138 | btrfs_super_stripesize(sb)); |
4141 | ret = -EINVAL; | 4139 | ret = -EINVAL; |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index c3a2900c6030..64eec2cec1d3 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -4694,12 +4694,12 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, | |||
4694 | 4694 | ||
4695 | if (type & BTRFS_BLOCK_GROUP_RAID5) { | 4695 | if (type & BTRFS_BLOCK_GROUP_RAID5) { |
4696 | raid_stripe_len = find_raid56_stripe_len(ndevs - 1, | 4696 | raid_stripe_len = find_raid56_stripe_len(ndevs - 1, |
4697 | btrfs_super_stripesize(info->super_copy)); | 4697 | extent_root->stripesize); |
4698 | data_stripes = num_stripes - 1; | 4698 | data_stripes = num_stripes - 1; |
4699 | } | 4699 | } |
4700 | if (type & BTRFS_BLOCK_GROUP_RAID6) { | 4700 | if (type & BTRFS_BLOCK_GROUP_RAID6) { |
4701 | raid_stripe_len = find_raid56_stripe_len(ndevs - 2, | 4701 | raid_stripe_len = find_raid56_stripe_len(ndevs - 2, |
4702 | btrfs_super_stripesize(info->super_copy)); | 4702 | extent_root->stripesize); |
4703 | data_stripes = num_stripes - 2; | 4703 | data_stripes = num_stripes - 2; |
4704 | } | 4704 | } |
4705 | 4705 | ||