From nobody Wed Oct 07 01:54:48 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hzx5V1N9mz6sl0b for ; Wed, 07 Oct 2026 01:54:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hzx5T6vWXz4Rdb for ; Wed, 07 Oct 2026 01:54:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791338094; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Tsge8kveXHpIHxOkziX2hz2R3QmvbPAFOrgCfDM4xzw=; b=qrj5P0hHy7Bm4Iwyd/gECe5vIOvp1jRnIkCIL43bnZZnr8BkDymwjjhHhPIIw20Rq5UCTj Sc/TX04K9JPg3ydRepAOISUBIQnqCZuq17D7SZRH5PZ5kekPVZXi6g3E/PvCTEIMqr5uHg +lBknIMao0AJTU4TZbikVNMQX3yF1m2qoYu2qpprXZv8AM+qKYisF2PV3x/gm6rzXNT8AZ NmP3eaaJ2o3eNwk2Op1j86IE4LXzaMRXvvxRIAjRXgGyJF8348vra5faAFMtCcDs3DyWB1 v40UgrBeE4phhjqjcO8PACyjOCsf4i61+UXvZFbP5rwBgGbGVHIVVPe96at+9Q== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1791338094; b=gn20Is4dFI1GZttA6VFmpFfpNVzGo32FiKYjkHWtmrjxpzCTVMX9RvJ0Xwk4kAqsaEMOP6 /3dmh1OR3K7yx6Y8E9DFNlDw228/Mw7r076RGj+Ah8tJ4BtGwdBg8uTW8RLOLT565xamnj Ga1p621/1Fh9qVvrW7eNrbCTFMRk9Q/xhm/8MjkCE2TfaUOwBEQ6XslojO44Omxeaan7Gk EyACRoQRR0UUe3lO2IWPIsXFAj8y13x6E7fgNi5Rno71hGJXX4EOabN1/as+JlggQSZS5n t29/LUsLSOYJGVWhgn+y3fxuFRSdpXbiVqFzuqMYtnDygo9Xo5l/d6Ngv+dFQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1791338094; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Tsge8kveXHpIHxOkziX2hz2R3QmvbPAFOrgCfDM4xzw=; b=vJSBX6UA15e9/2115mfLzJI7cu9WGuYgrwDeyvNWHLuyEmeg9voEOvlJdUIpk+AvEYpPUV EycsNvObSitTmTUtwD6XuIQ5SDMqODOc+wPFGEeGVOvUoQlSrvyMvXZ07WONZ0D77n/OLU TbYhXHpJOkSohQkC3Tm0IuS1p9NnB7TobVw4TEb8fct7DUqRZthlX0nD21GvvPXo6VCK8P p18WjuTePniosljkX/K+A9E54KdLvKIqSEzkwClTkdB3aWGZ+s2qyLT/imVgRe50PVbl4r w59SVQIrMIcX9eVVcup/YDVO/AzoUGHzShIH3v/o0obD46Cxzy12vOF1RFstWQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hzx5T5lSzzYT9 for ; Wed, 07 Oct 2026 01:54:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1d92d by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 07 Oct 2026 01:54:48 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: J. David From: Rick Macklem Subject: git: 77a7a48a1cb0 - main - nfscl: Fix oddball cases for session slot release List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 77a7a48a1cb003831ff1d4342b1974fc7f79381e Auto-Submitted: auto-generated Date: Wed, 07 Oct 2026 01:54:48 +0000 Message-Id: <6ac5a668.1d92d.20633377@gitrepo.freebsd.org> The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=77a7a48a1cb003831ff1d4342b1974fc7f79381e commit 77a7a48a1cb003831ff1d4342b1974fc7f79381e Author: J. David AuthorDate: 2026-10-07 01:52:19 +0000 Commit: Rick Macklem CommitDate: 2026-10-07 01:52:19 +0000 nfscl: Fix oddball cases for session slot release We have identified some cases where silent slot loss can occur when operations on NFS mounts are aborted. We experience this when using NFSv4.2, but it likely also occurs with NFSv4.1. A slot is acquired for compound operations by nfsv4_setsequence() and freed by newnfs_request(). Any call path that abandons the compound before reaching newnfs_request() loses the slot permanently. We identified four call sites where this happens, one of which where it actually does happen for us in a semi-reproducible way, which allowed us to develop a candidate patch, attached. The patch adds one function, nfsv4_freeunsentslot(), to nfs_clcomsubs.c. It is called from each of the four call sites: nfsrpc_writerpc(), nfsrpc_writeds(), and two in nfsrpc_setextattr(). nfsv4_freeunsentslot() calls nfsv4_freeslot() with resetseq set to true because the aborted RPC will never be sent and therefore the slot sequence ID should not advance. With this patch and other diagnostics, we have confirmed that slot loss does not occur under the conditions that otherwise cause it in our environment. PR: 298416 Reviewed by: rmacklem MFC after: 1 week --- sys/fs/nfs/nfs_var.h | 2 ++ sys/fs/nfsclient/nfs_clcomsubs.c | 18 ++++++++++++++++++ sys/fs/nfsclient/nfs_clrpcops.c | 4 ++++ 3 files changed, 24 insertions(+) diff --git a/sys/fs/nfs/nfs_var.h b/sys/fs/nfs/nfs_var.h index 38f0ff90c5da..488ddbd1c582 100644 --- a/sys/fs/nfs/nfs_var.h +++ b/sys/fs/nfs/nfs_var.h @@ -383,6 +383,8 @@ int nfscl_wcc_data(struct nfsrv_descript *, vnode_t, int nfsm_loadattr(struct nfsrv_descript *, struct nfsvattr *); int nfscl_request(struct nfsrv_descript *, vnode_t, NFSPROC_T *, struct ucred *); +void nfsv4_freeunsentslot(struct nfsmount *, struct nfsclsession *, + struct nfsrv_descript *); /* nfs_nfsdsubs.c */ void nfsd_fhtovp(struct nfsrv_descript *, struct nfsrvfh *, int, diff --git a/sys/fs/nfsclient/nfs_clcomsubs.c b/sys/fs/nfsclient/nfs_clcomsubs.c index d76eecd2762f..fa772ee12c8b 100644 --- a/sys/fs/nfsclient/nfs_clcomsubs.c +++ b/sys/fs/nfsclient/nfs_clcomsubs.c @@ -443,3 +443,21 @@ nfscl_lockderef(struct nfsv4lock *lckp) } NFSUNLOCKCLSTATE(); } + +/* + * Free the session slot of a compound that was built but will not be sent + * to the server. + */ +void +nfsv4_freeunsentslot(struct nfsmount *nmp, struct nfsclsession *sep, + struct nfsrv_descript *nd) +{ + + if (nmp == NULL || (nd->nd_flag & (ND_NFSV41 | ND_HASSLOTID)) != + (ND_NFSV41 | ND_HASSLOTID)) + return; + if (sep == NULL) + sep = nfsmnt_mdssession(nmp); + if (sep != NULL) + nfsv4_freeslot(sep, nd->nd_slotid, true); +} diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index 547771e4594f..ed19a782c5ba 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -2138,6 +2138,7 @@ nfsrpc_writerpc(vnode_t vp, struct uio *uiop, vm_page_t *pgp, int *iomode, error = nfsm_uiombuf(nd, uiop, len); } if (error != 0) { + nfsv4_freeunsentslot(nmp, NULL, nd); m_freem(nd->nd_mreq); free(nd, M_TEMP); return (error); @@ -7376,6 +7377,7 @@ nfsrpc_writeds(vnode_t vp, struct uio *uiop, int *iomode, int *must_commit, *tl = txdr_unsigned(len); error = nfsm_uiombuf(nd, uiop, len); if (error != 0) { + nfsv4_freeunsentslot(nmp, &dsp->nfsclds_sess, nd); m_freem(nd->nd_mreq); return (error); } @@ -9740,6 +9742,7 @@ nfsrpc_setextattr(vnode_t vp, const char *name, struct uio *uiop, NFSCL_REQSTART(nd, NFSPROC_SETEXTATTR, vp, cred); if (uiop->uio_resid > nd->nd_maxreq) { /* nd_maxreq is set by NFSCL_REQSTART(). */ + nfsv4_freeunsentslot(VFSTONFS(vp->v_mount), NULL, nd); m_freem(nd->nd_mreq); return (EINVAL); } @@ -9750,6 +9753,7 @@ nfsrpc_setextattr(vnode_t vp, const char *name, struct uio *uiop, *tl = txdr_unsigned(uiop->uio_resid); error = nfsm_uiombuf(nd, uiop, uiop->uio_resid); if (error != 0) { + nfsv4_freeunsentslot(VFSTONFS(vp->v_mount), NULL, nd); m_freem(nd->nd_mreq); return (error); }