Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/vfs_cache.c
Show First 20 Lines • Show All 1,249 Lines • ▼ Show 20 Lines | |||||
cache_lookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, | cache_lookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, | ||||
struct timespec *tsp, int *ticksp) | struct timespec *tsp, int *ticksp) | ||||
{ | { | ||||
struct namecache_ts *ncp_ts; | struct namecache_ts *ncp_ts; | ||||
struct namecache *ncp; | struct namecache *ncp; | ||||
struct rwlock *blp; | struct rwlock *blp; | ||||
struct mtx *dvlp; | struct mtx *dvlp; | ||||
uint32_t hash; | uint32_t hash; | ||||
enum vgetstate vs; | |||||
int error, ltype; | int error, ltype; | ||||
if (__predict_false(!doingcache)) { | if (__predict_false(!doingcache)) { | ||||
cnp->cn_flags &= ~MAKEENTRY; | cnp->cn_flags &= ~MAKEENTRY; | ||||
return (0); | return (0); | ||||
} | } | ||||
counter_u64_add(numcalls, 1); | counter_u64_add(numcalls, 1); | ||||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | success: | ||||
* protocol. | * protocol. | ||||
*/ | */ | ||||
MPASS(dvp != *vpp); | MPASS(dvp != *vpp); | ||||
ltype = 0; /* silence gcc warning */ | ltype = 0; /* silence gcc warning */ | ||||
if (cnp->cn_flags & ISDOTDOT) { | if (cnp->cn_flags & ISDOTDOT) { | ||||
ltype = VOP_ISLOCKED(dvp); | ltype = VOP_ISLOCKED(dvp); | ||||
VOP_UNLOCK(dvp, 0); | VOP_UNLOCK(dvp, 0); | ||||
} | } | ||||
vhold(*vpp); | vs = vget_prep(*vpp); | ||||
cache_lookup_unlock(blp, dvlp); | cache_lookup_unlock(blp, dvlp); | ||||
error = vget(*vpp, cnp->cn_lkflags | LK_VNHELD, cnp->cn_thread); | error = vget_finish(*vpp, cnp->cn_lkflags, vs); | ||||
if (cnp->cn_flags & ISDOTDOT) { | if (cnp->cn_flags & ISDOTDOT) { | ||||
vn_lock(dvp, ltype | LK_RETRY); | vn_lock(dvp, ltype | LK_RETRY); | ||||
if (dvp->v_iflag & VI_DOOMED) { | if (dvp->v_iflag & VI_DOOMED) { | ||||
if (error == 0) | if (error == 0) | ||||
vput(*vpp); | vput(*vpp); | ||||
*vpp = NULL; | *vpp = NULL; | ||||
return (ENOENT); | return (ENOENT); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,042 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
struct vnode * | struct vnode * | ||||
vn_dir_dd_ino(struct vnode *vp) | vn_dir_dd_ino(struct vnode *vp) | ||||
{ | { | ||||
struct namecache *ncp; | struct namecache *ncp; | ||||
struct vnode *ddvp; | struct vnode *ddvp; | ||||
struct mtx *vlp; | struct mtx *vlp; | ||||
enum vgetstate vs; | |||||
ASSERT_VOP_LOCKED(vp, "vn_dir_dd_ino"); | ASSERT_VOP_LOCKED(vp, "vn_dir_dd_ino"); | ||||
vlp = VP2VNODELOCK(vp); | vlp = VP2VNODELOCK(vp); | ||||
mtx_lock(vlp); | mtx_lock(vlp); | ||||
TAILQ_FOREACH(ncp, &(vp->v_cache_dst), nc_dst) { | TAILQ_FOREACH(ncp, &(vp->v_cache_dst), nc_dst) { | ||||
if ((ncp->nc_flag & NCF_ISDOTDOT) != 0) | if ((ncp->nc_flag & NCF_ISDOTDOT) != 0) | ||||
continue; | continue; | ||||
ddvp = ncp->nc_dvp; | ddvp = ncp->nc_dvp; | ||||
vhold(ddvp); | vs = vget_prep(ddvp); | ||||
mtx_unlock(vlp); | mtx_unlock(vlp); | ||||
if (vget(ddvp, LK_SHARED | LK_NOWAIT | LK_VNHELD, curthread)) | if (vget_finish(ddvp, LK_SHARED | LK_NOWAIT, vs)) | ||||
return (NULL); | return (NULL); | ||||
return (ddvp); | return (ddvp); | ||||
} | } | ||||
mtx_unlock(vlp); | mtx_unlock(vlp); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
int | int | ||||
▲ Show 20 Lines • Show All 142 Lines • Show Last 20 Lines |