From patchwork Thu May 18 03:38:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9732423 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 BB88C6020B for ; Thu, 18 May 2017 03:39:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BEC828800 for ; Thu, 18 May 2017 03:39:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90CD328802; Thu, 18 May 2017 03:39:39 +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 4091528800 for ; Thu, 18 May 2017 03:39:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932226AbdERDjg (ORCPT ); Wed, 17 May 2017 23:39:36 -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 S932200AbdERDj1 (ORCPT ); Wed, 17 May 2017 23:39:27 -0400 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="18996771" 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 A581347C6528; Thu, 18 May 2017 11:39:12 +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:11 +0800 From: Qu Wenruo To: , Subject: [PATCH 21/32] btrfs-progs: Refactor sectorsize users in free-space-cache.c Date: Thu, 18 May 2017 11:38:46 +0800 Message-ID: <20170518033857.15002-22-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: A581347C6528.AD52D 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 --- free-space-cache.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/free-space-cache.c b/free-space-cache.c index a4196eb1..4bf4a6cb 100644 --- a/free-space-cache.c +++ b/free-space-cache.c @@ -54,7 +54,8 @@ static int io_ctl_init(struct io_ctl *io_ctl, u64 size, u64 ino, struct btrfs_root *root) { memset(io_ctl, 0, sizeof(struct io_ctl)); - io_ctl->num_pages = (size + root->sectorsize - 1) / root->sectorsize; + io_ctl->num_pages = (size + root->fs_info->sectorsize - 1) / + root->fs_info->sectorsize; io_ctl->buffer = kzalloc(size, GFP_NOFS); if (!io_ctl->buffer) return -ENOMEM; @@ -81,11 +82,12 @@ static void io_ctl_unmap_page(struct io_ctl *io_ctl) static void io_ctl_map_page(struct io_ctl *io_ctl, int clear) { BUG_ON(io_ctl->index >= io_ctl->num_pages); - io_ctl->cur = io_ctl->buffer + (io_ctl->index++ * io_ctl->root->sectorsize); + io_ctl->cur = io_ctl->buffer + (io_ctl->index++ * + io_ctl->root->fs_info->sectorsize); io_ctl->orig = io_ctl->cur; - io_ctl->size = io_ctl->root->sectorsize; + io_ctl->size = io_ctl->root->fs_info->sectorsize; if (clear) - memset(io_ctl->cur, 0, io_ctl->root->sectorsize); + memset(io_ctl->cur, 0, io_ctl->root->fs_info->sectorsize); } static void io_ctl_drop_pages(struct io_ctl *io_ctl) @@ -210,7 +212,8 @@ static int io_ctl_check_crc(struct io_ctl *io_ctl, int index) val = *tmp; io_ctl_map_page(io_ctl, 0); - crc = crc32c(crc, io_ctl->orig + offset, io_ctl->root->sectorsize - offset); + crc = crc32c(crc, io_ctl->orig + offset, + io_ctl->root->fs_info->sectorsize - offset); btrfs_csum_final(crc, (u8 *)&crc); if (val != crc) { printk("btrfs: csum mismatch on free space cache\n"); @@ -257,7 +260,7 @@ static int io_ctl_read_bitmap(struct io_ctl *io_ctl, if (ret) return ret; - memcpy(entry->bitmap, io_ctl->cur, io_ctl->root->sectorsize); + memcpy(entry->bitmap, io_ctl->cur, io_ctl->root->fs_info->sectorsize); io_ctl_unmap_page(io_ctl); return 0;