From 6084b6c9d5decc02587ea1f3a6152e567181b6b5 Mon Sep 17 00:00:00 2001 From: Don Lewis Date: Thu, 19 Jun 2003 04:10:56 +0000 Subject: [PATCH] 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. --- sys/kern/vfs_extattr.c | 10 +++++----- sys/kern/vfs_syscalls.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index 6d42736479d3..46ff3aa6a832 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -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; diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 6d42736479d3..46ff3aa6a832 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -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;