From patchwork Thu May 18 03:38:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9732445 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 49D596020B for ; Thu, 18 May 2017 03:40:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D0CE28824 for ; Thu, 18 May 2017 03:40:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1187E28826; Thu, 18 May 2017 03:40:06 +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 9D88E28813 for ; Thu, 18 May 2017 03:40:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932250AbdERDkD (ORCPT ); Wed, 17 May 2017 23:40:03 -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 S932097AbdERDjW (ORCPT ); Wed, 17 May 2017 23:39:22 -0400 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="18996758" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 18 May 2017 11:39:10 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id C943D47E64DE; Thu, 18 May 2017 11:39:10 +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:10 +0800 From: Qu Wenruo To: , Subject: [PATCH 18/32] btrfs-progs: Refactor nodesize users in cmds-inspect-tree-stats.c Date: Thu, 18 May 2017 11:38:43 +0800 Message-ID: <20170518033857.15002-19-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: C943D47E64DE.AF91E 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 --- cmds-inspect-tree-stats.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/cmds-inspect-tree-stats.c b/cmds-inspect-tree-stats.c index 58dd29e1..ecb33ce2 100644 --- a/cmds-inspect-tree-stats.c +++ b/cmds-inspect-tree-stats.c @@ -105,7 +105,7 @@ static int walk_leaf(struct btrfs_root *root, struct btrfs_path *path, struct btrfs_key found_key; int i; - stat->total_bytes += root->nodesize; + stat->total_bytes += root->fs_info->nodesize; stat->total_leaves++; if (!find_inline) @@ -137,12 +137,13 @@ static int walk_nodes(struct btrfs_root *root, struct btrfs_path *path, struct root_stats *stat, int level, int find_inline) { struct extent_buffer *b = path->nodes[level]; + u32 nodesize = root->fs_info->nodesize; u64 last_block; - u64 cluster_size = root->nodesize; + u64 cluster_size = nodesize; int i; int ret = 0; - stat->total_bytes += root->nodesize; + stat->total_bytes += nodesize; stat->total_nodes++; last_block = btrfs_header_bytenr(b); @@ -153,7 +154,7 @@ static int walk_nodes(struct btrfs_root *root, struct btrfs_path *path, path->slots[level] = i; if ((level - 1) > 0 || find_inline) { tmp = read_tree_block(root, cur_blocknr, - root->nodesize, + nodesize, btrfs_node_ptr_generation(b, i)); if (!extent_buffer_uptodate(tmp)) { error("failed to read blocknr %llu", @@ -167,9 +168,9 @@ static int walk_nodes(struct btrfs_root *root, struct btrfs_path *path, find_inline); else ret = walk_leaf(root, path, stat, find_inline); - if (last_block + root->nodesize != cur_blocknr) { + if (last_block + nodesize != cur_blocknr) { u64 distance = calc_distance(last_block + - root->nodesize, + nodesize, cur_blocknr); stat->total_seeks++; stat->total_seek_len += distance; @@ -186,7 +187,7 @@ static int walk_nodes(struct btrfs_root *root, struct btrfs_path *path, stat->forward_seeks++; else stat->backward_seeks++; - if (cluster_size != root->nodesize) { + if (cluster_size != nodesize) { stat->total_cluster_size += cluster_size; stat->total_clusters++; if (cluster_size < stat->min_cluster_size) @@ -194,9 +195,9 @@ static int walk_nodes(struct btrfs_root *root, struct btrfs_path *path, if (cluster_size > stat->max_cluster_size) stat->max_cluster_size = cluster_size; } - cluster_size = root->nodesize; + cluster_size = nodesize; } else { - cluster_size += root->nodesize; + cluster_size += nodesize; } last_block = cur_blocknr; if (cur_blocknr < stat->lowest_bytenr) @@ -334,7 +335,7 @@ static int calc_root_size(struct btrfs_root *tree_root, struct btrfs_key *key, stat.lowest_bytenr = btrfs_header_bytenr(root->node); stat.highest_bytenr = stat.lowest_bytenr; stat.min_cluster_size = (u64)-1; - stat.max_cluster_size = root->nodesize; + stat.max_cluster_size = root->fs_info->nodesize; path.nodes[level] = root->node; if (gettimeofday(&start, NULL)) { error("cannot get time: %s", strerror(errno));