summaryrefslogtreecommitdiffstats
path: root/sys/fs/nullfs/null_vnops.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/fs/nullfs/null_vnops.c')
-rw-r--r--sys/fs/nullfs/null_vnops.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c
index fa87a24..66ccc7f 100644
--- a/sys/fs/nullfs/null_vnops.c
+++ b/sys/fs/nullfs/null_vnops.c
@@ -586,20 +586,33 @@ null_unlock(struct vop_unlock_args *ap)
{
struct vnode *vp = ap->a_vp;
int flags = ap->a_flags;
+ int mtxlkflag = 0;
struct thread *td = ap->a_td;
struct null_node *nn;
struct vnode *lvp;
int error;
- if ((flags & LK_INTERLOCK) != 0) {
- VI_UNLOCK(vp);
- ap->a_flags = flags &= ~LK_INTERLOCK;
+ if ((flags & LK_INTERLOCK) != 0)
+ mtxlkflag = 1;
+ else if (mtx_owned(VI_MTX(vp)) == 0) {
+ VI_LOCK(vp);
+ mtxlkflag = 2;
}
nn = VTONULL(vp);
- if (nn != NULL && (lvp = NULLVPTOLOWERVP(vp)) != NULL)
+ if (nn != NULL && (lvp = NULLVPTOLOWERVP(vp)) != NULL) {
+ VI_LOCK_FLAGS(lvp, MTX_DUPOK);
+ flags |= LK_INTERLOCK;
+ vholdl(lvp);
+ VI_UNLOCK(vp);
error = VOP_UNLOCK(lvp, flags, td);
- else
+ vdrop(lvp);
+ if (mtxlkflag == 0)
+ VI_LOCK(vp);
+ } else {
+ if (mtxlkflag == 2)
+ VI_UNLOCK(vp);
error = vop_stdunlock(ap);
+ }
return (error);
}
OpenPOWER on IntegriCloud