vn_setrecurse: if no lock is exported, use v_lock. Works around issue

described in PR kern/37808. The ideal solution here is to kill vnode
lock recursion, which should not be hard once it is understood what
the two remaining callers of vn_setrecurse() are doing.
This commit is contained in:
ad 2008-01-25 14:37:33 +00:00
parent dd1ca367a6
commit 38076b60ea

View File

@ -1,4 +1,4 @@
/* $NetBSD: vfs_vnops.c,v 1.152 2008/01/25 14:32:15 ad Exp $ */ /* $NetBSD: vfs_vnops.c,v 1.153 2008/01/25 14:37:33 ad Exp $ */
/* /*
* Copyright (c) 1982, 1986, 1989, 1993 * Copyright (c) 1982, 1986, 1989, 1993
@ -37,7 +37,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.152 2008/01/25 14:32:15 ad Exp $"); __KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.153 2008/01/25 14:37:33 ad Exp $");
#include "fs_union.h" #include "fs_union.h"
#include "veriexec.h" #include "veriexec.h"
@ -717,9 +717,11 @@ vn_closefile(struct file *fp, struct lwp *l)
u_int u_int
vn_setrecurse(struct vnode *vp) vn_setrecurse(struct vnode *vp)
{ {
struct lock *lkp = vp->v_vnlock; struct lock *lkp;
u_int retval; u_int retval;
lkp = (vp->v_vnlock != NULL ? vp->v_vnlock : &vp->v_lock);
mutex_enter(&lkp->lk_interlock); mutex_enter(&lkp->lk_interlock);
retval = lkp->lk_flags & LK_CANRECURSE; retval = lkp->lk_flags & LK_CANRECURSE;
lkp->lk_flags |= LK_CANRECURSE; lkp->lk_flags |= LK_CANRECURSE;
@ -734,7 +736,9 @@ vn_setrecurse(struct vnode *vp)
void void
vn_restorerecurse(struct vnode *vp, u_int flags) vn_restorerecurse(struct vnode *vp, u_int flags)
{ {
struct lock *lkp = vp->v_vnlock; struct lock *lkp;
lkp = (vp->v_vnlock != NULL ? vp->v_vnlock : &vp->v_lock);
mutex_enter(&lkp->lk_interlock); mutex_enter(&lkp->lk_interlock);
lkp->lk_flags &= ~LK_CANRECURSE; lkp->lk_flags &= ~LK_CANRECURSE;