Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2986361pxb; Mon, 18 Apr 2022 12:43:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuwJX0bKid6TtWJ7sBvw5GjzMYu5i2bJYx4VzEXm7KQ+dHpwukgDLhJwL0/xVnzw0xM+c/ X-Received: by 2002:a17:907:7da8:b0:6ef:a5c8:7de1 with SMTP id oz40-20020a1709077da800b006efa5c87de1mr5583515ejc.171.1650311039522; Mon, 18 Apr 2022 12:43:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650311039; cv=none; d=google.com; s=arc-20160816; b=Z8hgSqTph4oVqgl0tH1klkwvHANzT4WqnsU04ez7+PO0XI3lJM3xQq9bJ5RfI6+uFH t2KNGQKG0ZPa10a8lhrNA6FZyLqAHWdfgDuZXhaP7XadCpQ0m7w9Lxl7kjT5gUxWA7jg 2AM1O+11E0SLq02oREQiRaw2E8IrgBFRht5h7rHyC0wY+NtTSwlqE8pzH38i1rKNKbur HWnSa9rh6uub3rTTiG2eaaBaP1Bx+JYg6/Xw1iJwqTDQcHNE9JrZWksqMlnpJl1uwcR+ rD8pyVAhPQnqSmIWvVu95oV5Vq0C+WzJSc981IRekKcCOgZa/heFX2S77gUaE22tea37 R7bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=v27+foOhO99IsqR3e4byu17odP+R50EM+mOEln8irpg=; b=orLKFoC6xHM0uzFbRLUrp5yTm9Ah4p6USJyjIdeYzpYxSJrC/hb1x3aSwf40+pa4sN V9+RDc8HRNbxk/mU754dCMiWu+wabSV7ptrMe7kOLRQP6ZKaAnpczUbEO4MEDSKVoHDw V3WDDUwTLzBAvYEV7QpLhF9JtM1iSLALRZYxm4LYdNprvqceYHJEVGmMFA5I9z9YcgVA 5PcCTKOYmfPlJpsfchCp7fr2TE0ahurRpRmUHbxMNuHj1/4ay06cHASrZnTySlKQMQyX kDUv+ugBCedxnZpWtmXI4dZHgGGJjQLcHw1V1QndS5T4BS94UY2GMLjbP3ZtOvBaCJjb gL3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HDhdSyCK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e6-20020a170906374600b006e890becd77si6333907ejc.424.2022.04.18.12.43.35; Mon, 18 Apr 2022 12:43:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HDhdSyCK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233580AbiDRMVb (ORCPT + 99 others); Mon, 18 Apr 2022 08:21:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238329AbiDRMVJ (ORCPT ); Mon, 18 Apr 2022 08:21:09 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 236301AF10; Mon, 18 Apr 2022 05:17:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BBCB5B80ED7; Mon, 18 Apr 2022 12:17:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 164BDC385A1; Mon, 18 Apr 2022 12:17:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650284232; bh=PGMSCHIq8Ea2LVix5FCymQtAbWUPzEE/jy1wS8r+Rxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HDhdSyCKxYGOhYP0JaJIZ4K/9Y2EXrEt2C7WJfLSIMOtC7PucXHsMTTRzi10LCVz+ OwuWdpUr1nqE8TWOJ5Xv1mHbE5Cn3L30y0Akk26/x6GMvJhukNO0kkCj3pn/8NTz9Z 5dMRYqSRGLtaV4HcWJz8YYgknfHWMJWiNqAxA5Hg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Thumshirn , Naohiro Aota , David Sterba Subject: [PATCH 5.17 016/219] btrfs: return allocated block group from do_chunk_alloc() Date: Mon, 18 Apr 2022 14:09:45 +0200 Message-Id: <20220418121204.075353134@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121203.462784814@linuxfoundation.org> References: <20220418121203.462784814@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Naohiro Aota commit 820c363bd526ec8e133e4b84e6ad1fda12023b4b upstream. Return the allocated block group from do_chunk_alloc(). This is a preparation patch for the next patch. CC: stable@vger.kernel.org # 5.16+ Reviewed-by: Johannes Thumshirn Tested-by: Johannes Thumshirn Signed-off-by: Naohiro Aota Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/block-group.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -3427,7 +3427,7 @@ int btrfs_force_chunk_alloc(struct btrfs return btrfs_chunk_alloc(trans, alloc_flags, CHUNK_ALLOC_FORCE); } -static int do_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags) +static struct btrfs_block_group *do_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags) { struct btrfs_block_group *bg; int ret; @@ -3514,7 +3514,11 @@ static int do_chunk_alloc(struct btrfs_t out: btrfs_trans_release_chunk_metadata(trans); - return ret; + if (ret) + return ERR_PTR(ret); + + btrfs_get_block_group(bg); + return bg; } /* @@ -3629,6 +3633,7 @@ int btrfs_chunk_alloc(struct btrfs_trans { struct btrfs_fs_info *fs_info = trans->fs_info; struct btrfs_space_info *space_info; + struct btrfs_block_group *ret_bg; bool wait_for_alloc = false; bool should_alloc = false; int ret = 0; @@ -3722,9 +3727,14 @@ int btrfs_chunk_alloc(struct btrfs_trans force_metadata_allocation(fs_info); } - ret = do_chunk_alloc(trans, flags); + ret_bg = do_chunk_alloc(trans, flags); trans->allocating_chunk = false; + if (IS_ERR(ret_bg)) + ret = PTR_ERR(ret_bg); + else + btrfs_put_block_group(ret_bg); + spin_lock(&space_info->lock); if (ret < 0) { if (ret == -ENOSPC)