From nobody Wed Nov 16 20:10:45 2022 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 4NCDgp078Tz4hYV7; Wed, 16 Nov 2022 20:10:46 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NCDgn6bNfz3ppd; Wed, 16 Nov 2022 20:10:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668629445; 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=Q35FT6X5sut35qdt7cuqD7Zn6fBDoUSEwoH1SlVGQ5M=; b=T5QpqM5fgToCA0huW16Y2QeIJZ7AbNZR9YFcOWGD0FN1aAGPiS/AzPu2KhTLQtSZ8AVkLo oOqdAUuEIZ/zZ/B0GMFpz0ld8w28hfjU852T0loc+dx2lKESsoFDbZVOtiAaOTQaSFZC/p 91ygMhU4c/pCu4z7SC0VxKJ1uCsT4e2gOVDLL2z/9d5SqKaaf48FWiXKycRhPnvLUDW4B8 s2aON72layjZ1Qas34NMdnY+8HfRluzFio1VRY3jv6ilTQl7OfVfUyZF44Rgldgwx99RTU eG8O+40SHOxlJlNKksLwOxGj2xZfj0PWYOZuUMCkB7d22LCDmWQxJmSoZzFRbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668629445; 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=Q35FT6X5sut35qdt7cuqD7Zn6fBDoUSEwoH1SlVGQ5M=; b=DKRUhgbUVADyPwr8VWy2GERs1Qq6810U+aA/B96BB4j3Ax4a5Ih4zH3QH80LEUQBOiLmUt 70wnpEb9nZQcYC5usQtG3VSPPzP/wf6KpOJJROXaWW7di2ZgfifkEi2t8yL+IYrM6u6GZf Ok320QZMSos+F0lilQBN+t79qxMNiM4fwagVwmafqACpF5a94fcFAjn6ALY7C7Mhl0Ciai d3iMWbPX8oz6NWv3N4dCSDkyL0k1o4bFBIqkfEohIDanjYc9wxPueF3wyM44cWSfZuBSnE 8VdS7RO9F9PXo/sOcfbUYy2KEjRBKPV58WTJPwFIYasYtbSOO2bkBP03R64Ksg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668629445; a=rsa-sha256; cv=none; b=iXtT/r0NtVMR778/TWmWQiWCCnKhghtIQniteGthAgwFLS0x2SQQQfvHYa0Zw6nOXH67Ms mseUugz1dKGtTuWJu4CKfZDQer3kI62Q9lhsMJO47jglVIKdcKbSexlvTIrpSl4k9ftLs7 v7K/TktP7ma0Fn/D0yX8M7d+mDPbs4nLbLQZnR9snxljSsUavhXqqRFlmZE9xdp4t4fLyo cJcSxnQfWqGUuUukJSnsEBfHderfpSFVXQCI+CTVWY8Bti1YeZzmearKCzcBX0b4YZU5Sb BuBVFUGB7vghQncKzrHh1RslaR9ltLbqgitAK7SGnQiOB9xiUqDt/WSJG098HA== 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 4NCDgn5g0FzF8r; Wed, 16 Nov 2022 20:10:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2AGKAjuk087949; Wed, 16 Nov 2022 20:10:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AGKAjFu087934; Wed, 16 Nov 2022 20:10:45 GMT (envelope-from git) Date: Wed, 16 Nov 2022 20:10:45 GMT Message-Id: <202211162010.2AGKAjFu087934@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: 5971781ee78b - stable/13 - nfsd: Make the pNFS server update Change for Setxattr/Rmxattr 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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/13 X-Git-Reftype: branch X-Git-Commit: 5971781ee78b0c5879c2696437b1f7629d140c30 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=5971781ee78b0c5879c2696437b1f7629d140c30 commit 5971781ee78b0c5879c2696437b1f7629d140c30 Author: Rick Macklem AuthorDate: 2022-10-18 22:47:07 +0000 Commit: Rick Macklem CommitDate: 2022-11-16 20:09:33 +0000 nfsd: Make the pNFS server update Change for Setxattr/Rmxattr When the NFS server does the Setxattr or Rmxattr operation, the Change attribute (va_filerev) needs to be updated. Without this patch, that was not happening for the pNFS server configuration. This patch does a Setattr against the DS file to make the Change attribute change. This bug was discovered during a recent IETF NFSv4 testing event, where the Change attribute wasn't changed in the operation reply. (cherry picked from commit ae7816576e44412a8ae9daa92c210a6ba4f269dc) --- sys/fs/nfsserver/nfs_nfsdport.c | 49 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index 258642bb1060..51c4d59e5380 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -101,6 +101,7 @@ struct callout nfsd_callout; static int nfssvc_srvcall(struct thread *, struct nfssvc_args *, struct ucred *); +static void nfsvno_updateds(struct vnode *, struct ucred *, struct thread *); int nfsrv_enable_crossmntpt = 1; static int nfs_commit_blks; @@ -6568,8 +6569,11 @@ nfsvno_setxattr(struct vnode *vp, char *name, int len, struct mbuf *m, if (error == 0) { error = VOP_SETEXTATTR(vp, EXTATTR_NAMESPACE_USER, name, uiop, cred, p); - if (error == 0) + if (error == 0) { + if (vp->v_type == VREG && nfsrv_devidcnt != 0) + nfsvno_updateds(vp, cred, p); error = VOP_FSYNC(vp, MNT_WAIT, p); + } free(iv, M_TEMP); } @@ -6578,6 +6582,44 @@ out: return (error); } +/* + * For a pNFS server, the DS file's ctime and + * va_filerev (TimeMetadata and Change) needs to + * be updated. This is a hack, but works by + * flipping the S_ISGID bit in va_mode and then + * flipping it back. + * It does result in two MDS->DS RPCs, but creating + * a custom RPC just to do this seems overkill, since + * Setxattr/Rmxattr will not be done that frequently. + * If it fails part way through, that is not too + * serious, since the DS file is never executed. + */ +static void +nfsvno_updateds(struct vnode *vp, struct ucred *cred, NFSPROC_T *p) +{ + struct nfsvattr nva; + int ret; + u_short tmode; + + ret = VOP_GETATTR(vp, &nva.na_vattr, cred); + if (ret == 0) { + tmode = nva.na_mode; + NFSVNO_ATTRINIT(&nva); + tmode ^= S_ISGID; + NFSVNO_SETATTRVAL(&nva, mode, tmode); + ret = nfsrv_proxyds(vp, 0, 0, cred, p, + NFSPROC_SETATTR, NULL, NULL, NULL, &nva, + NULL, NULL, 0, NULL); + if (ret == 0) { + tmode ^= S_ISGID; + NFSVNO_SETATTRVAL(&nva, mode, tmode); + ret = nfsrv_proxyds(vp, 0, 0, cred, p, + NFSPROC_SETATTR, NULL, NULL, NULL, + &nva, NULL, NULL, 0, NULL); + } + } +} + /* * Remove Extended attribute vnode op. */ @@ -6605,8 +6647,11 @@ nfsvno_rmxattr(struct nfsrv_descript *nd, struct vnode *vp, char *name, if (error == EOPNOTSUPP) error = VOP_SETEXTATTR(vp, EXTATTR_NAMESPACE_USER, name, NULL, cred, p); - if (error == 0) + if (error == 0) { + if (vp->v_type == VREG && nfsrv_devidcnt != 0) + nfsvno_updateds(vp, cred, p); error = VOP_FSYNC(vp, MNT_WAIT, p); + } out: NFSEXITCODE(error); return (error);