Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3099096rwb; Mon, 15 Aug 2022 18:04:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR7N+gQj3HnTbI5nK+4YC8Ep3dW3GrZrAZ6BvYihiOTl8XpC4FtiWaLPVjKaoPxtu6LYbdUY X-Received: by 2002:a05:6402:530e:b0:443:df38:9df with SMTP id eo14-20020a056402530e00b00443df3809dfmr4334386edb.9.1660611896547; Mon, 15 Aug 2022 18:04:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611896; cv=none; d=google.com; s=arc-20160816; b=IOkNwusRDl233L0ud/Ou94EcS3mjfAPXY6twy5VueeqbIbRQRd4Ht998RYQP2Mrgjq T11UhAx1Kqi6scLL2BOdZbjqE7e/0XU3WRq/ohyxEgXLQvTR5YocfDMGYTX95vWjXJWj Xs12At07DOWyQ8lf+XknjErh7KvwvipHULM/8cUAn7eHQ5HTFe30IAkL9ERliR3dAOL0 moN4YydQEvv/M2xpGyKO/YOO7UwtflcphMH1obgOMzRWUDftSthH+FRFburPLQCbHZnk xvX46jmuggPnWNvnxOBGI7hBSIrHvR1+1TZiqn5vpYY/s761rDXKmLXEqOOyqw5a1RAD FoCg== 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=wwsPIk5hmlvYgAsbplKmqa2DEousRNs1qO2s46xIAJg=; b=aZq3danP2g/BU0O2uzdPUncHZ7QStusr8cQaaGI/Nzuf+ooc5fxF7azHVHCObd3Ojk N63V8ecrxoSu5nDUHlAFGCWd+C4AL3wOmauzAYScVco/c82ak4hiIHZuczLS1Uv73AtN sv6CG83s4k+4N3+l537xjWjtMkk0BcjxxWXLtvv/ZF7TCmLtrqUSZNUXV/LGf5CRbDW5 bjKDu94uGPoBFqI2luDWoRv0/ox9aHz4ygKN++5xS4PWRGjEvZPxgCZUxQgLQkmvCj+H U+9+m8iLnuVXPfjHHQQeCikdmkPHnYNyHaLGsM0WH615/7lU9AST0pdN18eLhzhJH5WP MTIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rds2EpvM; 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 g9-20020a056402090900b0043d88c55277si9895563edz.238.2022.08.15.18.04.13; Mon, 15 Aug 2022 18:04:56 -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=rds2EpvM; 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 S1348487AbiHPBCR (ORCPT + 99 others); Mon, 15 Aug 2022 21:02:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345249AbiHPA4l (ORCPT ); Mon, 15 Aug 2022 20:56:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF4CEDAA3C; Mon, 15 Aug 2022 13:48:21 -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 ECB6861255; Mon, 15 Aug 2022 20:48:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEB1EC433C1; Mon, 15 Aug 2022 20:48:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596500; bh=4BnIrXYRqN01St2n7dxsaGgN/+3PG5oNAtHvK8qvYCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rds2EpvM5ANOqpbKz3Rm2cJ/kgRDKeiftgohLRlX7xgPqfv6Mb1tl3I0XGwooBNNH UFbAFxj0s14AWu0sYT3HIBeOgmHtF95OoAzfkUlCXS3bebTY5CuZowdacnt5z5W8bO t3G/2jcynM2po4E9fwxkca720RyQgJ7F5lpwcZA8= 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.19 1082/1157] btrfs: reset block group chunk force if we have to wait Date: Mon, 15 Aug 2022 20:07:18 +0200 Message-Id: <20220815180523.442276351@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 ede389f2602d..13358fbc1629 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -3761,6 +3761,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