svn commit: r351252 - in projects/nfsv42/sys/fs: nfs nfsserver

Rick Macklem rmacklem at FreeBSD.org
Tue Aug 20 17:00:32 UTC 2019


Author: rmacklem
Date: Tue Aug 20 17:00:31 2019
New Revision: 351252
URL: https://svnweb.freebsd.org/changeset/base/351252

Log:
  Fix nfsvno_seek()'s setting of eof.
  
  This repairs a bug introduced by yesterday's commit.

Modified:
  projects/nfsv42/sys/fs/nfs/nfs_var.h
  projects/nfsv42/sys/fs/nfsserver/nfs_nfsdport.c
  projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c

Modified: projects/nfsv42/sys/fs/nfs/nfs_var.h
==============================================================================
--- projects/nfsv42/sys/fs/nfs/nfs_var.h	Tue Aug 20 16:07:17 2019	(r351251)
+++ projects/nfsv42/sys/fs/nfs/nfs_var.h	Tue Aug 20 17:00:31 2019	(r351252)
@@ -725,8 +725,8 @@ int nfsrv_dscreate(struct vnode *, struct vattr *, str
 int nfsrv_updatemdsattr(struct vnode *, struct nfsvattr *, NFSPROC_T *);
 void nfsrv_killrpcs(struct nfsmount *);
 int nfsrv_setacl(struct vnode *, NFSACL_T *, struct ucred *, NFSPROC_T *);
-int nfsvno_seek(struct vnode *, u_long, off_t *, int, bool *, struct ucred *,
-    NFSPROC_T *);
+int nfsvno_seek(struct nfsrv_descript *, struct vnode *, u_long, off_t *, int,
+    bool *, struct ucred *, NFSPROC_T *);
 
 /* nfs_commonkrpc.c */
 int newnfs_nmcancelreqs(struct nfsmount *);

Modified: projects/nfsv42/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- projects/nfsv42/sys/fs/nfsserver/nfs_nfsdport.c	Tue Aug 20 16:07:17 2019	(r351251)
+++ projects/nfsv42/sys/fs/nfsserver/nfs_nfsdport.c	Tue Aug 20 17:00:31 2019	(r351252)
@@ -5829,10 +5829,10 @@ out:
  * Seek vnode op call (actually it is a VOP_IOCTL()).
  */
 int
-nfsvno_seek(struct vnode *vp, u_long cmd, off_t *offp, int content, bool *eofp,
-    struct ucred *cred, NFSPROC_T *p)
+nfsvno_seek(struct nfsrv_descript *nd, struct vnode *vp, u_long cmd,
+    off_t *offp, int content, bool *eofp, struct ucred *cred, NFSPROC_T *p)
 {
-	struct vattr va;
+	struct nfsvattr at;
 	int error, ret;
 
 	ASSERT_VOP_UNLOCKED(vp, "nfsvno_seek vp");
@@ -5848,22 +5848,19 @@ nfsvno_seek(struct vnode *vp, u_long cmd, off_t *offp,
 	/*
 	 * Do the VOP_IOCTL() call.  For the case where *offp == file_size,
 	 * VOP_IOCTL() will return ENXIO.  However, the correct reply for
-	 * NFSv4.2 is *eofp == true and no error return.
-	 * *eofp only needs to be set if returning error == 0.
+	 * NFSv4.2 is *eofp == true and error == 0 for this case.
 	 */
 	error = VOP_IOCTL(vp, cmd, offp, 0, cred, p);
-	if (error == 0)
-		*eofp = false;
-	else if (error == ENXIO) {
-		ret = vn_lock(vp, LK_SHARED);
-		if (ret == 0) {
-			ret = VOP_GETATTR(vp, &va, cred);
-			VOP_UNLOCK(vp, 0);
-		}
-		if (ret == 0 && *offp == va.va_size) {
+	*eofp = false;
+	if (error == ENXIO || (error == 0 && cmd == FIOSEEKHOLE)) {
+		/* Handle the cases where we might be at EOF. */
+		ret = nfsvno_getattr(vp, &at, nd, p, 0, NULL);
+		if (ret == 0 && *offp == at.na_size) {
 			*eofp = true;
 			error = 0;
 		}
+		if (ret != 0 && error == 0)
+			error = ret;
 	}
 	NFSEXITCODE(error);
 	return (error);

Modified: projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c
==============================================================================
--- projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c	Tue Aug 20 16:07:17 2019	(r351251)
+++ projects/nfsv42/sys/fs/nfsserver/nfs_nfsdserv.c	Tue Aug 20 17:00:31 2019	(r351252)
@@ -5457,8 +5457,8 @@ nfsrvd_seek(struct nfsrv_descript *nd, __unused int is
 		goto nfsmout;
 
 	NFSVOPUNLOCK(vp, 0);
-	nd->nd_repstat = nfsvno_seek(vp, cmd, &off, content, &eof, nd->nd_cred,
-	    curthread);
+	nd->nd_repstat = nfsvno_seek(nd, vp, cmd, &off, content, &eof,
+	    nd->nd_cred, curthread);
 	vrele(vp);
 	if (nd->nd_repstat == 0) {
 		NFSM_BUILD(tl, uint32_t *, NFSX_UNSIGNED + NFSX_HYPER);


More information about the svn-src-projects mailing list