From patchwork Mon Sep 18 07:21:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9955591 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 7213A6056A for ; Mon, 18 Sep 2017 07:22:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 631F028A52 for ; Mon, 18 Sep 2017 07:22:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57DD528BAC; Mon, 18 Sep 2017 07:22:10 +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,FREEMAIL_FROM, 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 3AFB728A50 for ; Mon, 18 Sep 2017 07:22:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750898AbdIRHVt (ORCPT ); Mon, 18 Sep 2017 03:21:49 -0400 Received: from mout.gmx.net ([212.227.17.21]:63538 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750757AbdIRHVs (ORCPT ); Mon, 18 Sep 2017 03:21:48 -0400 Received: from localhost.localdomain ([45.32.39.184]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0M4kfR-1dUKPN2atB-00yuSR; Mon, 18 Sep 2017 09:21:45 +0200 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH v3 01/14] btrfs-progs: Refactor find_next_chunk() to get rid of parameter root and objectid Date: Mon, 18 Sep 2017 16:21:26 +0900 Message-Id: <20170918072139.6300-2-quwenruo.btrfs@gmx.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170918072139.6300-1-quwenruo.btrfs@gmx.com> References: <20170918072139.6300-1-quwenruo.btrfs@gmx.com> X-Provags-ID: V03:K0:YgyH+iqp8VGWvrPuba4nKoC9Wj7wJO9cN6mFqXnxx5Ndnhs3/nP hU/XV6eAK+CeIJ71RLgMCt2lbR/IbNjclwg8vMZKqBz+SjaR1S3jMvzZ/BEeURrDCx4PY3V QV/OqyNAsR7XC+Fh4R35bwFmMvgCpIsM66wib0mFoUEe6f5g5rbEzL1W1t/tgWR4VeM5JWO qSc6JXFPhKWMaURW3c/6g== X-UI-Out-Filterresults: notjunk:1; V01:K0:Eu1juaclUK4=:xgX9o0AK5qOwnfLU3SgxMN WiFwomwb2IxQNvnTgT9mpC2ObHVgDi4E8fyoT5aD4a3THh9xOXMcd9yBXapctFrbmjPsX+Fb2 TBWTenT/96FPL5He1uNmfcXYDuR88QBEc2/t/ZmVhYrz5szsjzby9X6zYjhfrTHIN2icihoNx OGUXnpdKATjyKv1w1m5SOWnoDOmbe6H34ZgVE8BsKapuitj50sh0i9n0Z6CLNoe3YxbuWal0F mbveEZ4J8g0N+ybZ2uw78oBpokeg0/WbdouiZb2uUATMeXpSMl4B66YWo/aqcpm3EoR89PIik ZKZ8Z04w2fmF5RvoKG6McBQORzpAm09pEo62PgnQjoNEuY+ocaxGOOck4jbGplX9MmYkbn0dg pg1Nn+J6maFrz7KFHcq2iWXskcwu4NDDVqt0R+piOfCOBeU1F9uQ5aPzAOE9SUV7YYfNCQ5VD rT3J6HHv/1au13s65KwOMMZNTOo+pDu9SagJ29yndLCtJEG2fxCapntnHyRk2kXXLXWvfZuWG GJTRtGDZqirelnc4nJ7XoNNNzmD6/m8hRB+QS3mkW3DdUum8Sg+ZLuAzGR/9Yc0cMMC6Y0hiQ kYsJyW2YYy7Pl9RkKkramRcsBaa0eE8TqceEr/gz8paJUt699te04pjkzK3/3z6nTjs2R8dGy dXM259IU18T6ntlI9tiY5SYTYU0Gac3AugjBkRQpssPlqXd03GAsPT8lUDAqigtqI51CrxW9w 3dIL6TumF4IlRzH23C1CdlTTK4qyOVhFnrXPkEh/rCX4aeTK3Sk3CLGAjd2HXVqBgkoQwp8sM q7McNJySsQeC6M4edskz5TXMJrnVA== 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 Function find_next_chunk() is used to find next chunk start position, which should only do search on chunk tree and objectid is fixed to BTRFS_FIRST_CHUNK_TREE_OBJECTID. So refactor the parameter list to get rid of @root, which should be get from fs_info->chunk_root, and @objectid, which is fixed to BTRFS_FIRST_CHUNK_TREE_OBJECTID. Signed-off-by: Qu Wenruo --- volumes.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/volumes.c b/volumes.c index 2ae2d1bb..2209e5a9 100644 --- a/volumes.c +++ b/volumes.c @@ -505,8 +505,9 @@ err: return ret; } -static int find_next_chunk(struct btrfs_root *root, u64 objectid, u64 *offset) +static int find_next_chunk(struct btrfs_fs_info *fs_info, u64 *offset) { + struct btrfs_root *root = fs_info->chunk_root; struct btrfs_path *path; int ret; struct btrfs_key key; @@ -517,7 +518,7 @@ static int find_next_chunk(struct btrfs_root *root, u64 objectid, u64 *offset) if (!path) return -ENOMEM; - key.objectid = objectid; + key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID; key.offset = (u64)-1; key.type = BTRFS_CHUNK_ITEM_KEY; @@ -533,7 +534,7 @@ static int find_next_chunk(struct btrfs_root *root, u64 objectid, u64 *offset) } else { btrfs_item_key_to_cpu(path->nodes[0], &found_key, path->slots[0]); - if (found_key.objectid != objectid) + if (found_key.objectid != BTRFS_FIRST_CHUNK_TREE_OBJECTID) *offset = 0; else { chunk = btrfs_item_ptr(path->nodes[0], path->slots[0], @@ -995,8 +996,7 @@ again: } return -ENOSPC; } - ret = find_next_chunk(chunk_root, BTRFS_FIRST_CHUNK_TREE_OBJECTID, - &offset); + ret = find_next_chunk(info, &offset); if (ret) return ret; key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID; @@ -1129,9 +1129,7 @@ int btrfs_alloc_data_chunk(struct btrfs_trans_handle *trans, } else { u64 tmp; - ret = find_next_chunk(chunk_root, - BTRFS_FIRST_CHUNK_TREE_OBJECTID, - &tmp); + ret = find_next_chunk(info, &tmp); key.offset = tmp; if (ret) return ret;