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.
This commit is contained in:
parent
05a181bf68
commit
f5647f853e
@ -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>
|
||||
@ -423,21 +423,6 @@ vnis_marker(vnode_t *vp)
|
||||
return (VNODE_TO_VIMPL(vp)->vi_state == VS_MARKER);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
@ -1123,7 +1108,7 @@ vcache_alloc(void)
|
||||
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 @@ vcache_free(vnode_impl_t *vip)
|
||||
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);
|
||||
|
@ -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 @@ genfs_deadlock(void *v)
|
||||
|
||||
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 @@ genfs_deadunlock(void *v)
|
||||
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 @@ genfs_lock(void *v)
|
||||
|
||||
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 @@ genfs_unlock(void *v)
|
||||
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 @@ genfs_islocked(void *v)
|
||||
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;
|
||||
|
@ -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_revoke(void *);
|
||||
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_ */
|
||||
|
@ -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 @@ layerfs_loadvnode(struct mount *mp, struct vnode *vp,
|
||||
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;
|
||||
|
@ -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 @@ const struct vnodeopv_entry_desc null_vnodeop_entries[] = {
|
||||
{ &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 },
|
||||
|
@ -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 @@ const struct vnodeopv_entry_desc overlay_vnodeop_entries[] = {
|
||||
{ &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 },
|
||||
|
@ -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 @@ const struct vnodeopv_entry_desc umap_vnodeop_entries[] = {
|
||||
{ &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 },
|
||||
|
@ -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 @@ bool vrecycle(struct vnode *);
|
||||
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);
|
||||
|
@ -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 @@ struct vnode_impl {
|
||||
TAILQ_ENTRY(vnode_impl) vi_synclist; /* s: vnodes with dirty bufs */
|
||||
TAILQ_ENTRY(vnode_impl) vi_mntvnodes; /* m: vnodes for mount point */
|
||||
SLIST_ENTRY(vnode_impl) vi_hash; /* c: vnode cache list */
|
||||
krwlock_t *vi_lock; /* -: lock for this vnode */
|
||||
krwlock_t vi_lock; /* -: lock for this vnode */
|
||||
struct vcache_key vi_key; /* c: vnode cache key */
|
||||
};
|
||||
typedef struct vnode_impl vnode_impl_t;
|
||||
|
Loading…
Reference in New Issue
Block a user