diff options
author | Kirk McKusick <mckusick@FreeBSD.org> | 2013-03-20 17:57:00 +0000 |
---|---|---|
committer | Kirk McKusick <mckusick@FreeBSD.org> | 2013-03-20 17:57:00 +0000 |
commit | 3289d5877a321a6e073875da5a1ab374f50fbbff (patch) | |
tree | 3142bd0a78d267ce0b86f3c2972bc8ca6b0764c0 /sys/kern/vfs_cache.c | |
parent | a2c472e741ff8682553464270bdef82b70635fdb (diff) | |
download | src-3289d5877a321a6e073875da5a1ab374f50fbbff.tar.gz src-3289d5877a321a6e073875da5a1ab374f50fbbff.zip |
When renaming a directory from one parent directory to another,
we need to call ufs_checkpath() to walk from our new location to
the root of the filesystem to ensure that we do not encounter
ourselves along the way. Until now, we accomplished this by reading
the ".." entries of each directory in our path until we reached
the root (or encountered an error). This change tries to avoid the
I/O of reading the ".." entries by first looking them up in the
name cache and only doing the I/O when the name cache lookup fails.
Reviewed by: kib
Tested by: Peter Holm
MFC after: 4 weeks
Notes
Notes:
svn path=/head/; revision=248561
Diffstat (limited to 'sys/kern/vfs_cache.c')
-rw-r--r-- | sys/kern/vfs_cache.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index aea71af52107..9eecc0992408 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -1359,6 +1359,28 @@ vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode *rdir, return (0); } +struct vnode * +vn_dir_dd_ino(struct vnode *vp) +{ + struct namecache *ncp; + struct vnode *ddvp; + + ASSERT_VOP_LOCKED(vp, "vn_dir_dd_ino"); + CACHE_RLOCK(); + TAILQ_FOREACH(ncp, &(vp->v_cache_dst), nc_dst) { + if ((ncp->nc_flag & NCF_ISDOTDOT) != 0) + continue; + ddvp = ncp->nc_dvp; + VI_LOCK(ddvp); + CACHE_RUNLOCK(); + if (vget(ddvp, LK_INTERLOCK | LK_SHARED | LK_NOWAIT, curthread)) + return (NULL); + return (ddvp); + } + CACHE_RUNLOCK(); + return (NULL); +} + int vn_commname(struct vnode *vp, char *buf, u_int buflen) { |