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
This commit is contained in:
Joe Marcus Clarke 2008-11-25 15:36:15 +00:00
parent effde07141
commit ef61995ebd
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=185298

View file

@ -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;