Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Oct 2019 05:50:57 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r353676 - projects/nfsv42/sys/fs/nfsclient
Message-ID:  <201910170550.x9H5ovHS010472@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Thu Oct 17 05:50:57 2019
New Revision: 353676
URL: https://svnweb.freebsd.org/changeset/base/353676

Log:
  Patch the NFSv4.2 client side Copy for the Linux server.
  
  RFC-7862 states that a Copy request with offset or offset + len greater
  than file size should fail with NFSERR_INVAL. However the Linux NFSv4.2
  server replies with a length of 0.
  This patch translates this case into NFSERR_INVAL.

Modified:
  projects/nfsv42/sys/fs/nfsclient/nfs_clvnops.c

Modified: projects/nfsv42/sys/fs/nfsclient/nfs_clvnops.c
==============================================================================
--- projects/nfsv42/sys/fs/nfsclient/nfs_clvnops.c	Thu Oct 17 01:30:37 2019	(r353675)
+++ projects/nfsv42/sys/fs/nfsclient/nfs_clvnops.c	Thu Oct 17 05:50:57 2019	(r353676)
@@ -3542,8 +3542,9 @@ nfs_copy_file_range(struct vop_copy_file_range_args *a
 
 	nmp = VFSTONFS(invp->v_mount);
 	mtx_lock(&nmp->nm_mtx);
+	/* NFSv4.2 Copy is not permitted for infile == outfile. */
 	if (!NFSHASNFSV4(nmp) || nmp->nm_minorvers < NFSV42_MINORVERSION ||
-	    (nmp->nm_privflag & NFSMNTP_NOCOPY) != 0) {
+	    (nmp->nm_privflag & NFSMNTP_NOCOPY) != 0 || invp == outvp) {
 		mtx_unlock(&nmp->nm_mtx);
 		error = vn_generic_copy_file_range(ap->a_invp, ap->a_inoffp,
 		    ap->a_outvp, ap->a_outoffp, ap->a_lenp, ap->a_flags,
@@ -3633,6 +3634,15 @@ nfs_copy_file_range(struct vop_copy_file_range_args *a
 			    1, 1);
 			if (error == 0 && ret != 0)
 				error = ret;
+		}
+		if (error == 0 && len2 == 0) {
+			/*
+			 * Some Linux NFSv4.2 servers can reply NFS_OK, but
+			 * with a copied length (wr_count) == 0 when the
+			 * offset + len is past EOF. (RFC-7862 requires a
+			 * reply of NFS4ERR_INVAL for this case.)
+			 */
+			error = NFSERR_INVAL;
 		}
 		if (error == 0) {
 			if (consecutive == false) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910170550.x9H5ovHS010472>