diff options
author | jhb <jhb@FreeBSD.org> | 2005-11-01 17:13:05 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2005-11-01 17:13:05 +0000 |
commit | 2eddf38ca6603759a7a97d99379fa80288915826 (patch) | |
tree | bf091605957a60cbda2809e44420c2dc2709c89c /sys/kern | |
parent | 85cdb26faeb92a931e335252d6eac61240aaaf03 (diff) | |
download | FreeBSD-src-2eddf38ca6603759a7a97d99379fa80288915826.zip FreeBSD-src-2eddf38ca6603759a7a97d99379fa80288915826.tar.gz |
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
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_descrip.c | 33 | ||||
-rw-r--r-- | sys/kern/kern_exit.c | 2 | ||||
-rw-r--r-- | sys/kern/vfs_aio.c | 2 |
3 files changed, 24 insertions, 13 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 5bf1553..eae5b99 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); } diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 25ca5b8..6107a00 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -235,6 +235,7 @@ retry: */ mtx_lock(&Giant); /* XXX: not sure if needed */ funsetownlst(&p->p_sigiolst); + mtx_unlock(&Giant); /* * If this process has an nlminfo data area (for lockd), release it @@ -247,7 +248,6 @@ retry: * This may block! */ fdfree(td); - mtx_unlock(&Giant); /* * If this thread tickled GEOM, we need to wait for the giggling to diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c index 007d1ed..b39f1a6 100644 --- a/sys/kern/vfs_aio.c +++ b/sys/kern/vfs_aio.c @@ -894,10 +894,8 @@ aio_daemon(void *uproc) * Get rid of our current filedescriptors. AIOD's don't need any * filedescriptors, except as temporarily inherited from the client. */ - mtx_lock(&Giant); fdfree(td); - mtx_unlock(&Giant); /* The daemon resides in its own pgrp. */ MALLOC(newpgrp, struct pgrp *, sizeof(struct pgrp), M_PGRP, M_WAITOK | M_ZERO); |