Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/rmind-uvmplock]: src/sys - Amend getnewvnode(9) to take the lock for sha...
details: https://anonhg.NetBSD.org/src/rev/ac0da1a400ce
branches: rmind-uvmplock
changeset: 753091:ac0da1a400ce
user: rmind <rmind%NetBSD.org@localhost>
date: Mon May 30 14:57:48 2011 +0000
description:
- Amend getnewvnode(9) to take the lock for sharing, not a vnode.
- Update tmpfs to perform vnode and UVM object lock sharing correctly.
diffstat:
sys/fs/tmpfs/tmpfs_subr.c | 19 +++++++++++--------
sys/fs/union/union_subr.c | 7 ++++---
sys/fs/unionfs/unionfs_subr.c | 3 ++-
sys/kern/vfs_vnode.c | 18 +++++++++---------
sys/miscfs/genfs/layer_subr.c | 6 +++---
sys/sys/vnode.h | 4 ++--
6 files changed, 31 insertions(+), 26 deletions(-)
diffs (197 lines):
diff -r cc087fab115b -r ac0da1a400ce sys/fs/tmpfs/tmpfs_subr.c
--- a/sys/fs/tmpfs/tmpfs_subr.c Sun May 22 21:52:12 2011 +0000
+++ b/sys/fs/tmpfs/tmpfs_subr.c Mon May 30 14:57:48 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tmpfs_subr.c,v 1.56.4.6 2011/05/22 04:29:04 rmind Exp $ */
+/* $NetBSD: tmpfs_subr.c,v 1.56.4.7 2011/05/30 14:57:48 rmind Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.56.4.6 2011/05/22 04:29:04 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.56.4.7 2011/05/30 14:57:48 rmind Exp $");
#include <sys/param.h>
#include <sys/dirent.h>
@@ -344,6 +344,7 @@
int
tmpfs_alloc_vp(struct mount *mp, struct tmpfs_node *node, struct vnode **vpp)
{
+ struct uvm_object *uobj;
int error;
struct vnode *vp;
@@ -364,16 +365,18 @@
break;
}
- /* Get a new vnode and associate it with our node. */
- error = getnewvnode(VT_TMPFS, mp, tmpfs_vnodeop_p, NULL, &vp);
+ /*
+ * Get a new vnode and associate it with our inode. Share the
+ * lock with underlying UVM object.
+ */
+ uobj = node->tn_spec.tn_reg.tn_aobj;
+ error = getnewvnode(VT_TMPFS, mp, tmpfs_vnodeop_p,
+ uobj->vmobjlock, &vp);
if (error != 0) {
mutex_exit(&node->tn_vlock);
return error;
}
-
- /* Set UVM object to use vnode_t::v_interlock (share it). */
- uvm_obj_setlock(node->tn_spec.tn_reg.tn_aobj, vp->v_interlock);
- mutex_obj_hold(vp->v_interlock);
+ KASSERT(uobj->vmobjlock == vp->v_interlock);
error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
if (error != 0) {
diff -r cc087fab115b -r ac0da1a400ce sys/fs/union/union_subr.c
--- a/sys/fs/union/union_subr.c Sun May 22 21:52:12 2011 +0000
+++ b/sys/fs/union/union_subr.c Mon May 30 14:57:48 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: union_subr.c,v 1.35.4.4 2011/05/21 03:38:24 rmind Exp $ */
+/* $NetBSD: union_subr.c,v 1.35.4.5 2011/05/30 14:57:48 rmind Exp $ */
/*
* Copyright (c) 1994
@@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.35.4.4 2011/05/21 03:38:24 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.35.4.5 2011/05/30 14:57:48 rmind Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -511,8 +511,9 @@
* Get a new vnode and share the lock with upper layer vnode,
* unless layers are inverted.
*/
+ vnode_t *svp = (uppervp != NULLVP) ? uppervp : lowervp;
error = getnewvnode(VT_UNION, mp, union_vnodeop_p,
- (uppervp != NULLVP ? uppervp : lowervp), vpp);
+ svp->v_interlock, vpp);
if (error) {
if (uppervp) {
if (dvp == uppervp)
diff -r cc087fab115b -r ac0da1a400ce sys/fs/unionfs/unionfs_subr.c
--- a/sys/fs/unionfs/unionfs_subr.c Sun May 22 21:52:12 2011 +0000
+++ b/sys/fs/unionfs/unionfs_subr.c Mon May 30 14:57:48 2011 +0000
@@ -95,8 +95,9 @@
* Get a new vnode and share the lock with upper layer vnode,
* unless layers are inverted.
*/
+ vnode_t *svp = (uppervp != NULLVP) ? uppervp : lowervp;
error = getnewvnode(VT_UNION, mp, unionfs_vnodeop_p,
- (uppervp != NULLVP ? uppervp : lowervp), &vp);
+ svp->v_interlock, &vp);
if (error != 0) {
return (error);
}
diff -r cc087fab115b -r ac0da1a400ce sys/kern/vfs_vnode.c
--- a/sys/kern/vfs_vnode.c Sun May 22 21:52:12 2011 +0000
+++ b/sys/kern/vfs_vnode.c Mon May 30 14:57:48 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_vnode.c,v 1.5.2.4 2011/05/22 04:29:04 rmind Exp $ */
+/* $NetBSD: vfs_vnode.c,v 1.5.2.5 2011/05/30 14:57:48 rmind Exp $ */
/*-
* Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.5.2.4 2011/05/22 04:29:04 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.5.2.5 2011/05/30 14:57:48 rmind Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -308,11 +308,11 @@
* getnewvnode: return the next vnode from the free list.
*
* => Returns referenced vnode, moved into the mount queue.
- * => Shares the lock with vnode specified by 'svp', if it is not NULL.
+ * => Shares the interlock specified by 'slock', if it is not NULL.
*/
int
getnewvnode(enum vtagtype tag, struct mount *mp, int (**vops)(void *),
- const vnode_t *svp, vnode_t **vpp)
+ kmutex_t *slock, vnode_t **vpp)
{
struct uvm_object *uobj;
static int toggle;
@@ -386,7 +386,7 @@
*vpp = 0;
return ENFILE;
}
- if ((vp->v_iflag & VI_LOCKSHARE) != 0 || svp) {
+ if ((vp->v_iflag & VI_LOCKSHARE) != 0 || slock) {
/* We must remove vnode from the old mount point. */
if (vp->v_mount) {
vfs_insmntque(vp, NULL);
@@ -421,12 +421,12 @@
vp->v_size = vp->v_writesize = VSIZENOTSET;
/* Share the vnode_t::v_interlock, if requested. */
- if (svp) {
+ if (slock) {
/* Set the interlock and mark that it is shared. */
KASSERT(vp->v_mount == NULL);
- mutex_obj_hold(svp->v_interlock);
- uvm_obj_setlock(&vp->v_uobj, svp->v_interlock);
- KASSERT(vp->v_interlock == svp->v_interlock);
+ mutex_obj_hold(slock);
+ uvm_obj_setlock(&vp->v_uobj, slock);
+ KASSERT(vp->v_interlock == slock);
vp->v_iflag |= VI_LOCKSHARE;
}
diff -r cc087fab115b -r ac0da1a400ce sys/miscfs/genfs/layer_subr.c
--- a/sys/miscfs/genfs/layer_subr.c Sun May 22 21:52:12 2011 +0000
+++ b/sys/miscfs/genfs/layer_subr.c Mon May 30 14:57:48 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: layer_subr.c,v 1.28.4.4 2011/05/19 03:43:03 rmind Exp $ */
+/* $NetBSD: layer_subr.c,v 1.28.4.5 2011/05/30 14:57:48 rmind Exp $ */
/*
* Copyright (c) 1999 National Aeronautics & Space Administration
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: layer_subr.c,v 1.28.4.4 2011/05/19 03:43:03 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: layer_subr.c,v 1.28.4.5 2011/05/30 14:57:48 rmind Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -191,7 +191,7 @@
/* Get a new vnode and share its interlock with underlying vnode. */
error = getnewvnode(lmp->layerm_tag, mp, lmp->layerm_vnodeop_p,
- lowervp, &vp);
+ lowervp->v_interlock, &vp);
if (error) {
return error;
}
diff -r cc087fab115b -r ac0da1a400ce sys/sys/vnode.h
--- a/sys/sys/vnode.h Sun May 22 21:52:12 2011 +0000
+++ b/sys/sys/vnode.h Mon May 30 14:57:48 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vnode.h,v 1.214.2.6 2011/05/19 03:43:04 rmind Exp $ */
+/* $NetBSD: vnode.h,v 1.214.2.7 2011/05/30 14:57:49 rmind Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -546,7 +546,7 @@
int bdevvp(dev_t, struct vnode **);
int cdevvp(dev_t, struct vnode **);
int getnewvnode(enum vtagtype, struct mount *, int (**)(void *),
- const struct vnode *, struct vnode **);
+ kmutex_t *, struct vnode **);
void ungetnewvnode(struct vnode *);
int vaccess(enum vtype, mode_t, uid_t, gid_t, mode_t, kauth_cred_t);
void vattr_null(struct vattr *);
Home |
Main Index |
Thread Index |
Old Index