From nobody Tue Oct 18 22:48:06 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 4MsTXk5J0Rz4g1yR; Tue, 18 Oct 2022 22:48:06 +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 4MsTXk4hdyz3G7F; Tue, 18 Oct 2022 22:48:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666133286; 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=Gp4KNgYzT675Xadhvxn+PEQSCamKit4xYVlKD1h5nq4=; b=sIwWPS8QJfga89t3ITXMeVGhJuFuodPdCvzQ2FhnvLhP/sBzaI+jElj5yru41wb/N3p23w 2gKhUg55594PwK0BYY5PgKsTEeKsdCvI+oJlUtCv2Y6PZLBiFla0RxHedi6TM8jldDQKjI y6RATIpCovl0YWXOFY0TX6ydHPO9na7469u47bol1kKiliO3Htd4kroXJt232Az7vHyjkZ +QTV3tE/AWEBCgIT6+SwsUvv/7Gs7ngLOfAtYtuYUuMgFSqTetwNewHy71xrtWRAHbMO71 XPxPi2VK1cKF5+sp2GOC60vy4MSC4yagMlL+LK2yTyiQpagVpYkJrNO0fp5yKA== 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 4MsTXk3dRJzKFX; Tue, 18 Oct 2022 22:48:06 +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 29IMm6td040390; Tue, 18 Oct 2022 22:48:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29IMm60t040389; Tue, 18 Oct 2022 22:48:06 GMT (envelope-from git) Date: Tue, 18 Oct 2022 22:48:06 GMT Message-Id: <202210182248.29IMm60t040389@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: ae7816576e44 - main - 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/main X-Git-Reftype: branch X-Git-Commit: ae7816576e44412a8ae9daa92c210a6ba4f269dc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666133286; 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=Gp4KNgYzT675Xadhvxn+PEQSCamKit4xYVlKD1h5nq4=; b=uZiHmoHwf3f/NsKXJL5Jw2lYrERQmcwqt2c1pTC84Z0PNZe2SkeglIJP99B/2THFnGJewR b2FMmMX+JnJ47TYSS+QuoLfyHyiyLpHrH/hJkVi9vc3WyOSuuglTBuitVosmKzpO0SzU6K 6ANUIQycopDsLguCQPRgkEKOx6aTJVhDhizu2yGvDmaVybaUrtsmIaAIKy7aF8oMHbpbSt SE3sBI294fR/LmEUzdF4uZNT4u+L9PDfNWS1pUrP7l0cvi0MrtsvAGvG/+bUQu7JEbbNHk L317WsOWsARf6l5KCl8uVvBt53rGlgy+5MrWFQdy1CcI0o6ZfMicy9ClJGuzLQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666133286; a=rsa-sha256; cv=none; b=PSl8uCBQDkxd2+VnkgYSneb6yyy9M+gwV2kZZawBQv8gAYCUXVrJwFEn86jb/BJvjXywpL fXNnbnxQuEJB7KDMjvPzzu09Gcaas0A16hgOOew4XEgoNGQlJOwe5avYASk1ctXEAkfZdJ 6oNl2izUR9COw+YiDf2P+8HIXiQHH9d0kWwpR7ktGQiwZjXwuUW94Tbm17aH9B4wwYKe/t 0phbg+xyykisa9VYLwiRZ3bHI3WPICl0BI0qhJu/eyNNXMWjXxKhOJ2URcK0+iPNNQSHSa 4f+G23VwsOAzRdCaXPbQJeDLioZSbdrJnZ3zu1lktF50nEf77+KdYq7daz8ZNg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=ae7816576e44412a8ae9daa92c210a6ba4f269dc commit ae7816576e44412a8ae9daa92c210a6ba4f269dc Author: Rick Macklem AuthorDate: 2022-10-18 22:47:07 +0000 Commit: Rick Macklem CommitDate: 2022-10-18 22:47:07 +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. MFC after: 1 month --- 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 f7a97ef04018..5a5b212ae584 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; @@ -6776,8 +6777,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); } @@ -6786,6 +6790,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. */ @@ -6813,8 +6855,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);