From patchwork Thu May 18 03:38:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9732431 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 9AA086020B for ; Thu, 18 May 2017 03:39:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B48B287A1 for ; Thu, 18 May 2017 03:39:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 702BA28802; Thu, 18 May 2017 03:39:45 +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 170E5287A1 for ; Thu, 18 May 2017 03:39:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932237AbdERDjn (ORCPT ); Wed, 17 May 2017 23:39:43 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:22220 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S932212AbdERDjb (ORCPT ); Wed, 17 May 2017 23:39:31 -0400 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="18996770" 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 34A0F47E64DD; Thu, 18 May 2017 11:39:15 +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:14 +0800 From: Qu Wenruo To: , Subject: [PATCH 25/32] btrfs-progs: Refactor sectorsize in convert/source-fs.c Date: Thu, 18 May 2017 11:38:50 +0800 Message-ID: <20170518033857.15002-26-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: 34A0F47E64DD.AFBC1 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 --- convert/source-fs.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/convert/source-fs.c b/convert/source-fs.c index 80e4e418..59e36095 100644 --- a/convert/source-fs.c +++ b/convert/source-fs.c @@ -68,9 +68,10 @@ int block_iterate_proc(u64 disk_block, u64 file_block, int do_barrier; struct btrfs_root *root = idata->root; struct btrfs_block_group_cache *cache; - u64 bytenr = disk_block * root->sectorsize; + u32 sectorsize = root->fs_info->sectorsize; + u64 bytenr = disk_block * sectorsize; - sb_region = intersect_with_sb(bytenr, root->sectorsize); + sb_region = intersect_with_sb(bytenr, sectorsize); do_barrier = sb_region || disk_block >= idata->boundary; if ((idata->num_blocks > 0 && do_barrier) || (file_block > idata->first_block + idata->num_blocks) || @@ -102,7 +103,7 @@ int block_iterate_proc(u64 disk_block, u64 file_block, idata->first_block = file_block; idata->disk_block = disk_block; - idata->boundary = bytenr / root->sectorsize; + idata->boundary = bytenr / sectorsize; } idata->num_blocks++; fail: @@ -195,9 +196,10 @@ int record_file_blocks(struct blk_iterate_data *data, struct btrfs_root *root = data->root; struct btrfs_root *convert_root = data->convert_root; struct btrfs_path path; - u64 file_pos = file_block * root->sectorsize; - u64 old_disk_bytenr = disk_block * root->sectorsize; - u64 num_bytes = num_blocks * root->sectorsize; + u32 sectorsize = root->fs_info->sectorsize; + u64 file_pos = file_block * sectorsize; + u64 old_disk_bytenr = disk_block * sectorsize; + u64 num_bytes = num_blocks * sectorsize; u64 cur_off = old_disk_bytenr; /* Hole, pass it to record_file_extent directly */