From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 8331244999A for ; Thu, 9 Jul 2026 19:55:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783626923; cv=none; b=A6/cg3YOEtplwphIv6yegr0WL93kxGLp1LyNXGOgyX7mLjYPjWrZ+kFDSF00USyWQPK7dajDCeMPFtQvw+YhYFbl5BOXhMdWvOPKvFPkNBn/zjSWZ+KsBxOL2GOV284hw3mEnoLIvHFQAOxE2B2unF+Yan6MI1kDnki4FWL2R0E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783626923; c=relaxed/simple; bh=vB5ef3CjicVSgwCtd2eOHHL/izaG/8hSIjg8oe+70LI=; h=MIME-Version:Date:From:To:Cc:Message-Id:In-Reply-To:References: Subject:Content-Type; b=rVmv9zUT7buG0FsmOY2v5+Hf5uz/Np9Jy86lhsNR117gGPvxMOcPy9Vfp+1faJHdVhrLVLE7QaVGlUj11gdu40Ekgy2u+6ZizJPqgVw6AJwqQoQYMzLRgozBZ2RwTt+SI+QtQePr6AAb9qvGWItdAECkaZtdbez9Qb955PFdT2w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cml4UFqz; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cml4UFqz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77B191F000E9; Thu, 9 Jul 2026 19:55:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783626921; bh=QehIRXfaSslViHGlxa/4fwubHddtIj1CC3xCGbWWv8c=; h=Date:From:To:Cc:In-Reply-To:References:Subject; b=cml4UFqzGRAXz5ucwGyvdnk9q6YyOosAl5cZvO05yOjJUOOs/xnB8NfIubeWdXqmn ICXVwWfDRCqtYznM6zS3jajKLEG51ISWaPKCuSIFvR3oQyof2XvB6Gi5makY+os4FS jwSwp+fLTk+Mxxd/5+X0JyrxYh+Wane5gi2S8EhUA5oQDO6f2/aLcdI1N+jI3QDwKV /Q4N3w8n8VTWcUykUraxiwtQqOKNiux4xzkWOZ5Al5OMaNu+BVbGwgSkprbDVl26Sv 3pBKtyJgezti5chd/af8BebadE40lLq/aDm2AzvbtcisW9RnTFC8JdhcbcS4aQofn1 n2Sd6rjtkVA3Q== Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailfauth.phl.internal (Postfix) with ESMTP id 897E3F4007A; Thu, 9 Jul 2026 15:55:20 -0400 (EDT) Received: from phl-imap-15 ([10.202.2.104]) by phl-compute-10.internal (MEProxy); Thu, 09 Jul 2026 15:55:20 -0400 X-ME-Sender: X-ME-Proxy-Cause: dmFkZTGpxNdCv2SyuiG5PkycyXZZbK/ZHIg1XenU8iRecF0Zhpqk2ES2xEgACHxmW+FxfI UXmEDLcm+OE6Lydr7PFxRdsd6J1nDSKvAGUg/TClZJLbCRToStCIDUpH+TiN6kgAgkPyPi zBJ+oqSZNLaTN2SIpzs0AyiP5+CpVRzcKB+Fikzl1cDfAoYkjqPMQEPAopBlS4o/RMoiB4 NgtPMPIGoFwuk7fKdbCafzjBC79QzS3KNfp7FiB7RWvWIFiqSNvLDE7Az6gNOrmiLVDbbf 7dIBCBLI8YD/zyvUXzieiagCVU/EBOCXB8pO5hvb6fgYtOKEmlc4yxPEClUjKecLORVUU5 ogutnj+OgH9lHc3414BQKAGXar17+Ajl35ISSsSYmiE6zx1UDIbWsqvJ113sOdGyCfLQ3E OCPl3N/DR0hs/v9IRrtlae69eRAJFFspnVzkMXZPDzjh1o08sm6rR/p6t6n5EysZ0WkjVP lsksoM354joLpAYBYYAVaFQ0iR0/S+2pgZZ8DWCEdiEjalAungu7oSnAxFapuUqn+nbHl1 DBix3Loeuo9R4HNDNOhHRviqdacn1AGtFR6ygmDi70zbw3SKYSMZtFqj5WkjI1pG+3UOXp sPYZYPZipSk6JGZhT0Ofm/xckClgF8UqwINSbmHgTNvKQZN9dCiUaPu1TwHg X-ME-Proxy: Feedback-ID: ifa6e4810:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 676C3780AB8; Thu, 9 Jul 2026 15:55:20 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ThreadId: Amiak35LOpZN Date: Thu, 09 Jul 2026 15:55:00 -0400 From: "Chuck Lever" To: "Jeff Layton" , NeilBrown , "Olga Kornievskaia" , "Dai Ngo" , "Tom Talpey" Cc: linux-nfs@vger.kernel.org, sashiko-bot Message-Id: <2b2a1ec1-e2dd-4e87-b812-08fe17a993bd@app.fastmail.com> In-Reply-To: <62b35e8e3073f16c7ffc514fc30f23c788d25486.camel@kernel.org> References: <20260709-cel-v4-0-1d519d9be0cb@kernel.org> <20260709-cel-v4-9-1d519d9be0cb@kernel.org> <62b35e8e3073f16c7ffc514fc30f23c788d25486.camel@kernel.org> Subject: Re: [PATCH v4 9/9] NFSD: Release the export reference when reaping open stateids Content-Type: text/plain Content-Transfer-Encoding: 7bit On Thu, Jul 9, 2026, at 2:40 PM, Jeff Layton wrote: > On Thu, 2026-07-09 at 13:40 -0400, Chuck Lever wrote: >> nfs4_put_stid() releases the svc_export tracked in >> nfs4_stid.sc_export, but free_ol_stateid_reaplist() frees open and >> lock stateids by calling ->sc_free() directly, bypassing that path. >> An open stateid takes an sc_export reference in nfs4_open() and a >> lock stateid takes its own in init_lock_stateid(); both reach >> free_ol_stateid_reaplist() through their normal teardown, the open >> stateid via release_open_stateid() and the lock stateid via >> nfsd4_release_lockowner(), each through put_ol_stateid_locked(). >> The reference is therefore never dropped, pinning the export and >> blocking unmount for the lifetime of the stateid. >> >> Release sc_export in free_ol_stateid_reaplist() the way >> nfs4_put_stid() does. ->sc_free() runs once per stateid, and a >> stateid reaches free_ol_stateid_reaplist() or nfs4_put_stid() but >> never both, so the reference is dropped exactly once. Revoked >> stateids reach this path with sc_export already cleared by >> drop_stid_export(), so they are skipped rather than double-freed. >> >> nfs4_put_stid() itself read sc_export before acquiring cl_lock. >> drop_stid_export() clears that field and releases the reference >> under cl_lock, so a concurrent revocation could drop the export in >> the window between the read and the final put, releasing the same >> reference twice. Read sc_export while cl_lock is held so the two >> paths serialize and the reference is released exactly once. >> >> Fixes: ba0cde5dc81d ("NFSD: Track svc_export in nfs4_stid") >> Reported-by: sashiko-bot >> Closes: https://sashiko.dev/#/patchset/20260707-cel-v3-0-7c0cc16fd54f@kernel.org?part=9 >> Signed-off-by: Chuck Lever >> --- >> fs/nfsd/nfs4state.c | 8 +++++++- >> 1 file changed, 7 insertions(+), 1 deletion(-) >> >> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c >> index 20556b8f186a..e988dfebf75e 100644 >> --- a/fs/nfsd/nfs4state.c >> +++ b/fs/nfsd/nfs4state.c >> @@ -1753,9 +1756,12 @@ free_ol_stateid_reaplist(struct list_head *reaplist) >> st_locks); >> list_del(&stp->st_locks); >> fp = stp->st_stid.sc_file; >> + exp = stp->st_stid.sc_export; >> stp->st_stid.sc_free(&stp->st_stid); >> if (fp) >> put_nfs4_file(fp); >> + if (exp) >> + exp_put(exp); > > nit: nfs4_put_stid() does this in the reverse order. It doesn't > actually matter, but it looks a bit weird if you want to fix it up > before merging. > >> } >> } >> > > Reviewed-by: Jeff Layton Swap applied, series pushed to nfsd-testing. Thanks for your review! -- Chuck Lever