From patchwork Thu Dec 11 08:31:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Dongsheng X-Patchwork-Id: 5474671 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D28E49F2E8 for ; Thu, 11 Dec 2014 08:34:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C56F32017D for ; Thu, 11 Dec 2014 08:34:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AF65D20173 for ; Thu, 11 Dec 2014 08:34:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964994AbaLKIeP (ORCPT ); Thu, 11 Dec 2014 03:34:15 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:2241 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S964989AbaLKIeL (ORCPT ); Thu, 11 Dec 2014 03:34:11 -0500 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="44863345" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 11 Dec 2014 16:30:52 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id sBB8Xmb3019962; Thu, 11 Dec 2014 16:33:48 +0800 Received: from yds-PC.g08.fujitsu.local (10.167.226.66) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 11 Dec 2014 16:34:10 +0800 From: Dongsheng Yang To: , <1i5t5.duncan@cox.net>, , CC: , Dongsheng Yang Subject: [PATCH v2 2/3] Btrfs: raid56: simplify the parameter of nr_parity_stripes(). Date: Thu, 11 Dec 2014 16:31:24 +0800 Message-ID: X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <36be817396956bffe981a69ea0b8796c44153fa5.1418203063.git.yangds.fnst@cn.fujitsu.com> References: <36be817396956bffe981a69ea0b8796c44153fa5.1418203063.git.yangds.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.66] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 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);