diff mbox

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

Message ID 1420452425-7874-2-git-send-email-yangds.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Yang Dongsheng Jan. 5, 2015, 10:07 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>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
---
 fs/btrfs/raid56.h  | 8 ++++----
 fs/btrfs/volumes.c | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/fs/btrfs/raid56.h b/fs/btrfs/raid56.h
index 31d4a15..d2f5690 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 50c5a87..fedf76e 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -5181,7 +5181,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);