namecache: skip locking in cache_lookup_nomakeentry if there is no entry

This commit is contained in:
Mateusz Guzik 2017-11-05 21:59:39 +00:00
parent 6f74a1c952
commit ba324b5946

View File

@ -1163,6 +1163,9 @@ cache_lookup_nomakeentry(struct vnode *dvp, struct vnode **vpp,
hash = cache_get_hash(cnp->cn_nameptr, cnp->cn_namelen, dvp);
blp = HASH2BUCKETLOCK(hash);
retry:
if (LIST_EMPTY(NCHHASH(hash)))
goto out_no_entry;
rw_rlock(blp);
LIST_FOREACH(ncp, (NCHHASH(hash)), nc_hash) {
@ -1175,10 +1178,7 @@ cache_lookup_nomakeentry(struct vnode *dvp, struct vnode **vpp,
/* We failed to find an entry */
if (ncp == NULL) {
rw_runlock(blp);
SDT_PROBE3(vfs, namecache, lookup, miss, dvp, cnp->cn_nameptr,
NULL);
counter_u64_add(nummisszap, 1);
return (0);
goto out_no_entry;
}
counter_u64_add(numposzaps, 1);
@ -1191,6 +1191,10 @@ cache_lookup_nomakeentry(struct vnode *dvp, struct vnode **vpp,
}
cache_free(ncp);
return (0);
out_no_entry:
SDT_PROBE3(vfs, namecache, lookup, miss, dvp, cnp->cn_nameptr, NULL);
counter_u64_add(nummisszap, 1);
return (0);
}
int