diff mbox series

[5/6] btrfs: Read stripe len directly in btrfs_rmap_block

Message ID 20191119120555.6465-6-nborisov@suse.com (mailing list archive)
State New, archived
Headers show
Series Cleanup super block stripe exclusion code | expand

Commit Message

Nikolay Borisov Nov. 19, 2019, 12:05 p.m. UTC
extent_map::orig_block_len contains the size of a physical stripe when
it's used to describe block groups. So get the size directly in
btrfs_rmap_block rather than open-coding the calculations. No
functional changes.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/block-group.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

Comments

David Sterba Jan. 14, 2020, 4:54 p.m. UTC | #1
On Tue, Nov 19, 2019 at 02:05:54PM +0200, Nikolay Borisov wrote:
> extent_map::orig_block_len contains the size of a physical stripe when
> it's used to describe block groups. So get the size directly in
> btrfs_rmap_block rather than open-coding the calculations. No
> functional changes.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>  fs/btrfs/block-group.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
> index c3b1f304bc70..2ab4d9cb598a 100644
> --- a/fs/btrfs/block-group.c
> +++ b/fs/btrfs/block-group.c
> @@ -1546,17 +1546,12 @@ int btrfs_rmap_block(struct btrfs_fs_info *fs_info, u64 chunk_start,
>  		return -EIO;
>  
>  	map = em->map_lookup;
> -	data_stripe_length = em->len;
> +	data_stripe_length = em->orig_block_len;
>  	io_stripe_size = map->stripe_len;
>  
> -	if (map->type & BTRFS_BLOCK_GROUP_RAID10)
> -		data_stripe_length = div_u64(data_stripe_length, map->num_stripes / map->sub_stripes);
> -	else if (map->type & BTRFS_BLOCK_GROUP_RAID0)
> -		data_stripe_length = div_u64(data_stripe_length, map->num_stripes);
> -	else if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
> -		data_stripe_length = div_u64(data_stripe_length, nr_data_stripes(map));
> +	/* For raid5/6 adjust to a full IO stripe length */
> +	if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK)
>  		io_stripe_size = map->stripe_len * nr_data_stripes(map);

I'm not convinced this is 'no functional change' so will merge only
patches 1-4 for now as I have reviewed them and want to add them to
misc-next before the 5.6 freeze.
Nikolay Borisov Jan. 15, 2020, 10:52 a.m. UTC | #2
On 14.01.20 г. 18:54 ч., David Sterba wrote:
> On Tue, Nov 19, 2019 at 02:05:54PM +0200, Nikolay Borisov wrote:
>> extent_map::orig_block_len contains the size of a physical stripe when
>> it's used to describe block groups. So get the size directly in
>> btrfs_rmap_block rather than open-coding the calculations. No
>> functional changes.
>>
>> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
>> ---
>>  fs/btrfs/block-group.c | 11 +++--------
>>  1 file changed, 3 insertions(+), 8 deletions(-)
>>
>> diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
>> index c3b1f304bc70..2ab4d9cb598a 100644
>> --- a/fs/btrfs/block-group.c
>> +++ b/fs/btrfs/block-group.c
>> @@ -1546,17 +1546,12 @@ int btrfs_rmap_block(struct btrfs_fs_info *fs_info, u64 chunk_start,
>>  		return -EIO;
>>  
>>  	map = em->map_lookup;
>> -	data_stripe_length = em->len;
>> +	data_stripe_length = em->orig_block_len;
>>  	io_stripe_size = map->stripe_len;
>>  
>> -	if (map->type & BTRFS_BLOCK_GROUP_RAID10)
>> -		data_stripe_length = div_u64(data_stripe_length, map->num_stripes / map->sub_stripes);
>> -	else if (map->type & BTRFS_BLOCK_GROUP_RAID0)
>> -		data_stripe_length = div_u64(data_stripe_length, map->num_stripes);
>> -	else if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
>> -		data_stripe_length = div_u64(data_stripe_length, nr_data_stripes(map));
>> +	/* For raid5/6 adjust to a full IO stripe length */
>> +	if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK)
>>  		io_stripe_size = map->stripe_len * nr_data_stripes(map);
> 
> I'm not convinced this is 'no functional change' so will merge only
> patches 1-4 for now as I have reviewed them and want to add them to
> misc-next before the 5.6 freeze.
> 

THe easiest way to convince yourself is to work out the maths happening
in __btrfs_alloc_chunk, since orig_block_len for chunks is set there.
diff mbox series

Patch

diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index c3b1f304bc70..2ab4d9cb598a 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -1546,17 +1546,12 @@  int btrfs_rmap_block(struct btrfs_fs_info *fs_info, u64 chunk_start,
 		return -EIO;
 
 	map = em->map_lookup;
-	data_stripe_length = em->len;
+	data_stripe_length = em->orig_block_len;
 	io_stripe_size = map->stripe_len;
 
-	if (map->type & BTRFS_BLOCK_GROUP_RAID10)
-		data_stripe_length = div_u64(data_stripe_length, map->num_stripes / map->sub_stripes);
-	else if (map->type & BTRFS_BLOCK_GROUP_RAID0)
-		data_stripe_length = div_u64(data_stripe_length, map->num_stripes);
-	else if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
-		data_stripe_length = div_u64(data_stripe_length, nr_data_stripes(map));
+	/* For raid5/6 adjust to a full IO stripe length */
+	if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK)
 		io_stripe_size = map->stripe_len * nr_data_stripes(map);
-	}
 
 	buf = kcalloc(map->num_stripes, sizeof(u64), GFP_NOFS);
 	if (!buf) {