Author: mjoras
Date: Wed Oct 11 21:53:53 2017
New Revision: 324542
URL: https://svnweb.freebsd.org/changeset/base/324542

Log:
  When unmounting a tmpfs, do not call free_unr.
  
  tmpfs uses unr(9) to allocate inodes. Previously when unmounting it
  would individually free the units when it freed each vnode. This is
  unnecessary as we can use the newly-added unrhdr_clear function to clear
  out the unr in onde go. This measurably reduces the time to unmount a
  tmpfs with many files.
  
  Reviewed by:  cem, lidl
  Approved by:  rstone (mentor)
  Sponsored by: Dell EMC Isilon
  Differential Revision:        https://reviews.freebsd.org/D12591

Modified:
  head/sys/fs/tmpfs/tmpfs_subr.c
  head/sys/fs/tmpfs/tmpfs_vfsops.c

Modified: head/sys/fs/tmpfs/tmpfs_subr.c
==============================================================================
--- head/sys/fs/tmpfs/tmpfs_subr.c      Wed Oct 11 21:53:50 2017        
(r324541)
+++ head/sys/fs/tmpfs/tmpfs_subr.c      Wed Oct 11 21:53:53 2017        
(r324542)
@@ -362,7 +362,13 @@ tmpfs_free_node_locked(struct tmpfs_mount *tmp, struct
                panic("tmpfs_free_node: type %p %d", node, (int)node->tn_type);
        }
 
-       free_unr(tmp->tm_ino_unr, node->tn_id);
+       /*
+        * If we are unmounting there is no need for going through the overhead
+        * of freeing the inodes from the unr individually, so free them all in
+        * one go later.
+        */
+       if (!detach)
+               free_unr(tmp->tm_ino_unr, node->tn_id);
        uma_zfree(tmp->tm_node_pool, node);
        TMPFS_LOCK(tmp);
        tmpfs_free_tmp(tmp);

Modified: head/sys/fs/tmpfs/tmpfs_vfsops.c
==============================================================================
--- head/sys/fs/tmpfs/tmpfs_vfsops.c    Wed Oct 11 21:53:50 2017        
(r324541)
+++ head/sys/fs/tmpfs/tmpfs_vfsops.c    Wed Oct 11 21:53:53 2017        
(r324542)
@@ -317,6 +317,8 @@ tmpfs_unmount(struct mount *mp, int mntflags)
                        TMPFS_NODE_UNLOCK(node);
        }
 
+       clear_unrhdr(tmp->tm_ino_unr);
+
        mp->mnt_data = NULL;
        tmpfs_free_tmp(tmp);
        vfs_write_resume(mp, VR_START_WRITE);
_______________________________________________
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