Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5858497rdb; Sun, 17 Sep 2023 16:12:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEe/5Ls6nrSpyYmNHCMEWXRLpc0989rM9YSHEmUAfZTakpW7Mk4lrMlw1yYsZsGEPxLwWpC X-Received: by 2002:a05:6a20:442a:b0:140:3cc7:b3a6 with SMTP id ce42-20020a056a20442a00b001403cc7b3a6mr15154337pzb.4.1694992364601; Sun, 17 Sep 2023 16:12:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694992364; cv=none; d=google.com; s=arc-20160816; b=Uc+0iLNKDrqKhByItT2BuoMPa6auC5JjN+L4AeRLkpgKxR0CY9C6TKL0mGuWnoChTk HRYmDDpsOlyUCu/6xgm17xHqCRTjDFnCw2mhxLbKIvOVt9fYF4fAIvHs2Xdt1CjfIDWl z4McLH59wmt4Aj0oXhvGROwrfO5+6F+I3HqDOMwBu9PQifTIIl8VrowDTY5zhZgNHeUn oSuUXNFgAhmPbGMcx7vkCax7dE2ZGeqYCCcbFS+G/wPO7qlXPnn3+EP5SmFB82MlHoQ2 GcgNDcNnzBwc1RF+KTq3KXDVFwtXrroIl4BO9vAIFfvj2u/opVYwHzuF3iR54qknUyY7 CVmg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=1Nc27gGuyZSE+d6rqWhiHS7Kefangm3bszE4b7usi4E=; fh=sG9b8sIRwnMx357dAEVjdzLttEK3RTv7pmgywyQXOZs=; b=aRRSRZheZAZdDFr23OMkdij8/lTs7AJpEi0ly8ZslUJowD/Ui3rTyKdZ9aGW5mXyhl PO5TzV3Li6XcVdfdmMqi6kNLtV8yczP7O4JM91ilWx9zfVOA+fw4V0L7OSTTNW4CZz7S cb4QaY9QqbmruCMF1RrMY3HxV67Ksd1F3tUfMKFNxOWeTZXsEN4EumJfxgkurHSN3ICR EaSWTJ2eUBlf+/E9gGhLdsZRtmkjMtWbphEBaoFzOzydEbSXmbMvCaxjaQIFV+1Rz1KM bYComKbyBsrcYrO0xTT5+YZBvyata4/qu2xKdhKGOojrxH3QszfKrTLCKcMk/a2XSRB0 zllw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=puiC0eNd; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id p126-20020a634284000000b0056536fc7901si6343204pga.593.2023.09.17.16.12.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 16:12:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=puiC0eNd; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 731D7819D214; Sun, 17 Sep 2023 16:12:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231491AbjIQXMH (ORCPT + 99 others); Sun, 17 Sep 2023 19:12:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238428AbjIQXME (ORCPT ); Sun, 17 Sep 2023 19:12:04 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E44611F for ; Sun, 17 Sep 2023 16:11:58 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D4FBC433C8; Sun, 17 Sep 2023 23:11:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694992317; bh=aYfde5eM3WvCla80MMfJ6aK7fi7rG7vNHxS84KWVDLw=; h=From:To:Cc:Subject:Date:From; b=puiC0eNdfTijFs8dM2CurOPLZfOy1kGYFcyy7bDTwa8VnSIYwQz2g2S7VI+TCKQyo VnHIEmZmJfHiJLFCBQ/gr9WG0KgrmCII2SNcujwuOO8M+gKr93ySpQ/OjrJKpQSEN0 FvmepNRFH+eQzXBmCWErnnuGFXbnd3/stDWVjrXjNxFzyctXHB+GOJb3e3S839VYxk frMNUSjCLmnJHC5JAyQRNvnxR/SmXGehPjnNOLrcmC0+WK5vpjlkwMkaQ/8iB81nIS VbkuLvNO4cePrWx0XiuVN4X1fxEaf8AFIAFODQ0nsCGh8a822MNvZ45DPsKCiqbFw2 0QXoVooUnxd8A== From: trondmy@kernel.org To: Anna Schumaker Cc: linux-nfs@vger.kernel.org, Neil Brown Subject: [PATCH 1/2] NFSv4: Fix a nfs4_state_manager() race Date: Sun, 17 Sep 2023 19:05:50 -0400 Message-ID: <20230917230551.30483-1-trondmy@kernel.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 17 Sep 2023 16:12:41 -0700 (PDT) From: Trond Myklebust If the NFS4CLNT_RUN_MANAGER flag got set just before we cleared NFS4CLNT_MANAGER_RUNNING, then we might have won the race against nfs4_schedule_state_manager(), and are responsible for handling the recovery situation. Fixes: aeabb3c96186 ("NFSv4: Fix a NFSv4 state manager deadlock") Signed-off-by: Trond Myklebust --- fs/nfs/nfs4state.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index e079987af4a3..0bc160fbabec 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -2703,6 +2703,13 @@ static void nfs4_state_manager(struct nfs_client *clp) nfs4_end_drain_session(clp); nfs4_clear_state_manager_bit(clp); + if (test_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state) && + !test_and_set_bit(NFS4CLNT_MANAGER_RUNNING, + &clp->cl_state)) { + memflags = memalloc_nofs_save(); + continue; + } + if (!test_and_set_bit(NFS4CLNT_RECALL_RUNNING, &clp->cl_state)) { if (test_and_clear_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) { nfs_client_return_marked_delegations(clp); -- 2.41.0