Author: mjg
Date: Tue Nov 20 14:59:27 2018
New Revision: 340677
URL: https://svnweb.freebsd.org/changeset/base/340677

Log:
  pipe: use unr64
  
  Reviewed by:  kib
  Sponsored by: The FreeBSD Foundation
  Differential Revision:        https://reviews.freebsd.org/D18054

Modified:
  head/sys/kern/sys_pipe.c

Modified: head/sys/kern/sys_pipe.c
==============================================================================
--- head/sys/kern/sys_pipe.c    Tue Nov 20 14:58:41 2018        (r340676)
+++ head/sys/kern/sys_pipe.c    Tue Nov 20 14:59:27 2018        (r340677)
@@ -244,7 +244,7 @@ static int  pipe_zone_init(void *mem, int size, int fla
 static void    pipe_zone_fini(void *mem, int size);
 
 static uma_zone_t pipe_zone;
-static struct unrhdr *pipeino_unr;
+static struct unrhdr64 pipeino_unr;
 static dev_t pipedev_ino;
 
 SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_ANY, pipeinit, NULL);
@@ -257,8 +257,7 @@ pipeinit(void *dummy __unused)
            pipe_zone_ctor, NULL, pipe_zone_init, pipe_zone_fini,
            UMA_ALIGN_PTR, 0);
        KASSERT(pipe_zone != NULL, ("pipe_zone not initialized"));
-       pipeino_unr = new_unrhdr(1, INT32_MAX, NULL);
-       KASSERT(pipeino_unr != NULL, ("pipe fake inodes not initialized"));
+       new_unrhdr64(&pipeino_unr, 1);
        pipedev_ino = devfs_alloc_cdp_inode();
        KASSERT(pipedev_ino > 0, ("pipe dev inode not initialized"));
 }
@@ -390,8 +389,6 @@ pipe_dtor(struct pipe *dpipe)
                funsetown(&peer->pipe_sigio);
                pipeclose(peer);
        }
-       if (ino != 0 && ino != (ino_t)-1)
-               free_unr(pipeino_unr, ino);
 }
 
 /*
@@ -639,7 +636,7 @@ pipe_create(struct pipe *pipe, int backing)
                        (void)pipespace_new(pipe, PIPE_SIZE);
        }
 
-       pipe->pipe_ino = -1;
+       pipe->pipe_ino = alloc_unr64(&pipeino_unr);
 }
 
 /* ARGSUSED */
@@ -1461,7 +1458,6 @@ pipe_stat(struct file *fp, struct stat *ub, struct ucr
     struct thread *td)
 {
        struct pipe *pipe;
-       int new_unr;
 #ifdef MAC
        int error;
 #endif
@@ -1482,23 +1478,6 @@ pipe_stat(struct file *fp, struct stat *ub, struct ucr
                return (vnops.fo_stat(fp, ub, active_cred, td));
        }
 
-       /*
-        * Lazily allocate an inode number for the pipe.  Most pipe
-        * users do not call fstat(2) on the pipe, which means that
-        * postponing the inode allocation until it is must be
-        * returned to userland is useful.  If alloc_unr failed,
-        * assign st_ino zero instead of returning an error.
-        * Special pipe_ino values:
-        *  -1 - not yet initialized;
-        *  0  - alloc_unr failed, return 0 as st_ino forever.
-        */
-       if (pipe->pipe_ino == (ino_t)-1) {
-               new_unr = alloc_unr(pipeino_unr);
-               if (new_unr != -1)
-                       pipe->pipe_ino = new_unr;
-               else
-                       pipe->pipe_ino = 0;
-       }
        PIPE_UNLOCK(pipe);
 
        bzero(ub, sizeof(*ub));
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to