Author: jhb
Date: Mon Sep 18 23:30:39 2017
New Revision: 323723
URL: https://svnweb.freebsd.org/changeset/base/323723

Log:
  Add UFS_LINK_MAX for the UFS-specific limit on link counts.
  
  ino64 expanded nlink_t to 64 bits, but the on-disk format for UFS is still
  limited to 16 bits.  This is a nop currently but will matter if LINK_MAX is
  increased in the future.
  
  Reviewed by:  kib
  Sponsored by: Chelsio Communications

Modified:
  head/sys/ufs/ffs/ffs_softdep.c
  head/sys/ufs/ufs/dinode.h
  head/sys/ufs/ufs/ufs_vnops.c

Modified: head/sys/ufs/ffs/ffs_softdep.c
==============================================================================
--- head/sys/ufs/ffs/ffs_softdep.c      Mon Sep 18 20:22:42 2017        
(r323722)
+++ head/sys/ufs/ffs/ffs_softdep.c      Mon Sep 18 23:30:39 2017        
(r323723)
@@ -11532,7 +11532,7 @@ handle_written_inodeblock(inodedep, bp, flags)
         */
        if (inodedep->id_savedsize == -1 || inodedep->id_savedextsize == -1)
                panic("handle_written_inodeblock: bad size");
-       if (inodedep->id_savednlink > LINK_MAX)
+       if (inodedep->id_savednlink > UFS_LINK_MAX)
                panic("handle_written_inodeblock: Invalid link count "
                    "%jd for inodedep %p", (uintmax_t)inodedep->id_savednlink,
                    inodedep);

Modified: head/sys/ufs/ufs/dinode.h
==============================================================================
--- head/sys/ufs/ufs/dinode.h   Mon Sep 18 20:22:42 2017        (r323722)
+++ head/sys/ufs/ufs/dinode.h   Mon Sep 18 23:30:39 2017        (r323723)
@@ -186,4 +186,6 @@ struct ufs1_dinode {
        u_int64_t       di_modrev;      /* 120: i_modrev for NFSv4 */
 };
 
+#define        UFS_LINK_MAX    32767
+
 #endif /* _UFS_UFS_DINODE_H_ */

Modified: head/sys/ufs/ufs/ufs_vnops.c
==============================================================================
--- head/sys/ufs/ufs/ufs_vnops.c        Mon Sep 18 20:22:42 2017        
(r323722)
+++ head/sys/ufs/ufs/ufs_vnops.c        Mon Sep 18 23:30:39 2017        
(r323723)
@@ -981,7 +981,7 @@ ufs_link(ap)
                goto out;
        }
        ip = VTOI(vp);
-       if ((nlink_t)ip->i_nlink >= LINK_MAX) {
+       if (ip->i_nlink >= UFS_LINK_MAX) {
                error = EMLINK;
                goto out;
        }
@@ -1266,7 +1266,7 @@ relock:
        doingdirectory = 0;
        newparent = 0;
        ino = fip->i_number;
-       if (fip->i_nlink >= LINK_MAX) {
+       if (fip->i_nlink >= UFS_LINK_MAX) {
                error = EMLINK;
                goto unlockout;
        }
@@ -1369,7 +1369,7 @@ relock:
                         * actual link modification is completed when
                         * .. is rewritten below.
                         */
-                       if ((nlink_t)tdp->i_nlink >= LINK_MAX) {
+                       if (tdp->i_nlink >= UFS_LINK_MAX) {
                                error = EMLINK;
                                goto bad;
                        }
@@ -1793,7 +1793,7 @@ ufs_mkdir(ap)
                panic("ufs_mkdir: no name");
 #endif
        dp = VTOI(dvp);
-       if ((nlink_t)dp->i_nlink >= LINK_MAX) {
+       if (dp->i_nlink >= UFS_LINK_MAX) {
                error = EMLINK;
                goto out;
        }
@@ -2442,6 +2442,9 @@ ufs_pathconf(ap)
 
        error = 0;
        switch (ap->a_name) {
+       case _PC_LINK_MAX:
+               *ap->a_retval = UFS_LINK_MAX;
+               break;
        case _PC_NAME_MAX:
                *ap->a_retval = UFS_MAXNAMLEN;
                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