Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Remove the concept of recursive vnode locks by eliminating
details: https://anonhg.NetBSD.org/src/rev/6458bf50c019
branches: trunk
changeset: 755748:6458bf50c019
user: hannken <hannken%NetBSD.org@localhost>
date: Fri Jun 18 16:29:01 2010 +0000
description:
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.
diffstat:
distrib/sets/lists/comp/mi | 14 +++++++-------
doc/CHANGES | 3 ++-
share/man/man9/Makefile | 4 +---
share/man/man9/vnsubr.9 | 24 ++----------------------
sys/fs/unionfs/unionfs_subr.c | 8 +-------
sys/kern/vfs_subr.c | 42 +++++++++++++-----------------------------
sys/kern/vfs_vnops.c | 29 +++--------------------------
sys/sys/lock.h | 3 +--
sys/sys/param.h | 4 ++--
sys/sys/vnode.h | 6 +-----
10 files changed, 33 insertions(+), 104 deletions(-)
diffs (truncated from 361 to 300 lines):
diff -r 1de90f4fbc3b -r 6458bf50c019 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi Fri Jun 18 16:13:56 2010 +0000
+++ b/distrib/sets/lists/comp/mi Fri Jun 18 16:29:01 2010 +0000
@@ -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
diff -r 1de90f4fbc3b -r 6458bf50c019 doc/CHANGES
--- a/doc/CHANGES Fri Jun 18 16:13:56 2010 +0000
+++ b/doc/CHANGES Fri Jun 18 16:29:01 2010 +0000
@@ -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 @@
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]
diff -r 1de90f4fbc3b -r 6458bf50c019 share/man/man9/Makefile
--- a/share/man/man9/Makefile Fri Jun 18 16:13:56 2010 +0000
+++ b/share/man/man9/Makefile Fri Jun 18 16:29:01 2010 +0000
@@ -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 @@
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
diff -r 1de90f4fbc3b -r 6458bf50c019 share/man/man9/vnsubr.9
--- a/share/man/man9/vnsubr.9 Fri Jun 18 16:13:56 2010 +0000
+++ b/share/man/man9/vnsubr.9 Fri Jun 18 16:29:01 2010 +0000
@@ -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 @@
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
diff -r 1de90f4fbc3b -r 6458bf50c019 sys/fs/unionfs/unionfs_subr.c
--- a/sys/fs/unionfs/unionfs_subr.c Fri Jun 18 16:13:56 2010 +0000
+++ b/sys/fs/unionfs/unionfs_subr.c Fri Jun 18 16:29:01 2010 +0000
@@ -473,7 +473,6 @@
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 @@
*/
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);
}
/*
diff -r 1de90f4fbc3b -r 6458bf50c019 sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c Fri Jun 18 16:13:56 2010 +0000
+++ b/sys/kern/vfs_subr.c Fri Jun 18 16:29:01 2010 +0000
@@ -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 @@
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 @@
vlockmgr(struct vnlock *vl, int flags)
{
- KASSERT((flags & ~(LK_CANRECURSE | LK_NOWAIT | LK_TYPE_MASK)) == 0);
-
- switch (flags & LK_TYPE_MASK) {
+ KASSERT((flags & ~(LK_NOWAIT | LK_TYPE_MASK)) == 0);
+
+ 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;
diff -r 1de90f4fbc3b -r 6458bf50c019 sys/kern/vfs_vnops.c
--- a/sys/kern/vfs_vnops.c Fri Jun 18 16:13:56 2010 +0000
+++ b/sys/kern/vfs_vnops.c Fri Jun 18 16:29:01 2010 +0000
@@ -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 @@
|| (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
@@ -822,28 +821,6 @@
}
/*
- * 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.
* Set IO_NODELOCKED in ioflg if the vnode is already locked.
diff -r 1de90f4fbc3b -r 6458bf50c019 sys/sys/lock.h
Home |
Main Index |
Thread Index |
Old Index