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
This commit is contained in:
parent
5be4c55fea
commit
68a17869c1
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user