From patchwork Thu May 18 03:38:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9732441 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 33B2D6020B for ; Thu, 18 May 2017 03:40:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1462628808 for ; Thu, 18 May 2017 03:40:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0683C28813; Thu, 18 May 2017 03:40:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A017028808 for ; Thu, 18 May 2017 03:40:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932203AbdERDj0 (ORCPT ); Wed, 17 May 2017 23:39:26 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:43366 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S932185AbdERDjX (ORCPT ); Wed, 17 May 2017 23:39:23 -0400 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="18996768" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 18 May 2017 11:39:16 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id CDFD047C6542; Thu, 18 May 2017 11:39:13 +0800 (CST) Received: from localhost.localdomain (10.167.226.34) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 18 May 2017 11:39:13 +0800 From: Qu Wenruo To: , Subject: [PATCH 23/32] btrfs-progs: Refactor sectorsize users in volumes.c Date: Thu, 18 May 2017 11:38:48 +0800 Message-ID: <20170518033857.15002-24-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170518033857.15002-1-quwenruo@cn.fujitsu.com> References: <20170518033857.15002-1-quwenruo@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.34] X-yoursite-MailScanner-ID: CDFD047C6542.A0609 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: quwenruo@cn.fujitsu.com Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Qu Wenruo --- volumes.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/volumes.c b/volumes.c index b350e259..3fc5a624 100644 --- a/volumes.c +++ b/volumes.c @@ -1060,9 +1060,9 @@ again: btrfs_set_stack_chunk_num_stripes(chunk, num_stripes); btrfs_set_stack_chunk_io_align(chunk, stripe_len); btrfs_set_stack_chunk_io_width(chunk, stripe_len); - btrfs_set_stack_chunk_sector_size(chunk, extent_root->sectorsize); + btrfs_set_stack_chunk_sector_size(chunk, info->sectorsize); btrfs_set_stack_chunk_sub_stripes(chunk, sub_stripes); - map->sector_size = extent_root->sectorsize; + map->sector_size = info->sectorsize; map->stripe_len = stripe_len; map->io_align = stripe_len; map->io_width = stripe_len; @@ -1123,7 +1123,7 @@ int btrfs_alloc_data_chunk(struct btrfs_trans_handle *trans, key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID; key.type = BTRFS_CHUNK_ITEM_KEY; if (convert) { - if (*start != round_down(*start, extent_root->sectorsize)) { + if (*start != round_down(*start, info->sectorsize)) { error("DATA chunk start not sectorsize aligned: %llu", (unsigned long long)*start); return -EINVAL; @@ -1188,9 +1188,9 @@ int btrfs_alloc_data_chunk(struct btrfs_trans_handle *trans, btrfs_set_stack_chunk_num_stripes(chunk, num_stripes); btrfs_set_stack_chunk_io_align(chunk, stripe_len); btrfs_set_stack_chunk_io_width(chunk, stripe_len); - btrfs_set_stack_chunk_sector_size(chunk, extent_root->sectorsize); + btrfs_set_stack_chunk_sector_size(chunk, info->sectorsize); btrfs_set_stack_chunk_sub_stripes(chunk, sub_stripes); - map->sector_size = extent_root->sectorsize; + map->sector_size = info->sectorsize; map->stripe_len = stripe_len; map->io_align = stripe_len; map->io_width = stripe_len; @@ -1685,6 +1685,7 @@ int btrfs_check_chunk_valid(struct btrfs_root *root, u16 num_stripes; u16 sub_stripes; u64 type; + u32 sectorsize = root->fs_info->sectorsize; length = btrfs_chunk_length(leaf, chunk); stripe_len = btrfs_chunk_stripe_len(leaf, chunk); @@ -1695,16 +1696,16 @@ int btrfs_check_chunk_valid(struct btrfs_root *root, /* * These valid checks may be insufficient to cover every corner cases. */ - if (!IS_ALIGNED(logical, root->sectorsize)) { + if (!IS_ALIGNED(logical, sectorsize)) { error("invalid chunk logical %llu", logical); return -EIO; } - if (btrfs_chunk_sector_size(leaf, chunk) != root->sectorsize) { + if (btrfs_chunk_sector_size(leaf, chunk) != sectorsize) { error("invalid chunk sectorsize %llu", (unsigned long long)btrfs_chunk_sector_size(leaf, chunk)); return -EIO; } - if (!length || !IS_ALIGNED(length, root->sectorsize)) { + if (!length || !IS_ALIGNED(length, sectorsize)) { error("invalid chunk length %llu", length); return -EIO; }