FILE_LOCK() uses a pool mutex, as does the vnode v_vnlock. Since pool

mutexes are supposed to only be used as leaf mutexes, and what appear
to be separate pool mutexes could be aliased together, it is bad idea
for a thread to attempt to hold two pool mutexes at the same time.

Slightly rearrange the code in kern_open() so that FILE_UNLOCK() is
called before calling VOP_GETVOBJECT(), which will grab the v_vnlock
mutex.
This commit is contained in:
Don Lewis 2003-06-19 04:10:56 +00:00
parent 4d7dfc31b8
commit 6084b6c9d5
2 changed files with 10 additions and 10 deletions

View File

@ -745,17 +745,17 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
td->td_retval[0] = indx; td->td_retval[0] = indx;
return 0; return 0;
} }
/* assert that vn_open created a backing object if one is needed */
KASSERT(!vn_canvmio(vp) || VOP_GETVOBJECT(vp, NULL) == 0,
("open: vmio vnode has no backing object after vn_open"));
fp->f_data = vp; fp->f_data = vp;
fp->f_flag = flags & FMASK; fp->f_flag = flags & FMASK;
fp->f_ops = &vnops; fp->f_ops = &vnops;
fp->f_type = (vp->v_type == VFIFO ? DTYPE_FIFO : DTYPE_VNODE); fp->f_type = (vp->v_type == VFIFO ? DTYPE_FIFO : DTYPE_VNODE);
FILEDESC_UNLOCK(fdp); FILEDESC_UNLOCK(fdp);
FILE_UNLOCK(fp); FILE_UNLOCK(fp);
/* assert that vn_open created a backing object if one is needed */
KASSERT(!vn_canvmio(vp) || VOP_GETVOBJECT(vp, NULL) == 0,
("open: vmio vnode has no backing object after vn_open"));
VOP_UNLOCK(vp, 0, td); VOP_UNLOCK(vp, 0, td);
if (flags & (O_EXLOCK | O_SHLOCK)) { if (flags & (O_EXLOCK | O_SHLOCK)) {
lf.l_whence = SEEK_SET; lf.l_whence = SEEK_SET;

View File

@ -745,17 +745,17 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
td->td_retval[0] = indx; td->td_retval[0] = indx;
return 0; return 0;
} }
/* assert that vn_open created a backing object if one is needed */
KASSERT(!vn_canvmio(vp) || VOP_GETVOBJECT(vp, NULL) == 0,
("open: vmio vnode has no backing object after vn_open"));
fp->f_data = vp; fp->f_data = vp;
fp->f_flag = flags & FMASK; fp->f_flag = flags & FMASK;
fp->f_ops = &vnops; fp->f_ops = &vnops;
fp->f_type = (vp->v_type == VFIFO ? DTYPE_FIFO : DTYPE_VNODE); fp->f_type = (vp->v_type == VFIFO ? DTYPE_FIFO : DTYPE_VNODE);
FILEDESC_UNLOCK(fdp); FILEDESC_UNLOCK(fdp);
FILE_UNLOCK(fp); FILE_UNLOCK(fp);
/* assert that vn_open created a backing object if one is needed */
KASSERT(!vn_canvmio(vp) || VOP_GETVOBJECT(vp, NULL) == 0,
("open: vmio vnode has no backing object after vn_open"));
VOP_UNLOCK(vp, 0, td); VOP_UNLOCK(vp, 0, td);
if (flags & (O_EXLOCK | O_SHLOCK)) { if (flags & (O_EXLOCK | O_SHLOCK)) {
lf.l_whence = SEEK_SET; lf.l_whence = SEEK_SET;