git: f32bf50d43be - main - nfsd: Fix handling of Open/Create for the pNFS server

From: Rick Macklem <rmacklem_at_FreeBSD.org>
Date: Wed, 04 May 2022 20:54:01 UTC
The branch main has been updated by rmacklem:

URL: https://cgit.FreeBSD.org/src/commit/?id=f32bf50d43be1e898cebf751ce749b07d1301b8f

commit f32bf50d43be1e898cebf751ce749b07d1301b8f
Author:     Rick Macklem <rmacklem@FreeBSD.org>
AuthorDate: 2022-05-04 20:52:33 +0000
Commit:     Rick Macklem <rmacklem@FreeBSD.org>
CommitDate: 2022-05-04 20:52:33 +0000

    nfsd: Fix handling of Open/Create for the pNFS server
    
    When the MDS of a pNFS service receives an Open/Create
    and the file already exists, it must do a Setattr of
    size == 0.  Without this patch, this was eroneously
    done via a VOP_SETAATR() call, which would set the
    length of the MDS file to 0 (which is already is,
    since all data lives on the DSs).
    
    This patch fixes the problem by doing a nfsvno_setattr()
    instead of VOP_SETATTR(), which knows to do a proxied
    Setattr on the DSs.
    
    For a non-pNFS server, the change has no effect, since
    nfsvno_setattr() only does a VOP_SETATTR() for that case.
    
    This was found during a recent IETF NFSv4 testing event.
    
    MFC after:      2 weeks
---
 sys/fs/nfsserver/nfs_nfsdport.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c
index 5dbe20f7a66a..c9238de00bea 100644
--- a/sys/fs/nfsserver/nfs_nfsdport.c
+++ b/sys/fs/nfsserver/nfs_nfsdport.c
@@ -1260,8 +1260,8 @@ nfsvno_createsub(struct nfsrv_descript *nd, struct nameidata *ndp,
 				tempsize = nvap->na_size;
 				NFSVNO_ATTRINIT(nvap);
 				nvap->na_size = tempsize;
-				error = VOP_SETATTR(*vpp,
-				    &nvap->na_vattr, nd->nd_cred);
+				error = nfsvno_setattr(*vpp, nvap,
+				    nd->nd_cred, p, exp);
 			}
 		}
 		if (error)
@@ -1930,8 +1930,8 @@ nfsvno_open(struct nfsrv_descript *nd, struct nameidata *ndp,
 					tempsize = nvap->na_size;
 					NFSVNO_ATTRINIT(nvap);
 					nvap->na_size = tempsize;
-					nd->nd_repstat = VOP_SETATTR(vp,
-					    &nvap->na_vattr, cred);
+					nd->nd_repstat = nfsvno_setattr(vp,
+					    nvap, cred, p, exp);
 				}
 			} else if (vp->v_type == VREG) {
 				nd->nd_repstat = nfsrv_opencheck(clientid,