From patchwork Mon Sep 11 06:36:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 9946697 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 1A948603F3 for ; Mon, 11 Sep 2017 06:36:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E89C26B41 for ; Mon, 11 Sep 2017 06:36:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 033B728AE7; Mon, 11 Sep 2017 06:36:27 +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.4 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM 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 73CFF26B41 for ; Mon, 11 Sep 2017 06:36:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750922AbdIKGgX (ORCPT ); Mon, 11 Sep 2017 02:36:23 -0400 Received: from mout.gmx.net ([212.227.15.19]:57902 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750878AbdIKGgW (ORCPT ); Mon, 11 Sep 2017 02:36:22 -0400 Received: from localhost.localdomain ([45.32.39.184]) by mail.gmx.com (mrgmx002 [212.227.17.184]) with ESMTPSA (Nemesis) id 0MdaCy-1e5fOI0Qzk-00PJ6o; Mon, 11 Sep 2017 08:36:18 +0200 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH v2 1/7] btrfs-progs: Refactor find_next_chunk() to get rid of parameter root and objectid Date: Mon, 11 Sep 2017 15:36:06 +0900 Message-Id: <20170911063612.32114-2-quwenruo.btrfs@gmx.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170911063612.32114-1-quwenruo.btrfs@gmx.com> References: <20170911063612.32114-1-quwenruo.btrfs@gmx.com> X-Provags-ID: V03:K0:MjPUs1y1jXiMBGEJH9TO+OBc7jCZi3NpE51lAXzZIUKlsA4Cmx+ yGTyVF9vZ0X7JmlXCkxmBRj0x+SuehXf5+/crBjXu7MiOvTTzqQyllenhMTi+FhXlZwlDRP TlD9iba85rqdROKImkvPiaFaSt1TgdvKqLZT1ghmIn5L+wMmgrMR9EggolwibENhKlWf1+A AcJ+QgDBvF35bsZ1KvVVQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:ISY+8AASG+E=:/5KI0/Sg5gFXI3d7gVyVee fJS2GErzmAxQpYkeCYIeXUuYC/BRMD5RPSpHxIwl5VbatXczFQR6n1B9dcBQQAOIXLlBrGSzK lmjIT65uYSpgryhfmrR4OskUynjse8UvbBqdNOHF6KYSjjD5uCNrON7ULSxgyY7XE72Yf7vdB DrPQdR69VDOnPBkNapo3+MdQhhLNCOzkLDiDS24k8bxlyeEhUJeEjo4bXHzuGJc4yPuo2Actl JIP2LpYggEelaIrUTBxjtpu6L6YecKSbsaRCa+yUUr1WoQLmO0rvQ8zVspkyyXH1gSGXIweqH ZnCwIECGGXARZFBaWPEJjGBAcEYf+vU/CeApWb2nsM0tVdOm/cQJzjCRYVtaKCR3H9hGsNpX6 v2eY49r24+OHB3Adcvoap7cMfNC4Ngz7R/nAvPZT2+XlA3WJXKrGziWVM+TmbFBeBVI/l5xSv cy0Cbjh7PXR9nS92HMLHphetuyQ/mgXT2RBweCVe/mv77UasWyhI1l4mpzGS7AHJccH8X+DIq w+MDDEReqSLAsIZtH3f3Mm8JI8YiZZt3gQ54crh5+EPruaDaR48lkdmNas7xmKCnUbNc59Uzc dcJPykB1TM28iBNG4Rz/z81eJDZnfLxbVtQiRi2qAFORmDr6/OEvxrkXOar/vx/ui5BS/3cQ4 OLuXQNuhUdj7JGPfe1ZxFGVtBrG0FxlWdhXxjsfAahVqOqa70gyZlotJ5QEzfSBubFssd8W3U outZD2cY9uY09UrlXLfcfbpyHX5uUUrCmYQ3XNKStzPErsbMwgCaYcYDLMMiWcHS0xw+Hj9sw 1TXMsNIonmvC+M4tFxBtm8dhEQLyg== 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;