Author: jhb
Date: Tue Dec 19 19:18:48 2017
New Revision: 326991
URL: https://svnweb.freebsd.org/changeset/base/326991

Log:
  Update NFS to handle larger link counts post ino64.
  
  - Define a NFS_LINK_MAX as UINT32_MAX to match the wire protocol.
  - Use NFS_LINK_MAX instead of LINK_MAX as the fallback value reported
    for a PATHCONF RPC by the NFS server.
  - Use NFS_LINK_MAX instead of LINK_MAX as the default value reported
    by the NFS client pathconf() if not overridden by the NFS server.
  - When reading the link count out of an RPC reply, read the full 32
    bits instead of the lower 16 bits.
  
  Reviewed by:  rmacklem (earlier version)
  Sponsored by: Chelsio Communications

Modified:
  head/sys/fs/nfs/nfs_commonport.c
  head/sys/fs/nfs/nfs_commonsubs.c
  head/sys/fs/nfs/nfsproto.h
  head/sys/fs/nfsclient/nfs_clcomsubs.c
  head/sys/fs/nfsclient/nfs_clvnops.c

Modified: head/sys/fs/nfs/nfs_commonport.c
==============================================================================
--- head/sys/fs/nfs/nfs_commonport.c    Tue Dec 19 19:14:01 2017        
(r326990)
+++ head/sys/fs/nfs/nfs_commonport.c    Tue Dec 19 19:18:48 2017        
(r326991)
@@ -331,7 +331,7 @@ nfsvno_pathconf(struct vnode *vp, int flag, register_t
                 */
                switch (flag) {
                case _PC_LINK_MAX:
-                       *retf = LINK_MAX;
+                       *retf = NFS_LINK_MAX;
                        break;
                case _PC_NAME_MAX:
                        *retf = NAME_MAX;

Modified: head/sys/fs/nfs/nfs_commonsubs.c
==============================================================================
--- head/sys/fs/nfs/nfs_commonsubs.c    Tue Dec 19 19:14:01 2017        
(r326990)
+++ head/sys/fs/nfs/nfs_commonsubs.c    Tue Dec 19 19:18:48 2017        
(r326991)
@@ -883,7 +883,7 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp,
                                NFSV3_FSFHOMOGENEOUS | NFSV3_FSFCANSETTIME);
                }
                if (pc != NULL) {
-                       pc->pc_linkmax = LINK_MAX;
+                       pc->pc_linkmax = NFS_LINK_MAX;
                        pc->pc_namemax = NAME_MAX;
                        pc->pc_notrunc = 0;
                        pc->pc_chownrestricted = 0;
@@ -1320,7 +1320,7 @@ nfsv4_loadattr(struct nfsrv_descript *nd, vnode_t vp,
                        NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED);
                        if (compare) {
                                if (!(*retcmpp)) {
-                                   if (fxdr_unsigned(int, *tl) != LINK_MAX)
+                                   if (fxdr_unsigned(int, *tl) != NFS_LINK_MAX)
                                        *retcmpp = NFSERR_NOTSAME;
                                }
                        } else if (pc != NULL) {

Modified: head/sys/fs/nfs/nfsproto.h
==============================================================================
--- head/sys/fs/nfs/nfsproto.h  Tue Dec 19 19:14:01 2017        (r326990)
+++ head/sys/fs/nfs/nfsproto.h  Tue Dec 19 19:18:48 2017        (r326991)
@@ -785,6 +785,8 @@ struct nfs_fattr {
 #define        fa3_mtime               fa_un.fa_nfsv3.nfsv3fa_mtime
 #define        fa3_ctime               fa_un.fa_nfsv3.nfsv3fa_ctime
 
+#define        NFS_LINK_MAX    UINT32_MAX
+
 struct nfsv2_sattr {
        u_int32_t sa_mode;
        u_int32_t sa_uid;

Modified: head/sys/fs/nfsclient/nfs_clcomsubs.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clcomsubs.c       Tue Dec 19 19:14:01 2017        
(r326990)
+++ head/sys/fs/nfsclient/nfs_clcomsubs.c       Tue Dec 19 19:18:48 2017        
(r326991)
@@ -433,7 +433,7 @@ nfsm_loadattr(struct nfsrv_descript *nd, struct nfsvat
                nap->na_mode = fxdr_unsigned(u_short, fp->fa_mode);
                nap->na_rdev = makedev(fxdr_unsigned(u_char, 
fp->fa3_rdev.specdata1),
                        fxdr_unsigned(u_char, fp->fa3_rdev.specdata2));
-               nap->na_nlink = fxdr_unsigned(u_short, fp->fa_nlink);
+               nap->na_nlink = fxdr_unsigned(uint32_t, fp->fa_nlink);
                nap->na_uid = fxdr_unsigned(uid_t, fp->fa_uid);
                nap->na_gid = fxdr_unsigned(gid_t, fp->fa_gid);
                nap->na_size = fxdr_hyper(&fp->fa3_size);

Modified: head/sys/fs/nfsclient/nfs_clvnops.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clvnops.c Tue Dec 19 19:14:01 2017        
(r326990)
+++ head/sys/fs/nfsclient/nfs_clvnops.c Tue Dec 19 19:18:48 2017        
(r326991)
@@ -3450,7 +3450,7 @@ nfs_pathconf(struct vop_pathconf_args *ap)
                 * For NFSv2 (or NFSv3 when not one of the above 4 a_names),
                 * just fake them.
                 */
-               pc.pc_linkmax = LINK_MAX;
+               pc.pc_linkmax = NFS_LINK_MAX;
                pc.pc_namemax = NFS_MAXNAMLEN;
                pc.pc_notrunc = 1;
                pc.pc_chownrestricted = 1;
@@ -3460,7 +3460,7 @@ nfs_pathconf(struct vop_pathconf_args *ap)
        }
        switch (ap->a_name) {
        case _PC_LINK_MAX:
-               *ap->a_retval = pc.pc_linkmax;
+               *ap->a_retval = MIN(LONG_MAX, pc.pc_linkmax);
                break;
        case _PC_NAME_MAX:
                *ap->a_retval = pc.pc_namemax;
_______________________________________________
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