Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Locking a layer vnode using the regular bypass routine i...
details: https://anonhg.NetBSD.org/src/rev/671fd3bd7f95
branches: trunk
changeset: 354106:671fd3bd7f95
user: hannken <hannken%NetBSD.org@localhost>
date: Sun Jun 04 08:02:26 2017 +0000
description:
Locking a layer vnode using the regular bypass routine is no longer
racy. Undo the change from 2017-03-30 11:16:52, commitid eurqbzuGxGRlryLz
and make vi_lock a krwlock_t again.
diffstat:
sys/kern/vfs_vnode.c | 23 ++++-------------------
sys/miscfs/genfs/genfs_vnops.c | 20 ++++++++++----------
sys/miscfs/genfs/layer_extern.h | 5 +----
sys/miscfs/genfs/layer_vfsops.c | 7 ++-----
sys/miscfs/nullfs/null_vnops.c | 7 ++-----
sys/miscfs/overlay/overlay_vnops.c | 9 +++------
sys/miscfs/umapfs/umap_vnops.c | 7 ++-----
sys/sys/vnode.h | 3 +--
sys/sys/vnode_impl.h | 4 ++--
9 files changed, 27 insertions(+), 58 deletions(-)
diffs (truncated from 307 to 300 lines):
diff -r fbb34359f89e -r 671fd3bd7f95 sys/kern/vfs_vnode.c
--- a/sys/kern/vfs_vnode.c Sun Jun 04 08:01:33 2017 +0000
+++ b/sys/kern/vfs_vnode.c Sun Jun 04 08:02:26 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_vnode.c,v 1.94 2017/06/04 07:58:29 hannken Exp $ */
+/* $NetBSD: vfs_vnode.c,v 1.95 2017/06/04 08:02:26 hannken Exp $ */
/*-
* Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -156,7 +156,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.94 2017/06/04 07:58:29 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.95 2017/06/04 08:02:26 hannken Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -424,21 +424,6 @@
}
/*
- * Set vnode to share another vnodes lock.
- */
-void
-vshare_lock(vnode_t *vp, vnode_t *src_vp)
-{
- vnode_impl_t *vip = VNODE_TO_VIMPL(vp);
- vnode_impl_t *src_vip = VNODE_TO_VIMPL(src_vp);
- krwlock_t *oldlock = vip->vi_lock;
-
- rw_obj_hold(src_vip->vi_lock);
- vip->vi_lock = src_vip->vi_lock;
- rw_obj_free(oldlock);
-}
-
-/*
* Return the lru list this node should be on.
*/
static vnodelst_t *
@@ -1123,7 +1108,7 @@
vip = pool_cache_get(vcache_pool, PR_WAITOK);
memset(vip, 0, sizeof(*vip));
- vip->vi_lock = rw_obj_alloc();
+ rw_init(&vip->vi_lock);
/* SLIST_INIT(&vip->vi_hash); */
/* LIST_INIT(&vip->vi_nclist); */
/* LIST_INIT(&vip->vi_dnclist); */
@@ -1185,7 +1170,7 @@
if (vp->v_type == VBLK || vp->v_type == VCHR)
spec_node_destroy(vp);
- rw_obj_free(vip->vi_lock);
+ rw_destroy(&vip->vi_lock);
uvm_obj_destroy(&vp->v_uobj, true);
cv_destroy(&vp->v_cv);
pool_cache_put(vcache_pool, vip);
diff -r fbb34359f89e -r 671fd3bd7f95 sys/miscfs/genfs/genfs_vnops.c
--- a/sys/miscfs/genfs/genfs_vnops.c Sun Jun 04 08:01:33 2017 +0000
+++ b/sys/miscfs/genfs/genfs_vnops.c Sun Jun 04 08:02:26 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: genfs_vnops.c,v 1.196 2017/06/04 08:01:33 hannken Exp $ */
+/* $NetBSD: genfs_vnops.c,v 1.197 2017/06/04 08:02:26 hannken Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.196 2017/06/04 08:01:33 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.197 2017/06/04 08:02:26 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -294,10 +294,10 @@
op = (ISSET(flags, LK_EXCLUSIVE) ? RW_WRITER : RW_READER);
if (ISSET(flags, LK_NOWAIT)) {
- if (! rw_tryenter(vip->vi_lock, op))
+ if (! rw_tryenter(&vip->vi_lock, op))
return EBUSY;
} else {
- rw_enter(vip->vi_lock, op);
+ rw_enter(&vip->vi_lock, op);
}
VSTATE_ASSERT_UNLOCKED(vp, VS_RECLAIMED);
return 0;
@@ -315,7 +315,7 @@
vnode_t *vp = ap->a_vp;
vnode_impl_t *vip = VNODE_TO_VIMPL(vp);
- rw_exit(vip->vi_lock);
+ rw_exit(&vip->vi_lock);
return 0;
}
@@ -337,10 +337,10 @@
op = (ISSET(flags, LK_EXCLUSIVE) ? RW_WRITER : RW_READER);
if (ISSET(flags, LK_NOWAIT)) {
- if (! rw_tryenter(vip->vi_lock, op))
+ if (! rw_tryenter(&vip->vi_lock, op))
return EBUSY;
} else {
- rw_enter(vip->vi_lock, op);
+ rw_enter(&vip->vi_lock, op);
}
VSTATE_ASSERT_UNLOCKED(vp, VS_ACTIVE);
return 0;
@@ -358,7 +358,7 @@
vnode_t *vp = ap->a_vp;
vnode_impl_t *vip = VNODE_TO_VIMPL(vp);
- rw_exit(vip->vi_lock);
+ rw_exit(&vip->vi_lock);
return 0;
}
@@ -375,10 +375,10 @@
vnode_t *vp = ap->a_vp;
vnode_impl_t *vip = VNODE_TO_VIMPL(vp);
- if (rw_write_held(vip->vi_lock))
+ if (rw_write_held(&vip->vi_lock))
return LK_EXCLUSIVE;
- if (rw_read_held(vip->vi_lock))
+ if (rw_read_held(&vip->vi_lock))
return LK_SHARED;
return 0;
diff -r fbb34359f89e -r 671fd3bd7f95 sys/miscfs/genfs/layer_extern.h
--- a/sys/miscfs/genfs/layer_extern.h Sun Jun 04 08:01:33 2017 +0000
+++ b/sys/miscfs/genfs/layer_extern.h Sun Jun 04 08:02:26 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: layer_extern.h,v 1.39 2017/03/30 09:16:52 hannken Exp $ */
+/* $NetBSD: layer_extern.h,v 1.40 2017/06/04 08:02:26 hannken Exp $ */
/*
* Copyright (c) 1999 National Aeronautics & Space Administration
@@ -113,8 +113,5 @@
int layer_rmdir(void *);
int layer_getpages(void *);
int layer_putpages(void *);
-#define layer_lock genfs_lock
-#define layer_unlock genfs_unlock
-#define layer_islocked genfs_islocked
#endif /* _MISCFS_GENFS_LAYER_EXTERN_H_ */
diff -r fbb34359f89e -r 671fd3bd7f95 sys/miscfs/genfs/layer_vfsops.c
--- a/sys/miscfs/genfs/layer_vfsops.c Sun Jun 04 08:01:33 2017 +0000
+++ b/sys/miscfs/genfs/layer_vfsops.c Sun Jun 04 08:02:26 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: layer_vfsops.c,v 1.50 2017/06/01 02:45:13 chs Exp $ */
+/* $NetBSD: layer_vfsops.c,v 1.51 2017/06/04 08:02:26 hannken Exp $ */
/*
* Copyright (c) 1999 National Aeronautics & Space Administration
@@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.50 2017/06/01 02:45:13 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.51 2017/06/04 08:02:26 hannken Exp $");
#include <sys/param.h>
#include <sys/sysctl.h>
@@ -218,9 +218,6 @@
mutex_obj_hold(lowervp->v_interlock);
uvm_obj_setlock(&vp->v_uobj, lowervp->v_interlock);
- /* Share the lock with the lower node. */
- vshare_lock(vp, lowervp);
-
vp->v_tag = lmp->layerm_tag;
vp->v_type = lowervp->v_type;
vp->v_op = lmp->layerm_vnodeop_p;
diff -r fbb34359f89e -r 671fd3bd7f95 sys/miscfs/nullfs/null_vnops.c
--- a/sys/miscfs/nullfs/null_vnops.c Sun Jun 04 08:01:33 2017 +0000
+++ b/sys/miscfs/nullfs/null_vnops.c Sun Jun 04 08:02:26 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: null_vnops.c,v 1.41 2017/03/30 09:16:52 hannken Exp $ */
+/* $NetBSD: null_vnops.c,v 1.42 2017/06/04 08:02:26 hannken Exp $ */
/*
* Copyright (c) 1999 National Aeronautics & Space Administration
@@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: null_vnops.c,v 1.41 2017/03/30 09:16:52 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: null_vnops.c,v 1.42 2017/06/04 08:02:26 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -106,9 +106,6 @@
{ &vop_fsync_desc, layer_fsync },
{ &vop_inactive_desc, layer_inactive },
{ &vop_reclaim_desc, layer_reclaim },
- { &vop_lock_desc, layer_lock },
- { &vop_unlock_desc, layer_unlock },
- { &vop_islocked_desc, layer_islocked },
{ &vop_print_desc, layer_print },
{ &vop_remove_desc, layer_remove },
{ &vop_rename_desc, layer_rename },
diff -r fbb34359f89e -r 671fd3bd7f95 sys/miscfs/overlay/overlay_vnops.c
--- a/sys/miscfs/overlay/overlay_vnops.c Sun Jun 04 08:01:33 2017 +0000
+++ b/sys/miscfs/overlay/overlay_vnops.c Sun Jun 04 08:02:26 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: overlay_vnops.c,v 1.23 2017/03/30 09:16:52 hannken Exp $ */
+/* $NetBSD: overlay_vnops.c,v 1.24 2017/06/04 08:02:26 hannken Exp $ */
/*
* Copyright (c) 1999, 2000 National Aeronautics & Space Administration
@@ -67,7 +67,7 @@
*
* Ancestors:
* @(#)lofs_vnops.c 1.2 (Berkeley) 6/18/92
- * $Id: overlay_vnops.c,v 1.23 2017/03/30 09:16:52 hannken Exp $
+ * $Id: overlay_vnops.c,v 1.24 2017/06/04 08:02:26 hannken Exp $
* ...and...
* @(#)null_vnodeops.c 1.20 92/07/07 UCLA Ficus project
*/
@@ -126,7 +126,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: overlay_vnops.c,v 1.23 2017/03/30 09:16:52 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: overlay_vnops.c,v 1.24 2017/06/04 08:02:26 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -154,9 +154,6 @@
{ &vop_fsync_desc, layer_fsync },
{ &vop_inactive_desc, layer_inactive },
{ &vop_reclaim_desc, layer_reclaim },
- { &vop_lock_desc, layer_lock },
- { &vop_unlock_desc, layer_unlock },
- { &vop_islocked_desc, layer_islocked },
{ &vop_print_desc, layer_print },
{ &vop_remove_desc, layer_remove },
{ &vop_rename_desc, layer_rename },
diff -r fbb34359f89e -r 671fd3bd7f95 sys/miscfs/umapfs/umap_vnops.c
--- a/sys/miscfs/umapfs/umap_vnops.c Sun Jun 04 08:01:33 2017 +0000
+++ b/sys/miscfs/umapfs/umap_vnops.c Sun Jun 04 08:02:26 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: umap_vnops.c,v 1.59 2017/03/30 09:16:53 hannken Exp $ */
+/* $NetBSD: umap_vnops.c,v 1.60 2017/06/04 08:02:26 hannken Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umap_vnops.c,v 1.59 2017/03/30 09:16:53 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umap_vnops.c,v 1.60 2017/06/04 08:02:26 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -88,9 +88,6 @@
{ &vop_fsync_desc, layer_fsync },
{ &vop_inactive_desc, layer_inactive },
{ &vop_reclaim_desc, layer_reclaim },
- { &vop_lock_desc, layer_lock },
- { &vop_unlock_desc, layer_unlock },
- { &vop_islocked_desc, layer_islocked },
{ &vop_open_desc, layer_open },
{ &vop_close_desc, layer_close },
{ &vop_setattr_desc, layer_setattr },
diff -r fbb34359f89e -r 671fd3bd7f95 sys/sys/vnode.h
--- a/sys/sys/vnode.h Sun Jun 04 08:01:33 2017 +0000
+++ b/sys/sys/vnode.h Sun Jun 04 08:02:26 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vnode.h,v 1.277 2017/04/11 14:29:32 riastradh Exp $ */
+/* $NetBSD: vnode.h,v 1.278 2017/06/04 08:02:26 hannken Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -512,7 +512,6 @@
void vrele(struct vnode *);
void vrele_async(struct vnode *);
void vrele_flush(struct mount *);
-void vshare_lock(vnode_t *, vnode_t *);
int vtruncbuf(struct vnode *, daddr_t, bool, int);
void vwakeup(struct buf *);
int vdead_check(struct vnode *, int);
diff -r fbb34359f89e -r 671fd3bd7f95 sys/sys/vnode_impl.h
--- a/sys/sys/vnode_impl.h Sun Jun 04 08:01:33 2017 +0000
+++ b/sys/sys/vnode_impl.h Sun Jun 04 08:02:26 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vnode_impl.h,v 1.14 2017/06/04 07:58:30 hannken Exp $ */
+/* $NetBSD: vnode_impl.h,v 1.15 2017/06/04 08:02:26 hannken Exp $ */
/*-
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
TAILQ_ENTRY(vnode_impl) vi_synclist; /* s: vnodes with dirty bufs */
Home |
Main Index |
Thread Index |
Old Index