From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59FC5242D73; Tue, 29 Apr 2025 17:48:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745948911; cv=none; b=bxtepDf75Hr4aMtixph/H9w3tBGcKP7MBDPtrJ3FKJ8AQHVUV91T/LXb8cCJxn5Eyo11LcJJ17ZvZI3Gp/hE8i9auKVwJOLzYikQUTzS22TR6mPNUk/YjOTxFPOYivlFDaR0wK/mq/ltnc1NF/OgVtsUoJd7tNWmQq9Qkods0hQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745948911; c=relaxed/simple; bh=6dueBsiFMLXg+5OTKLmgjYfNsHoj0UU6GHAiZgUSijw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PIA9wKXh9f7jeOWf6iegWJPQx63JSuPENn/P9aHJaWmZMF8mwJtw7Zp/fMqcvxvOPGuhFdhyXyZIhjY/Xa/8JBRXuJ/aO4y02PYXMwt0X4C9X31oGySXSwPPWjMPMre2TTzn6i14bsHb1JbRbvHiJ+Jdgi2Wr3HMJcvi6GMQ6Mc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=A/Tbl/vz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="A/Tbl/vz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF409C4CEE3; Tue, 29 Apr 2025 17:48:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745948911; bh=6dueBsiFMLXg+5OTKLmgjYfNsHoj0UU6GHAiZgUSijw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A/Tbl/vzKDWtLfU5vZFDCeGkHLyy3IRhQCvDMseGZcsGde0Ktu54MElKeez9qEfIU vzWxdZKIW/F16+4NYQTD6Q/Pb4tQ3cnXf8XPFBvNrLP9kHI3Z6shbWAjPYcNzLM9/M Mx5rQI7HvWYdLXBAPtyNbAP07GmrIUeDb61fN9lM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Li Lingfeng , Jeff Layton , Chuck Lever , Sasha Levin Subject: [PATCH 5.15 161/373] nfsd: decrease sc_count directly if fail to queue dl_recall Date: Tue, 29 Apr 2025 18:40:38 +0200 Message-ID: <20250429161129.763265328@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161123.119104857@linuxfoundation.org> References: <20250429161123.119104857@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Li Lingfeng [ Upstream commit a1d14d931bf700c1025db8c46d6731aa5cf440f9 ] A deadlock warning occurred when invoking nfs4_put_stid following a failed dl_recall queue operation: T1 T2 nfs4_laundromat nfs4_get_client_reaplist nfs4_anylock_blockers __break_lease spin_lock // ctx->flc_lock spin_lock // clp->cl_lock nfs4_lockowner_has_blockers locks_owner_has_blockers spin_lock // flctx->flc_lock nfsd_break_deleg_cb nfsd_break_one_deleg nfs4_put_stid refcount_dec_and_lock spin_lock // clp->cl_lock When a file is opened, an nfs4_delegation is allocated with sc_count initialized to 1, and the file_lease holds a reference to the delegation. The file_lease is then associated with the file through kernel_setlease. The disassociation is performed in nfsd4_delegreturn via the following call chain: nfsd4_delegreturn --> destroy_delegation --> destroy_unhashed_deleg --> nfs4_unlock_deleg_lease --> kernel_setlease --> generic_delete_lease The corresponding sc_count reference will be released after this disassociation. Since nfsd_break_one_deleg executes while holding the flc_lock, the disassociation process becomes blocked when attempting to acquire flc_lock in generic_delete_lease. This means: 1) sc_count in nfsd_break_one_deleg will not be decremented to 0; 2) The nfs4_put_stid called by nfsd_break_one_deleg will not attempt to acquire cl_lock; 3) Consequently, no deadlock condition is created. Given that sc_count in nfsd_break_one_deleg remains non-zero, we can safely perform refcount_dec on sc_count directly. This approach effectively avoids triggering deadlock warnings. Fixes: 230ca758453c ("nfsd: put dl_stid if fail to queue dl_recall") Signed-off-by: Li Lingfeng Reviewed-by: Jeff Layton Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin --- fs/nfsd/nfs4state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 5e576b1f46c79..1d09fb4ff5a5e 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -4944,7 +4944,7 @@ static void nfsd_break_one_deleg(struct nfs4_delegation *dp) queued = nfsd4_run_cb(&dp->dl_recall); WARN_ON_ONCE(!queued); if (!queued) - nfs4_put_stid(&dp->dl_stid); + refcount_dec(&dp->dl_stid.sc_count); } /* Called from break_lease() with flc_lock held. */ -- 2.39.5