From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from cn.fujitsu.com ([59.151.112.132]:37096 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751420AbbAEKKF (ORCPT ); Mon, 5 Jan 2015 05:10:05 -0500 From: Dongsheng Yang To: , , CC: , Dongsheng Yang Subject: [PATCH v2 2/3] Btrfs: raid56: simplify the parameter of nr_parity_stripes(). Date: Mon, 5 Jan 2015 18:07:04 +0800 Message-ID: <1420452425-7874-2-git-send-email-yangds.fnst@cn.fujitsu.com> In-Reply-To: <1420452425-7874-1-git-send-email-yangds.fnst@cn.fujitsu.com> References: <54AA5FB0.5020102@cn.fujitsu.com> <1420452425-7874-1-git-send-email-yangds.fnst@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-btrfs-owner@vger.kernel.org List-ID: 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 Reviewed-by: Satoru Takeuchi --- 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 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); -- 1.8.4.2