diff mbox

[v2,2/3] Btrfs: raid56: simplify the parameter of nr_parity_stripes().

Message ID e6e28a35915d9bb147edb3b8767d27d10ab78ac3.1418203063.git.yangds.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yang Dongsheng Dec. 11, 2014, 8:31 a.m. UTC
We just need the type of a chunk to calculate the number of parity stripes,
but we have to pass a structure of lookup_map to it. This will prevent some
callers to use it where there is no a convenient lookup_map to be passed.

This patch replace the parameter of struct map_lookup * with a profile type.
Then we can use it more easily.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 fs/btrfs/raid56.h  | 8 ++++----
 fs/btrfs/volumes.c | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

Comments

Satoru Takeuchi Dec. 16, 2014, 6:21 a.m. UTC | #1
(2014/12/11 17:31), Dongsheng Yang wrote:
> We just need the type of a chunk to calculate the number of parity stripes,
> but we have to pass a structure of lookup_map to it. This will prevent some
> callers to use it where there is no a convenient lookup_map to be passed.
> 
> This patch replace the parameter of struct map_lookup * with a profile type.
> Then we can use it more easily.
> 
> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>

Although patch 1/3 and patch 3/3 is being discussed, at least
this patch (patch 2/3) looks fine to me.

Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>

Thanks,
Satoru

> ---
>   fs/btrfs/raid56.h  | 8 ++++----
>   fs/btrfs/volumes.c | 2 +-
>   2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/btrfs/raid56.h b/fs/btrfs/raid56.h
> index ea5d73b..68ac9d3 100644
> --- a/fs/btrfs/raid56.h
> +++ b/fs/btrfs/raid56.h
> @@ -19,11 +19,11 @@
>   
>   #ifndef __BTRFS_RAID56__
>   #define __BTRFS_RAID56__
> -static inline int nr_parity_stripes(struct map_lookup *map)
> +static inline int nr_parity_stripes(u64 type)
>   {
> -	if (map->type & BTRFS_BLOCK_GROUP_RAID5)
> +	if (type & BTRFS_BLOCK_GROUP_RAID5)
>   		return 1;
> -	else if (map->type & BTRFS_BLOCK_GROUP_RAID6)
> +	else if (type & BTRFS_BLOCK_GROUP_RAID6)
>   		return 2;
>   	else
>   		return 0;
> @@ -31,7 +31,7 @@ static inline int nr_parity_stripes(struct map_lookup *map)
>   
>   static inline int nr_data_stripes(struct map_lookup *map)
>   {
> -	return map->num_stripes - nr_parity_stripes(map);
> +	return map->num_stripes - nr_parity_stripes(map->type);
>   }
>   #define RAID5_P_STRIPE ((u64)-2)
>   #define RAID6_Q_STRIPE ((u64)-1)
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index f61278f..aa3a907 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -5174,7 +5174,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
>   
>   			/* RAID[56] write or recovery. Return all stripes */
>   			num_stripes = map->num_stripes;
> -			max_errors = nr_parity_stripes(map);
> +			max_errors = nr_parity_stripes(map->type);
>   
>   			raid_map = kmalloc_array(num_stripes, sizeof(u64),
>   					   GFP_NOFS);
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/raid56.h b/fs/btrfs/raid56.h
index ea5d73b..68ac9d3 100644
--- a/fs/btrfs/raid56.h
+++ b/fs/btrfs/raid56.h
@@ -19,11 +19,11 @@ 
 
 #ifndef __BTRFS_RAID56__
 #define __BTRFS_RAID56__
-static inline int nr_parity_stripes(struct map_lookup *map)
+static inline int nr_parity_stripes(u64 type)
 {
-	if (map->type & BTRFS_BLOCK_GROUP_RAID5)
+	if (type & BTRFS_BLOCK_GROUP_RAID5)
 		return 1;
-	else if (map->type & BTRFS_BLOCK_GROUP_RAID6)
+	else if (type & BTRFS_BLOCK_GROUP_RAID6)
 		return 2;
 	else
 		return 0;
@@ -31,7 +31,7 @@  static inline int nr_parity_stripes(struct map_lookup *map)
 
 static inline int nr_data_stripes(struct map_lookup *map)
 {
-	return map->num_stripes - nr_parity_stripes(map);
+	return map->num_stripes - nr_parity_stripes(map->type);
 }
 #define RAID5_P_STRIPE ((u64)-2)
 #define RAID6_Q_STRIPE ((u64)-1)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index f61278f..aa3a907 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -5174,7 +5174,7 @@  static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
 
 			/* RAID[56] write or recovery. Return all stripes */
 			num_stripes = map->num_stripes;
-			max_errors = nr_parity_stripes(map);
+			max_errors = nr_parity_stripes(map->type);
 
 			raid_map = kmalloc_array(num_stripes, sizeof(u64),
 					   GFP_NOFS);