Author: rmacklem
Date: Sun Jul 26 23:13:10 2020
New Revision: 363587
URL: https://svnweb.freebsd.org/changeset/base/363587

Log:
  Fix the NFSv4 client so that it checks for support of TimeCreate before
  trying to set it.
  
  r362490 added support for setting of the TimeCreate (va_birthtime) attribute,
  but it does so without checking to see if the server supports the attribute.
  This could result in NFSERR_ATTRNOTSUPP error replies to the Setattr 
operation.
  This patch adds code to check that the server supports TimeCreate before
  attempting to do a Setattr of it to avoid these error returns.

Modified:
  head/sys/fs/nfs/nfs_commonsubs.c

Modified: head/sys/fs/nfs/nfs_commonsubs.c
==============================================================================
--- head/sys/fs/nfs/nfs_commonsubs.c    Sun Jul 26 23:03:41 2020        
(r363586)
+++ head/sys/fs/nfs/nfs_commonsubs.c    Sun Jul 26 23:13:10 2020        
(r363587)
@@ -504,6 +504,7 @@ nfscl_fillsattr(struct nfsrv_descript *nd, struct vatt
        u_int32_t *tl;
        struct nfsv2_sattr *sp;
        nfsattrbit_t attrbits;
+       struct nfsnode *np;
 
        switch (nd->nd_flag & (ND_NFSV2 | ND_NFSV3 | ND_NFSV4)) {
        case ND_NFSV2:
@@ -605,8 +606,18 @@ nfscl_fillsattr(struct nfsrv_descript *nd, struct vatt
                        NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_TIMEACCESSSET);
                if (vap->va_mtime.tv_sec != VNOVAL)
                        NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_TIMEMODIFYSET);
-               if (vap->va_birthtime.tv_sec != VNOVAL)
-                       NFSSETBIT_ATTRBIT(&attrbits, NFSATTRBIT_TIMECREATE);
+               if (vap->va_birthtime.tv_sec != VNOVAL &&
+                   strcmp(vp->v_mount->mnt_vfc->vfc_name, "nfs") == 0) {
+                       /*
+                        * We can only test for support of TimeCreate if
+                        * the "vp" argument is for an NFS vnode.
+                        */
+                       np = VTONFS(vp);
+                       if (NFSISSET_ATTRBIT(&np->n_vattr.na_suppattr,
+                           NFSATTRBIT_TIMECREATE))
+                               NFSSETBIT_ATTRBIT(&attrbits,
+                                   NFSATTRBIT_TIMECREATE);
+               }
                (void) nfsv4_fillattr(nd, vp->v_mount, vp, NULL, vap, NULL, 0,
                    &attrbits, NULL, NULL, 0, 0, 0, 0, (uint64_t)0, NULL);
                break;
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to