summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_cache.c
diff options
context:
space:
mode:
authormjg <mjg@FreeBSD.org>2016-01-21 01:09:39 +0000
committermjg <mjg@FreeBSD.org>2016-01-21 01:09:39 +0000
commit0b0166a1921bd25a662685abe2a140ee64582632 (patch)
tree66e3d6bae256c298abe04710a0a1061c3c6f80e3 /sys/kern/vfs_cache.c
parentfc47375f708d509e4540707e61780731d42a328a (diff)
downloadFreeBSD-src-0b0166a1921bd25a662685abe2a140ee64582632.zip
FreeBSD-src-0b0166a1921bd25a662685abe2a140ee64582632.tar.gz
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
Diffstat (limited to 'sys/kern/vfs_cache.c')
-rw-r--r--sys/kern/vfs_cache.c48
1 files changed, 20 insertions, 28 deletions
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index 7a7b882..ff2ad21 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -723,8 +723,6 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, struct componentname *cnp,
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, struct vnode *vp, struct componentname *cnp,
}
}
- 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, struct vnode *vp, struct componentname *cnp,
}
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, struct vnode *vp, struct componentname *cnp,
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, struct vnode *vp, struct componentname *cnp,
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, struct vnode *vp, struct componentname *cnp,
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();
}
OpenPOWER on IntegriCloud