diff options
author | John Baldwin <jhb@FreeBSD.org> | 2005-11-01 17:13:05 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2005-11-01 17:13:05 +0000 |
commit | 68a17869c12298c63e85d9cac9423444c3880460 (patch) | |
tree | bf091605957a60cbda2809e44420c2dc2709c89c /sys/kern/kern_descrip.c | |
parent | 5be4c55feaf02d53e16a23b3a2f2bb1ea8a8768b (diff) | |
download | src-68a17869c12298c63e85d9cac9423444c3880460.tar.gz src-68a17869c12298c63e85d9cac9423444c3880460.zip |
Push down Giant into fdfree() and remove it from two of the callers.
Other callers such as some rfork() cases weren't locking Giant anyway.
Reviewed by: csjp
MFC after: 1 week
Notes
Notes:
svn path=/head/; revision=151932
Diffstat (limited to 'sys/kern/kern_descrip.c')
-rw-r--r-- | sys/kern/kern_descrip.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 5bf15532ead6..eae5b9990856 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1525,10 +1525,10 @@ fdfree(struct thread *td) { struct filedesc *fdp; struct file **fpp; - int i; + int i, locked; struct filedesc_to_leader *fdtol; struct file *fp; - struct vnode *vp; + struct vnode *cdir, *jdir, *rdir, *vp; struct flock lf; /* Certain daemons might not have file descriptors. */ @@ -1559,13 +1559,14 @@ fdfree(struct thread *td) lf.l_len = 0; lf.l_type = F_UNLCK; vp = fp->f_vnode; - VFS_ASSERT_GIANT(vp->v_mount); + locked = VFS_LOCK_GIANT(vp->v_mount); (void) VOP_ADVLOCK(vp, (caddr_t)td->td_proc-> p_leader, F_UNLCK, &lf, F_POSIX); + VFS_UNLOCK_GIANT(locked); FILEDESC_LOCK(fdp); fdrop(fp, td); fpp = fdp->fd_ofiles + i; @@ -1635,18 +1636,30 @@ fdfree(struct thread *td) fdp->fd_nfiles = 0; - if (fdp->fd_cdir) - vrele(fdp->fd_cdir); + cdir = fdp->fd_cdir; fdp->fd_cdir = NULL; - if (fdp->fd_rdir) - vrele(fdp->fd_rdir); + rdir = fdp->fd_rdir; fdp->fd_rdir = NULL; - if (fdp->fd_jdir) - vrele(fdp->fd_jdir); + jdir = fdp->fd_jdir; fdp->fd_jdir = NULL; - FILEDESC_UNLOCK(fdp); + if (cdir) { + locked = VFS_LOCK_GIANT(cdir->v_mount); + vrele(cdir); + VFS_UNLOCK_GIANT(locked); + } + if (rdir) { + locked = VFS_LOCK_GIANT(rdir->v_mount); + vrele(rdir); + VFS_UNLOCK_GIANT(locked); + } + if (jdir) { + locked = VFS_LOCK_GIANT(jdir->v_mount); + vrele(jdir); + VFS_UNLOCK_GIANT(locked); + } + fddrop(fdp); } |