Date: Tue, 25 Nov 2008 15:36:15 +0000 (UTC) From: Joe Marcus Clarke <marcus@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r185298 - head/sys/kern Message-ID: <200811251536.mAPFaFJp027420@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marcus (doc,ports committer) Date: Tue Nov 25 15:36:15 2008 New Revision: 185298 URL: http://svn.freebsd.org/changeset/base/185298 Log: 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 Modified: head/sys/kern/vfs_cache.c Modified: head/sys/kern/vfs_cache.c ============================================================================== --- head/sys/kern/vfs_cache.c Tue Nov 25 14:14:58 2008 (r185297) +++ head/sys/kern/vfs_cache.c Tue Nov 25 15:36:15 2008 (r185298) @@ -716,7 +716,8 @@ kern___getcwd(struct thread *td, u_char { 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 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 vn { 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 vn 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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811251536.mAPFaFJp027420>