diff options
author | Joe Marcus Clarke <marcus@FreeBSD.org> | 2008-11-25 15:36:15 +0000 |
---|---|---|
committer | Joe Marcus Clarke <marcus@FreeBSD.org> | 2008-11-25 15:36:15 +0000 |
commit | ef61995ebd2af55678578d9538a917206e0b43c0 (patch) | |
tree | f46c23d80354763582c27fcbef9b8a3328da9ece | |
parent | effde07141649911a3439de28168aca4b5697601 (diff) | |
download | src-ef61995ebd2af55678578d9538a917206e0b43c0.tar.gz src-ef61995ebd2af55678578d9538a917206e0b43c0.zip |
Move vn_fullpath1() outside of FILEDESC locking. This is being done in
advance of teaching vn_fullpath1() how to query file systems for
vnode-to-name mappings when cache lookups fail.
Thanks to kib for guidance and patience on this process.
Reviewed by: kib
Approved by: kib
Notes
Notes:
svn path=/head/; revision=185298
-rw-r--r-- | sys/kern/vfs_cache.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 33e8759c97ff..d6937b7ca64e 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -716,7 +716,8 @@ kern___getcwd(struct thread *td, u_char *buf, enum uio_seg bufseg, u_int buflen) { char *bp, *tmpbuf; struct filedesc *fdp; - int error; + struct vnode *cdir, *rdir; + int error, vfslocked; if (disablecwd) return (ENODEV); @@ -728,9 +729,18 @@ kern___getcwd(struct thread *td, u_char *buf, enum uio_seg bufseg, u_int buflen) tmpbuf = malloc(buflen, M_TEMP, M_WAITOK); fdp = td->td_proc->p_fd; FILEDESC_SLOCK(fdp); - error = vn_fullpath1(td, fdp->fd_cdir, fdp->fd_rdir, tmpbuf, - &bp, buflen); + cdir = fdp->fd_cdir; + VREF(cdir); + rdir = fdp->fd_rdir; + VREF(rdir); FILEDESC_SUNLOCK(fdp); + error = vn_fullpath1(td, cdir, rdir, tmpbuf, &bp, buflen); + vfslocked = VFS_LOCK_GIANT(rdir->v_mount); + vrele(rdir); + VFS_UNLOCK_GIANT(vfslocked); + vfslocked = VFS_LOCK_GIANT(cdir->v_mount); + vrele(cdir); + VFS_UNLOCK_GIANT(vfslocked); if (!error) { if (bufseg == UIO_SYSSPACE) @@ -771,7 +781,8 @@ vn_fullpath(struct thread *td, struct vnode *vn, char **retbuf, char **freebuf) { char *buf; struct filedesc *fdp; - int error; + struct vnode *rdir; + int error, vfslocked; if (disablefullpath) return (ENODEV); @@ -781,8 +792,13 @@ vn_fullpath(struct thread *td, struct vnode *vn, char **retbuf, char **freebuf) buf = malloc(MAXPATHLEN, M_TEMP, M_WAITOK); fdp = td->td_proc->p_fd; FILEDESC_SLOCK(fdp); - error = vn_fullpath1(td, vn, fdp->fd_rdir, buf, retbuf, MAXPATHLEN); + rdir = fdp->fd_rdir; + VREF(rdir); FILEDESC_SUNLOCK(fdp); + error = vn_fullpath1(td, vn, rdir, buf, retbuf, MAXPATHLEN); + vfslocked = VFS_LOCK_GIANT(rdir->v_mount); + vrele(rdir); + VFS_UNLOCK_GIANT(vfslocked); if (!error) *freebuf = buf; |