Remove the concept of recursive vnode locks by eliminating
vn_setrecurse(), vn_restorerecurse() and LK_CANRECURSE. Welcome to 5.99.31 Discussed on tech-kern.
This commit is contained in:
parent
339c26b8f0
commit
2c090918c7
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: mi,v 1.1467 2010/06/18 04:21:22 mrg Exp $
|
||||
# $NetBSD: mi,v 1.1468 2010/06/18 16:29:01 hannken Exp $
|
||||
#
|
||||
# Note: don't delete entries from here - mark them as "obsolete" instead.
|
||||
#
|
||||
|
@ -9880,8 +9880,8 @@
|
|||
./usr/share/man/cat9/vn_poll.0 comp-sys-catman .cat
|
||||
./usr/share/man/cat9/vn_rdwr.0 comp-sys-catman .cat
|
||||
./usr/share/man/cat9/vn_read.0 comp-sys-catman .cat
|
||||
./usr/share/man/cat9/vn_restorerecurse.0 comp-sys-catman .cat
|
||||
./usr/share/man/cat9/vn_setrecurse.0 comp-sys-catman .cat
|
||||
./usr/share/man/cat9/vn_restorerecurse.0 comp-sys-catman obsolete
|
||||
./usr/share/man/cat9/vn_setrecurse.0 comp-sys-catman obsolete
|
||||
./usr/share/man/cat9/vn_start_write.0 comp-obsolete obsolete
|
||||
./usr/share/man/cat9/vn_stat.0 comp-sys-catman .cat
|
||||
./usr/share/man/cat9/vn_statfile.0 comp-sys-catman .cat
|
||||
|
@ -15582,8 +15582,8 @@
|
|||
./usr/share/man/html9/vn_poll.html comp-sys-htmlman html
|
||||
./usr/share/man/html9/vn_rdwr.html comp-sys-htmlman html
|
||||
./usr/share/man/html9/vn_read.html comp-sys-htmlman html
|
||||
./usr/share/man/html9/vn_restorerecurse.html comp-sys-htmlman html
|
||||
./usr/share/man/html9/vn_setrecurse.html comp-sys-htmlman html
|
||||
./usr/share/man/html9/vn_restorerecurse.html comp-sys-htmlman obsolete
|
||||
./usr/share/man/html9/vn_setrecurse.html comp-sys-htmlman obsolete
|
||||
./usr/share/man/html9/vn_stat.html comp-sys-htmlman html
|
||||
./usr/share/man/html9/vn_statfile.html comp-sys-htmlman html
|
||||
./usr/share/man/html9/vn_write.html comp-sys-htmlman html
|
||||
|
@ -21537,8 +21537,8 @@
|
|||
./usr/share/man/man9/vn_poll.9 comp-sys-man .man
|
||||
./usr/share/man/man9/vn_rdwr.9 comp-sys-man .man
|
||||
./usr/share/man/man9/vn_read.9 comp-sys-man .man
|
||||
./usr/share/man/man9/vn_restorerecurse.9 comp-sys-man .man
|
||||
./usr/share/man/man9/vn_setrecurse.9 comp-sys-man .man
|
||||
./usr/share/man/man9/vn_restorerecurse.9 comp-sys-man obsolete
|
||||
./usr/share/man/man9/vn_setrecurse.9 comp-sys-man obsolete
|
||||
./usr/share/man/man9/vn_start_write.9 comp-obsolete obsolete
|
||||
./usr/share/man/man9/vn_stat.9 comp-sys-man .man
|
||||
./usr/share/man/man9/vn_statfile.9 comp-sys-man .man
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.1404 $>
|
||||
# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.1405 $>
|
||||
#
|
||||
#
|
||||
# [Note: This file does not mention every change made to the NetBSD source tree.
|
||||
|
@ -633,3 +633,4 @@ Changes from NetBSD 5.0 to NetBSD 6.0:
|
|||
ofppc: Support Gigabit Ethernet Controller for MV64361 on PegasosII
|
||||
by mvgbe@gt. [kiyohara 20100609]
|
||||
arm: Added support for Cortex-A8 CPUs. [jmcneill 20100616]
|
||||
vnsubr(9): Remove recursive vnode locks. [hannken 20100618]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.332 2010/06/08 05:40:27 jruoho Exp $
|
||||
# $NetBSD: Makefile,v 1.333 2010/06/18 16:29:01 hannken Exp $
|
||||
|
||||
# Makefile for section 9 (kernel function and variable) manual pages.
|
||||
|
||||
|
@ -868,9 +868,7 @@ MLINKS+=vnsubr.9 vn_bwrite.9 \
|
|||
vnsubr.9 vn_lock.9 \
|
||||
vnsubr.9 vn_markexec.9 \
|
||||
vnsubr.9 vn_marktext.9 \
|
||||
vnsubr.9 vn_restorerecurse.9 \
|
||||
vnsubr.9 vn_rdwr.9 \
|
||||
vnsubr.9 vn_setrecurse.9 \
|
||||
vnsubr.9 vn_stat.9 \
|
||||
vnsubr.9 vn_open.9 \
|
||||
vnsubr.9 vn_writechk.9
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: vnsubr.9,v 1.38 2009/06/02 18:09:34 jnemeth Exp $
|
||||
.\" $NetBSD: vnsubr.9,v 1.39 2010/06/18 16:29:01 hannken Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
|
@ -27,7 +27,7 @@
|
|||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd June 2, 2009
|
||||
.Dd June 18, 2010
|
||||
.Dt VNSUBR 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -40,8 +40,6 @@
|
|||
.Nm vn_markexec ,
|
||||
.Nm vn_marktext ,
|
||||
.Nm vn_rdwr ,
|
||||
.Nm vn_restorerecurse ,
|
||||
.Nm vn_setrecurse ,
|
||||
.Nm vn_open ,
|
||||
.Nm vn_stat ,
|
||||
.Nm vn_writechk
|
||||
|
@ -64,10 +62,6 @@
|
|||
.Fn vn_markexec "struct vnode *vp"
|
||||
.Ft void
|
||||
.Fn vn_marktext "struct vnode *vp"
|
||||
.Ft u_int
|
||||
.Fn vn_setrecurse "struct vnode *vp"
|
||||
.Ft void
|
||||
.Fn vn_restorerecurse "struct vnode *vp" "u_int flags"
|
||||
.Ft int
|
||||
.Fn vn_open "struct nameidata *ndp" "int fmode" "int cmode"
|
||||
.Ft int
|
||||
|
@ -155,20 +149,6 @@ as containing executable code of a running process.
|
|||
Common code to mark the vnode
|
||||
.Fa vp
|
||||
as being the text of a running process.
|
||||
.It Fn vn_setrecurse "vp"
|
||||
Common code to enable
|
||||
.Dv LK_CANRECURSE
|
||||
on the vnode lock for vnode
|
||||
.Fa vp .
|
||||
.Fn vn_setrecurse
|
||||
returns the new
|
||||
.Xr lockmgr 9
|
||||
flags after the update.
|
||||
.It Fn vn_restorerecurse "vp" "flags"
|
||||
Common code to restore the vnode lock flags for the vnode
|
||||
.Fa vp .
|
||||
It is called when done with
|
||||
.Fn vn_setrecurse .
|
||||
.It Fn vn_open "ndp" "fmode" "cmode"
|
||||
Common code for vnode open operations.
|
||||
The pathname is described in the nameidata pointer (see
|
||||
|
|
|
@ -473,7 +473,6 @@ unionfs_relookup_for_rename(struct vnode *dvp, struct componentname *cnp)
|
|||
static void
|
||||
unionfs_node_update(struct unionfs_node *unp, struct vnode *uvp)
|
||||
{
|
||||
int count, lockcnt;
|
||||
struct vnode *vp;
|
||||
struct vnode *lvp;
|
||||
|
||||
|
@ -485,13 +484,8 @@ unionfs_node_update(struct unionfs_node *unp, struct vnode *uvp)
|
|||
*/
|
||||
mutex_enter(&vp->v_interlock);
|
||||
unp->un_uppervp = uvp;
|
||||
lockcnt = lvp->v_lock.vl_recursecnt +
|
||||
rw_write_held(&lvp->v_lock.vl_lock);
|
||||
if (lockcnt <= 0)
|
||||
panic("unionfs: no exclusive lock");
|
||||
KASSERT(rw_write_held(&lvp->v_lock.vl_lock));
|
||||
mutex_exit(&vp->v_interlock);
|
||||
for (count = 1; count < lockcnt; count++)
|
||||
vn_lock(uvp, LK_EXCLUSIVE | LK_CANRECURSE | LK_RETRY);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vfs_subr.c,v 1.404 2010/06/06 08:01:31 hannken Exp $ */
|
||||
/* $NetBSD: vfs_subr.c,v 1.405 2010/06/18 16:29:02 hannken Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -91,7 +91,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.404 2010/06/06 08:01:31 hannken Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.405 2010/06/18 16:29:02 hannken Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_compat_netbsd.h"
|
||||
|
@ -2738,11 +2738,11 @@ vprint(const char *label, struct vnode *vp)
|
|||
printf("%s: ", label);
|
||||
printf("vnode @ %p, flags (%s)\n\ttag %s(%d), type %s(%d), "
|
||||
"usecount %d, writecount %d, holdcount %d\n"
|
||||
"\tfreelisthd %p, mount %p, data %p lock %p recursecnt %d\n",
|
||||
"\tfreelisthd %p, mount %p, data %p lock %p\n",
|
||||
vp, bf, ARRAY_PRINT(vp->v_tag, vnode_tags), vp->v_tag,
|
||||
ARRAY_PRINT(vp->v_type, vnode_types), vp->v_type,
|
||||
vp->v_usecount, vp->v_writecount, vp->v_holdcnt,
|
||||
vp->v_freelisthd, vp->v_mount, vp->v_data, vl, vl->vl_recursecnt);
|
||||
vp->v_freelisthd, vp->v_mount, vp->v_data, vl);
|
||||
if (vp->v_data != NULL) {
|
||||
printf("\t");
|
||||
VOP_PRINT(vp);
|
||||
|
@ -2928,40 +2928,24 @@ int
|
|||
vlockmgr(struct vnlock *vl, int flags)
|
||||
{
|
||||
|
||||
KASSERT((flags & ~(LK_CANRECURSE | LK_NOWAIT | LK_TYPE_MASK)) == 0);
|
||||
KASSERT((flags & ~(LK_NOWAIT | LK_TYPE_MASK)) == 0);
|
||||
|
||||
switch (flags & LK_TYPE_MASK) {
|
||||
switch (flags & (LK_NOWAIT | LK_TYPE_MASK)) {
|
||||
case LK_SHARED:
|
||||
if (rw_tryenter(&vl->vl_lock, RW_READER)) {
|
||||
return 0;
|
||||
}
|
||||
if ((flags & LK_NOWAIT) != 0) {
|
||||
return EBUSY;
|
||||
}
|
||||
rw_enter(&vl->vl_lock, RW_READER);
|
||||
return 0;
|
||||
|
||||
case LK_SHARED | LK_NOWAIT:
|
||||
return rw_tryenter(&vl->vl_lock, RW_READER) ? 0 : EBUSY;
|
||||
|
||||
case LK_EXCLUSIVE:
|
||||
if (rw_tryenter(&vl->vl_lock, RW_WRITER)) {
|
||||
return 0;
|
||||
}
|
||||
if ((vl->vl_canrecurse || (flags & LK_CANRECURSE) != 0) &&
|
||||
rw_write_held(&vl->vl_lock)) {
|
||||
vl->vl_recursecnt++;
|
||||
return 0;
|
||||
}
|
||||
if ((flags & LK_NOWAIT) != 0) {
|
||||
return EBUSY;
|
||||
}
|
||||
rw_enter(&vl->vl_lock, RW_WRITER);
|
||||
return 0;
|
||||
|
||||
case LK_EXCLUSIVE | LK_NOWAIT:
|
||||
return rw_tryenter(&vl->vl_lock, RW_WRITER) ? 0 : EBUSY;
|
||||
|
||||
case LK_RELEASE:
|
||||
if (vl->vl_recursecnt != 0) {
|
||||
KASSERT(rw_write_held(&vl->vl_lock));
|
||||
vl->vl_recursecnt--;
|
||||
return 0;
|
||||
}
|
||||
rw_exit(&vl->vl_lock);
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vfs_vnops.c,v 1.172 2010/06/06 08:01:31 hannken Exp $ */
|
||||
/* $NetBSD: vfs_vnops.c,v 1.173 2010/06/18 16:29:02 hannken Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
|
@ -66,7 +66,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.172 2010/06/06 08:01:31 hannken Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.173 2010/06/18 16:29:02 hannken Exp $");
|
||||
|
||||
#include "veriexec.h"
|
||||
|
||||
|
@ -772,8 +772,7 @@ vn_lock(struct vnode *vp, int flags)
|
|||
|| (vp->v_iflag & VI_ONWORKLST) != 0);
|
||||
#endif
|
||||
KASSERT((flags &
|
||||
~(LK_INTERLOCK|LK_SHARED|LK_EXCLUSIVE|LK_NOWAIT|LK_RETRY|
|
||||
LK_CANRECURSE))
|
||||
~(LK_INTERLOCK|LK_SHARED|LK_EXCLUSIVE|LK_NOWAIT|LK_RETRY))
|
||||
== 0);
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
|
@ -821,28 +820,6 @@ vn_closefile(file_t *fp)
|
|||
return vn_close(fp->f_data, fp->f_flag, fp->f_cred);
|
||||
}
|
||||
|
||||
/*
|
||||
* Enable LK_CANRECURSE on lock. Return prior status.
|
||||
*/
|
||||
u_int
|
||||
vn_setrecurse(struct vnode *vp)
|
||||
{
|
||||
|
||||
atomic_inc_uint(&vp->v_lock.vl_canrecurse);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when done with locksetrecurse.
|
||||
*/
|
||||
void
|
||||
vn_restorerecurse(struct vnode *vp, u_int flags)
|
||||
{
|
||||
|
||||
atomic_dec_uint(&vp->v_lock.vl_canrecurse);
|
||||
}
|
||||
|
||||
/*
|
||||
* Simplified in-kernel wrapper calls for extended attribute access.
|
||||
* Both calls pass in a NULL credential, authorizing a "kernel" access.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lock.h,v 1.83 2008/04/28 20:24:10 martin Exp $ */
|
||||
/* $NetBSD: lock.h,v 1.84 2010/06/18 16:29:02 hannken Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2006, 2007 The NetBSD Foundation, Inc.
|
||||
|
@ -80,7 +80,6 @@
|
|||
#define LK_EXCLOTHER 0x00000008 /* other process holds lock */
|
||||
|
||||
#define LK_NOWAIT 0x00000010 /* do not sleep to await lock */
|
||||
#define LK_CANRECURSE 0x00000040 /* this may be recursive lock attempt */
|
||||
#define LK_INTERLOCK 0x00010000 /* unlock passed simple lock after
|
||||
getting lk_interlock */
|
||||
#define LK_RETRY 0x00020000 /* vn_lock: retry until locked */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: param.h,v 1.365 2010/06/06 08:01:32 hannken Exp $ */
|
||||
/* $NetBSD: param.h,v 1.366 2010/06/18 16:29:02 hannken Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1989, 1993
|
||||
|
@ -63,7 +63,7 @@
|
|||
* 2.99.9 (299000900)
|
||||
*/
|
||||
|
||||
#define __NetBSD_Version__ 599003000 /* NetBSD 5.99.30 */
|
||||
#define __NetBSD_Version__ 599003100 /* NetBSD 5.99.31 */
|
||||
|
||||
#define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
|
||||
(m) * 1000000) + (p) * 100) <= __NetBSD_Version__)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vnode.h,v 1.219 2010/06/06 08:01:32 hannken Exp $ */
|
||||
/* $NetBSD: vnode.h,v 1.220 2010/06/18 16:29:02 hannken Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -124,8 +124,6 @@ TAILQ_HEAD(vnodelst, vnode);
|
|||
|
||||
struct vnlock {
|
||||
krwlock_t vl_lock;
|
||||
u_int vl_canrecurse;
|
||||
u_int vl_recursecnt;
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -616,8 +614,6 @@ int vn_rdwr(enum uio_rw, struct vnode *, void *, int, off_t, enum uio_seg,
|
|||
int, kauth_cred_t, size_t *, struct lwp *);
|
||||
int vn_readdir(struct file *, char *, int, u_int, int *, struct lwp *,
|
||||
off_t **, int *);
|
||||
void vn_restorerecurse(struct vnode *, u_int);
|
||||
u_int vn_setrecurse(struct vnode *);
|
||||
int vn_stat(struct vnode *, struct stat *);
|
||||
int vn_kqfilter(struct file *, struct knote *);
|
||||
int vn_writechk(struct vnode *);
|
||||
|
|
Loading…
Reference in New Issue