Author: mjg
Date: Thu Jan 21 01:09:39 2016
New Revision: 294478
URL: https://svnweb.freebsd.org/changeset/base/294478

Log:
  cache: minor changes
  
  1. vhold and zap immediately instead of postponing few lines later
  2. increment numneg after new entry is added
  
  No functional changes.
  
  No objections:                kib

Modified:
  head/sys/kern/vfs_cache.c

Modified: head/sys/kern/vfs_cache.c
==============================================================================
--- head/sys/kern/vfs_cache.c   Thu Jan 21 01:07:05 2016        (r294477)
+++ head/sys/kern/vfs_cache.c   Thu Jan 21 01:09:39 2016        (r294478)
@@ -723,8 +723,6 @@ cache_enter_time(struct vnode *dvp, stru
        struct nchashhead *ncpp;
        uint32_t hash;
        int flag;
-       int hold;
-       int zap;
        int len;
 
        CTR3(KTR_VFS, "cache_enter(%p, %p, %s)", dvp, vp, cnp->cn_nameptr);
@@ -782,9 +780,6 @@ cache_enter_time(struct vnode *dvp, stru
                }
        }
 
-       hold = 0;
-       zap = 0;
-
        /*
         * Calculate the hash key and setup as much of the new
         * namecache entry as possible before acquiring the lock.
@@ -855,24 +850,22 @@ cache_enter_time(struct vnode *dvp, stru
        }
 
        numcache++;
-       if (vp == NULL) {
-               numneg++;
-               if (cnp->cn_flags & ISWHITEOUT)
-                       ncp->nc_flag |= NCF_WHITE;
-       } else if (vp->v_type == VDIR) {
-               if (flag != NCF_ISDOTDOT) {
-                       /*
-                        * For this case, the cache entry maps both the
-                        * directory name in it and the name ".." for the
-                        * directory's parent.
-                        */
-                       if ((n2 = vp->v_cache_dd) != NULL &&
-                           (n2->nc_flag & NCF_ISDOTDOT) != 0)
-                               cache_zap(n2);
-                       vp->v_cache_dd = ncp;
+       if (vp != NULL) {
+               if (vp->v_type == VDIR) {
+                       if (flag != NCF_ISDOTDOT) {
+                               /*
+                                * For this case, the cache entry maps both the
+                                * directory name in it and the name ".." for 
the
+                                * directory's parent.
+                                */
+                               if ((n2 = vp->v_cache_dd) != NULL &&
+                                   (n2->nc_flag & NCF_ISDOTDOT) != 0)
+                                       cache_zap(n2);
+                               vp->v_cache_dd = ncp;
+                       }
+               } else {
+                       vp->v_cache_dd = NULL;
                }
-       } else {
-               vp->v_cache_dd = NULL;
        }
 
        /*
@@ -882,7 +875,7 @@ cache_enter_time(struct vnode *dvp, stru
        LIST_INSERT_HEAD(ncpp, ncp, nc_hash);
        if (flag != NCF_ISDOTDOT) {
                if (LIST_EMPTY(&dvp->v_cache_src)) {
-                       hold = 1;
+                       vhold(dvp);
                        numcachehv++;
                }
                LIST_INSERT_HEAD(&dvp->v_cache_src, ncp, nc_src);
@@ -898,7 +891,10 @@ cache_enter_time(struct vnode *dvp, stru
                SDT_PROBE3(vfs, namecache, enter, done, dvp, nc_get_name(ncp),
                    vp);
        } else {
+               if (cnp->cn_flags & ISWHITEOUT)
+                       ncp->nc_flag |= NCF_WHITE;
                TAILQ_INSERT_TAIL(&ncneg, ncp, nc_dst);
+               numneg++;
                SDT_PROBE2(vfs, namecache, enter_negative, done, dvp,
                    nc_get_name(ncp));
        }
@@ -906,12 +902,8 @@ cache_enter_time(struct vnode *dvp, stru
                ncp = TAILQ_FIRST(&ncneg);
                KASSERT(ncp->nc_vp == NULL, ("ncp %p vp %p on ncneg",
                    ncp, ncp->nc_vp));
-               zap = 1;
-       }
-       if (hold)
-               vhold(dvp);
-       if (zap)
                cache_zap(ncp);
+       }
        CACHE_WUNLOCK();
 }
 
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to