From nobody Fri May 30 20:35:16 2025 X-Original-To: dev-commits-src-all@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 4b8FNh3BYfz5wsMR; Fri, 30 May 2025 20:35:16 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4b8FNh2HTvz3c8P; Fri, 30 May 2025 20:35:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1748637316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kOroIHkH+1Uc5qUE24h2hQHPLR0JIZMNC66UMaRcygA=; b=f1JEoFSjCRRt77UgKFuDQw0EZ+T2pzWw/zUc21RUnFUcAupOVE6oLmi8Q/iq4XK3ofMFWu zRfgQ+duJqU1G1hdeTDlnHHGVLJ4FBpNmCKCkfxngHjQoQnQdMewADHVq1+fO0JXT1N/bk jRZhDM+gSBPJ6oIgcU2m7o7OKN2vdTikw2JC+bwU8FpQ/FnXJStctTO18poEUXDDlNMNC4 3O57ZXztVg9lqvQevdaUDaeOrLnQpwaAsIZrL5fhfdhQ9oZVwLX9PVxoLhas3ex94zJrd2 qs4sceRTi4ZnLw/TyR18hJDPgNg/RT5eZKmlZMxBVk0r+/FyFUPEESD7+2w8ag== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1748637316; a=rsa-sha256; cv=none; b=s58J75IEwdTlS+XPnPngiAHzu/QYdYEXbG2LcWGlOmu/+Nw4L65RPKyWiMMe5UbbzjMUIa 2LWQ5wyBSu72LrVKnpTschuT7WCIcTexzYM6xNwx6NApazm2pR02BnRvKx2nugXKXJhnze ikRmapZyYqI2MjEdVKkLcdoTHTGvaV4+AAjL3693NxsOCrJI5PqFobG7tB843WUWujqQCU vnpAD7CmoLMZZFgxSQngb19XG994IZN1y6TTIAWyCDkHPLhgtFveZvrOX4lUrho8K9oAQm vuW6B7hGr3Zd1ljjoHCdIXASRDA4F0hB9wYEMWmg37ButMy+7yuo+pzHuWZMmw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1748637316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kOroIHkH+1Uc5qUE24h2hQHPLR0JIZMNC66UMaRcygA=; b=SAVyB3n7di3LBirZ2xDjM3Cg8eJB+VbUav8llmoZ0aykn14PdhvDHLMQUBLS8cQrUMx5gy xhuc0cgn0MGeERLx1dHYNzzgDncGWoUazSW1ZJyR17I3JU1AoaQHC4bsjstAOopc+tpODH 1b6P60KM0D66qCw6Cd8HxftDmfQff4cNOVnfSVyyxjO56SjUwgcAngO0Jq3ULo+SlEqqPD ZZKTzMfIVHIP4fE0flz9VXvm8/PXVgDrmIDVZuUGvaOKiGjBqYp82DlguClKU1JC09urKb uRPRXTwaEMUMx0AJM1Xch4ce5R53NpHIVbiPOTjbxSUptYffjhfKsn4arncvIg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4b8FNh1hndz16L5; Fri, 30 May 2025 20:35:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 54UKZGUQ004018; Fri, 30 May 2025 20:35:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 54UKZGLf004015; Fri, 30 May 2025 20:35:16 GMT (envelope-from git) Date: Fri, 30 May 2025 20:35:16 GMT Message-Id: <202505302035.54UKZGLf004015@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Rick Macklem Subject: git: e5c544f95ab4 - stable/14 - nfs_clrpcops.c: Fix acquisition of post-op attributes for link List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org 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/stable/14 X-Git-Reftype: branch X-Git-Commit: e5c544f95ab4d56d7b8ee73415c40135db84579b Auto-Submitted: auto-generated The branch stable/14 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=e5c544f95ab4d56d7b8ee73415c40135db84579b commit e5c544f95ab4d56d7b8ee73415c40135db84579b Author: Rick Macklem AuthorDate: 2025-05-16 00:27:14 +0000 Commit: Rick Macklem CommitDate: 2025-05-30 20:32:32 +0000 nfs_clrpcops.c: Fix acquisition of post-op attributes for link Without this patch, the link RPC (done by nfsrpc_link()) did not acquire post link operation attributes for the file object for NFSv4. For some recent Linux NFSv4 servers that support delegations, this would result in the client's cached attribute for st_nlinks not being increased right away, because the delegation would indicate that the now stale cached attributes were still valid. This patch fixes the problem by acquiring post link attributes and updating the client's cached copy in the same manner as the NFSv3 RPC did. Detected at the recent NFSv4 Bakeathon testing event. Applications will only be affected if they examine st_nlinks after a new hard link is created for a file object. (cherry picked from commit 772258c89f28501546844a60616211f44f55f4ce) --- sys/fs/nfs/nfs_commonsubs.c | 2 +- sys/fs/nfsclient/nfs_clrpcops.c | 40 +++++++++++++++++++++++++++------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c index ffd6d3e50654..c593264ef63e 100644 --- a/sys/fs/nfs/nfs_commonsubs.c +++ b/sys/fs/nfs/nfs_commonsubs.c @@ -252,7 +252,7 @@ static struct { { NFSV4OP_REMOVE, 1, "Remove", 6, }, { NFSV4OP_REMOVE, 1, "Remove", 6, }, { NFSV4OP_SAVEFH, 5, "Rename", 6, }, - { NFSV4OP_SAVEFH, 4, "Link", 4, }, + { NFSV4OP_SAVEFH, 6, "Link", 4, }, { NFSV4OP_READDIR, 2, "Readdir", 7, }, { NFSV4OP_READDIR, 2, "Readdir", 7, }, { NFSV4OP_GETATTR, 1, "Getattr", 7, }, diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index 76aa3b102962..d37bffc5ad2e 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -3112,15 +3112,20 @@ nfsrpc_link(vnode_t dvp, vnode_t vp, char *name, int namelen, (void)nfsm_fhtom(VFSTONFS(dvp->v_mount), nd, VTONFS(dvp)->n_fhp->nfh_fh, VTONFS(dvp)->n_fhp->nfh_len, 0); if (nd->nd_flag & ND_NFSV4) { - NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED); - *tl = txdr_unsigned(NFSV4OP_GETATTR); - NFSWCCATTR_ATTRBIT(&attrbits); - (void) nfsrv_putattrbit(nd, &attrbits); - nd->nd_flag |= ND_V4WCCATTR; NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED); *tl = txdr_unsigned(NFSV4OP_LINK); } (void) nfsm_strtom(nd, name, namelen); + if (nd->nd_flag & ND_NFSV4) { + NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED); + *tl = txdr_unsigned(NFSV4OP_GETATTR); + NFSGETATTR_ATTRBIT(&attrbits); + (void)nfsrv_putattrbit(nd, &attrbits); + NFSM_BUILD(tl, uint32_t *, 2 * NFSX_UNSIGNED); + *tl++ = txdr_unsigned(NFSV4OP_RESTOREFH); + *tl = txdr_unsigned(NFSV4OP_GETATTR); + (void)nfsrv_putattrbit(nd, &attrbits); + } error = nfscl_request(nd, vp, p, cred); if (error) return (error); @@ -3129,19 +3134,28 @@ nfsrpc_link(vnode_t dvp, vnode_t vp, char *name, int namelen, if (!error) error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, NULL); - } else if ((nd->nd_flag & (ND_NFSV4 | ND_NOMOREDATA)) == ND_NFSV4) { + } else if (nd->nd_repstat == 0 && (nd->nd_flag & ND_NFSV4) != 0) { /* - * First, parse out the PutFH and Getattr result. + * First and parse out the PutFH and Link results. */ - NFSM_DISSECT(tl, u_int32_t *, 2 * NFSX_UNSIGNED); - if (!(*(tl + 1))) - NFSM_DISSECT(tl, u_int32_t *, 2 * NFSX_UNSIGNED); - if (*(tl + 1)) + NFSM_DISSECT(tl, uint32_t *, 5 * NFSX_UNSIGNED + + 2 * NFSX_HYPER); + if (*(tl + 3)) nd->nd_flag |= ND_NOMOREDATA; /* - * Get the pre-op attributes. + * Get the directory post-op attributes. */ - error = nfscl_wcc_data(nd, dvp, dnap, dattrflagp, NULL, NULL); + if ((nd->nd_flag & ND_NOMOREDATA) == 0) + error = nfscl_postop_attr(nd, dnap, dattrflagp); + if (error == 0 && (nd->nd_flag & ND_NOMOREDATA) == 0) { + /* Get rid of the RestoreFH reply. */ + NFSM_DISSECT(tl, uint32_t *, 2 * NFSX_UNSIGNED); + if (*(tl + 1)) + nd->nd_flag |= ND_NOMOREDATA; + } + /* Get the file's post-op attributes. */ + if (error == 0 && (nd->nd_flag & ND_NOMOREDATA) == 0) + error = nfscl_postop_attr(nd, nap, attrflagp); } if (nd->nd_repstat && !error) error = nd->nd_repstat;