Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3031730rwb; Mon, 15 Aug 2022 16:31:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR40LQ8Mk3CmOrO+MZgYTtr4qdMirOZuXXKVc5floqwEI0XfBAAaVkVexPBuTdOMeC87oQs7 X-Received: by 2002:a17:907:7d91:b0:731:7ecb:1e5b with SMTP id oz17-20020a1709077d9100b007317ecb1e5bmr11771189ejc.78.1660606267718; Mon, 15 Aug 2022 16:31:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660606267; cv=none; d=google.com; s=arc-20160816; b=SFtdZ8wdMcCEa0hVDQ+9BNXFnhW4dck/Hx1NKr/rn87VU7EBIvD0hmIvn42tsPzE07 ap306fVHyBqf310IV2sVO/4DNx4cBDMnQ069iaYbM2n1Ji+cNP8q5eJsueFRHkGWD7H4 iOZLJSL4PpjFCnWyS2yQH3ozvm92mrDqKLoARTKgoKYKW/+C1RATDG4uBIEWXBJEl9Np bg7XLET3dPv//SYFjl9yQgZcJdHEDwxH/6B1B95KAVNsjgmt2tMjTFoTe9nqQddtuLBV f+Pratmr+FCZFXaVpX2wqa1v9hSWQ4gDXttxQgwcSZHS6kb0xRF/Ic4IHwKuXODJnwat YA3A== 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=tOMteeZyItYmVZIkVCIAsSVDi2z1/9MMRThHn8VjmUg=; b=vjsqhB4HyBOV2W3QJtEm0SERLlgXWXuhMC0ikaoeQNZ2vzeJGYbDMv2RhPTVnPUFVg UJFscMhpDqvAYoWEBqVqq09T5a3hXdxd37My//wSpcAYDMyCnuwy/DzFCd1u38/3c85v 5hyPAm3qiYjmS/eMq8Ia7uG2Sz4etrPMedQs7mfDTlc95bfI9OhPJZ66M4lL4nYoo2jx FIQMcyij9s7tM2+im1kx+I7Rb5U9HMz7vVsFLKMtwudpabYBq2dD6di/3K6Z7nFWSnTy yHW8ka6LyohhbRQGMQe5X9ltBY2vk+VQNOdDVfChUyQyRbYMpa52KjHfwHbJlzjxPNsU Xyjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ypWxWOvw; 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 e3-20020a17090658c300b00730cb783378si10319650ejs.13.2022.08.15.16.30.38; Mon, 15 Aug 2022 16:31:07 -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=ypWxWOvw; 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 S239428AbiHOXYa (ORCPT + 99 others); Mon, 15 Aug 2022 19:24:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245066AbiHOXUJ (ORCPT ); Mon, 15 Aug 2022 19:20:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A830F14A1F4; Mon, 15 Aug 2022 13:04:07 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 44E68612E8; Mon, 15 Aug 2022 20:04:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CC46C433D6; Mon, 15 Aug 2022 20:04:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593846; bh=PTZjMZz3dY7nGwXr/zmNJG3phN1LRfO3lK1lVY9wDPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ypWxWOvwn4gDr8s0uDyhRPlRAlaEa9s4G08qS26f2msANaR28armkDKCXPbvR3/Xm 3imAiZjZ78lmTcLB8Pxj40mbdsvU8x4qCnGIDJWtEzaA714f3hgc8FcYrONr75jpDT 9QZviPRj6KIuAmtZkcqNSkLlZQaiViIKsDybkRUc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , Josef Bacik , David Sterba , Sasha Levin Subject: [PATCH 5.18 1015/1095] btrfs: reset block group chunk force if we have to wait Date: Mon, 15 Aug 2022 20:06:54 +0200 Message-Id: <20220815180511.083835595@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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: Josef Bacik [ Upstream commit 1314ca78b2c35d3e7d0f097268a2ee6dc0d369ef ] If you try to force a chunk allocation, but you race with another chunk allocation, you will end up waiting on the chunk allocation that just occurred and then allocate another chunk. If you have many threads all doing this at once you can way over-allocate chunks. Fix this by resetting force to NO_FORCE, that way if we think we need to allocate we can, otherwise we don't force another chunk allocation if one is already happening. Reviewed-by: Filipe Manana CC: stable@vger.kernel.org # 5.4+ Signed-off-by: Josef Bacik Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/block-group.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index 667b7025d503..1deca5164c23 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -3724,6 +3724,7 @@ int btrfs_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags, * attempt. */ wait_for_alloc = true; + force = CHUNK_ALLOC_NO_FORCE; spin_unlock(&space_info->lock); mutex_lock(&fs_info->chunk_mutex); mutex_unlock(&fs_info->chunk_mutex); -- 2.35.1