From patchwork Thu Jun 27 09:39:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 2790911 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6211CC0AB1 for ; Thu, 27 Jun 2013 09:39:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1A72F202AB for ; Thu, 27 Jun 2013 09:39:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 82CBE202A7 for ; Thu, 27 Jun 2013 09:38:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752781Ab3F0Ji4 (ORCPT ); Thu, 27 Jun 2013 05:38:56 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:30430 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752053Ab3F0Jiz (ORCPT ); Thu, 27 Jun 2013 05:38:55 -0400 X-IronPort-AV: E=Sophos;i="4.87,950,1363104000"; d="scan'208";a="7703008" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 27 Jun 2013 17:35:58 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r5R9crg0010049 for ; Thu, 27 Jun 2013 17:38:53 +0800 Received: from localhost.localdomain ([10.167.226.30]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013062717373580-2531826 ; Thu, 27 Jun 2013 17:37:35 +0800 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: quwenruo@cn.fujitsu.com Subject: [PATCH] btrfs: Cleanup unneeded extra variant in btrfs_read_sys_array Date: Thu, 27 Jun 2013 17:39:35 +0800 Message-Id: <1372325975-7004-1-git-send-email-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/06/27 17:37:35, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/06/27 17:37:36, Serialize complete at 2013/06/27 17:37:36 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 The btrfs_read_sys_array function uses 3 variants to read data from super block. But the three variants are related to each other, so the patch removes unneeded extra variants and make code a little simpler. Signed-off-by: Qu Wenruo Reviewed-by: Miao Xie --- fs/btrfs/volumes.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 2494008..9d7cf92 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -5613,12 +5613,10 @@ int btrfs_read_sys_array(struct btrfs_root *root) struct btrfs_disk_key *disk_key; struct btrfs_chunk *chunk; u8 *ptr; - unsigned long sb_ptr; + u8 *array_end; int ret = 0; u32 num_stripes; - u32 array_size; u32 len = 0; - u32 cur; struct btrfs_key key; sb = btrfs_find_create_tree_block(root, BTRFS_SUPER_INFO_OFFSET, @@ -5643,22 +5641,19 @@ int btrfs_read_sys_array(struct btrfs_root *root) SetPageUptodate(sb->pages[0]); write_extent_buffer(sb, super_copy, 0, BTRFS_SUPER_INFO_SIZE); - array_size = btrfs_super_sys_array_size(super_copy); + array_end = ((u8 *)super_copy->sys_chunk_array) + + btrfs_super_sys_array_size(super_copy); ptr = super_copy->sys_chunk_array; - sb_ptr = offsetof(struct btrfs_super_block, sys_chunk_array); - cur = 0; - while (cur < array_size) { + while (ptr < array_end) { disk_key = (struct btrfs_disk_key *)ptr; btrfs_disk_key_to_cpu(&key, disk_key); len = sizeof(*disk_key); ptr += len; - sb_ptr += len; - cur += len; if (key.type == BTRFS_CHUNK_ITEM_KEY) { - chunk = (struct btrfs_chunk *)sb_ptr; + chunk = (struct btrfs_chunk *)(ptr - (u8 *)super_copy); ret = read_one_chunk(root, &key, sb, chunk); if (ret) break; @@ -5669,8 +5664,6 @@ int btrfs_read_sys_array(struct btrfs_root *root) break; } ptr += len; - sb_ptr += len; - cur += len; } free_extent_buffer(sb); return ret;