svn commit: r363586 - head/sys/fs/nfsserver

Rick Macklem rmacklem at FreeBSD.org
Sun Jul 26 23:03:42 UTC 2020


Author: rmacklem
Date: Sun Jul 26 23:03:41 2020
New Revision: 363586
URL: https://svnweb.freebsd.org/changeset/base/363586

Log:
  Fix the NFS server so that it sets va_birthtime.
  
  r362490 marked that the NFSv4 attribute TimeCreate (va_birthtime) is supported,
  but it did not change the NFS server code to actually do it.
  As such, errors could occur when unrolling a tarball onto an NFSv4 mounted
  volume, since setting TimeCreate would fail with a NFSERR_ATTRNOTSUPP reply.
  
  This patch fixes the server so that it does TimeCreate and also makes
  sure that TimeCreate will not be set for a DS file for a pNFS server.
  
  A separate commit will add a check to the NFSv4 client for support of
  the TimeCreate attribute before attempting to set it, to avoid a problem
  when mounting a server that does not support the attribute.
  The failures will still occur for r362490 or later kernels that do not
  have this patch, since they indicate support for the attribute, but do not
  actually support the attribute.

Modified:
  head/sys/fs/nfsserver/nfs_nfsdport.c

Modified: head/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdport.c	Sun Jul 26 22:30:55 2020	(r363585)
+++ head/sys/fs/nfsserver/nfs_nfsdport.c	Sun Jul 26 23:03:41 2020	(r363586)
@@ -459,6 +459,7 @@ nfsvno_setattr(struct vnode *vp, struct nfsvattr *nvap
 {
 	u_quad_t savsize = 0;
 	int error, savedit;
+	time_t savbtime;
 
 	/*
 	 * If this is an exported file system and a pNFS service is running,
@@ -490,9 +491,13 @@ nfsvno_setattr(struct vnode *vp, struct nfsvattr *nvap
 	    nvap->na_vattr.va_mode != (mode_t)VNOVAL ||
 	    nvap->na_vattr.va_atime.tv_sec != VNOVAL ||
 	    nvap->na_vattr.va_mtime.tv_sec != VNOVAL)) {
+		/* Never modify birthtime on a DS file. */
+		savbtime = nvap->na_vattr.va_birthtime.tv_sec;
+		nvap->na_vattr.va_birthtime.tv_sec = VNOVAL;
 		/* For a pNFS server, set the attributes on the DS file. */
 		error = nfsrv_proxyds(vp, 0, 0, cred, p, NFSPROC_SETATTR,
 		    NULL, NULL, NULL, nvap, NULL, NULL, 0, NULL);
+		nvap->na_vattr.va_birthtime.tv_sec = savbtime;
 		if (error == ENOENT)
 			error = 0;
 	}
@@ -2914,8 +2919,7 @@ nfsv4_sattr(struct nfsrv_descript *nd, vnode_t vp, str
 			break;
 		case NFSATTRBIT_TIMECREATE:
 			NFSM_DISSECT(tl, u_int32_t *, NFSX_V4TIME);
-			if (!nd->nd_repstat)
-				nd->nd_repstat = NFSERR_ATTRNOTSUPP;
+			fxdr_nfsv4time(tl, &nvap->na_btime);
 			attrsum += NFSX_V4TIME;
 			break;
 		case NFSATTRBIT_TIMEMODIFYSET:


More information about the svn-src-all mailing list