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:
parent
4d7dfc31b8
commit
6084b6c9d5
@ -745,17 +745,17 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
|
||||
td->td_retval[0] = indx;
|
||||
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_flag = flags & FMASK;
|
||||
fp->f_ops = &vnops;
|
||||
fp->f_type = (vp->v_type == VFIFO ? DTYPE_FIFO : DTYPE_VNODE);
|
||||
FILEDESC_UNLOCK(fdp);
|
||||
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);
|
||||
if (flags & (O_EXLOCK | O_SHLOCK)) {
|
||||
lf.l_whence = SEEK_SET;
|
||||
|
@ -745,17 +745,17 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
|
||||
td->td_retval[0] = indx;
|
||||
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_flag = flags & FMASK;
|
||||
fp->f_ops = &vnops;
|
||||
fp->f_type = (vp->v_type == VFIFO ? DTYPE_FIFO : DTYPE_VNODE);
|
||||
FILEDESC_UNLOCK(fdp);
|
||||
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);
|
||||
if (flags & (O_EXLOCK | O_SHLOCK)) {
|
||||
lf.l_whence = SEEK_SET;
|
||||
|
Loading…
Reference in New Issue
Block a user