Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Move vnode member v_lock as vi_lock to vnode_impl.h.
details: https://anonhg.NetBSD.org/src/rev/7691d71494b4
branches: trunk
changeset: 350411:7691d71494b4
user: hannken <hannken%NetBSD.org@localhost>
date: Wed Jan 11 09:08:58 2017 +0000
description:
Move vnode member v_lock as vi_lock to vnode_impl.h.
diffstat:
share/man/man9/vnode.9 | 13 +++-------
sys/kern/vfs_subr.c | 6 ++--
sys/kern/vfs_vnode.c | 8 +++---
sys/miscfs/genfs/genfs_vnops.c | 49 +++++++++++++++++++++++------------------
sys/sys/vnode.h | 3 +-
sys/sys/vnode_impl.h | 3 +-
6 files changed, 41 insertions(+), 41 deletions(-)
diffs (truncated from 306 to 300 lines):
diff -r 297fd5a986e0 -r 7691d71494b4 share/man/man9/vnode.9
--- a/share/man/man9/vnode.9 Wed Jan 11 09:07:57 2017 +0000
+++ b/share/man/man9/vnode.9 Wed Jan 11 09:08:58 2017 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: vnode.9,v 1.77 2017/01/11 09:07:57 hannken Exp $
+.\" $NetBSD: vnode.9,v 1.78 2017/01/11 09:08:58 hannken Exp $
.\"
.\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -180,7 +180,6 @@
} v_un;
enum vtype v_type; /* vnode type */
enum vtagtype v_tag; /* type of underlying data */
- struct vnlock v_lock; /* lock for this vnode */
void *v_data; /* private data for fs */
struct klist v_klist; /* notes attached to vnode */
};
@@ -433,9 +432,7 @@
systemV boot file system
.El
.Pp
-All vnode locking operations use
-.Em v_lock .
-This lock is acquired by calling
+The vnode lock is acquired by calling
.Xr vn_lock 9
and released by calling
.Xr VOP_UNLOCK 9 .
@@ -461,10 +458,8 @@
Multiple-reader locking functions equivalently only in the presence
of big-lock SMP locking or a uni-processor machine.
The lock may be held while sleeping.
-While the
-.Em v_lock
-is acquired, the holder is guaranteed that the vnode will not be
-reclaimed or invalidated.
+While the vnode lock is acquired, the holder is guaranteed that the
+vnode will not be reclaimed or invalidated.
Most file system functions require that you hold the vnode lock on entry.
See
.Xr lock 9
diff -r 297fd5a986e0 -r 7691d71494b4 sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c Wed Jan 11 09:07:57 2017 +0000
+++ b/sys/kern/vfs_subr.c Wed Jan 11 09:08:58 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_subr.c,v 1.456 2017/01/11 09:07:57 hannken Exp $ */
+/* $NetBSD: vfs_subr.c,v 1.457 2017/01/11 09:08:58 hannken Exp $ */
/*-
* Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.456 2017/01/11 09:07:57 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.457 2017/01/11 09:08:58 hannken Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -1116,7 +1116,7 @@
vp->v_usecount, vp->v_writecount, vp->v_holdcnt);
(*pr)("%ssize %" PRIx64 " writesize %" PRIx64 " numoutput %d\n",
prefix, vp->v_size, vp->v_writesize, vp->v_numoutput);
- (*pr)("%sdata %p lock %p\n", prefix, vp->v_data, &vp->v_lock);
+ (*pr)("%sdata %p lock %p\n", prefix, vp->v_data, &vip->vi_lock);
(*pr)("%sstate %s key(%p %zd)", prefix, vstate_name(vip->vi_state),
vip->vi_key.vk_mount, vip->vi_key.vk_key_len);
diff -r 297fd5a986e0 -r 7691d71494b4 sys/kern/vfs_vnode.c
--- a/sys/kern/vfs_vnode.c Wed Jan 11 09:07:57 2017 +0000
+++ b/sys/kern/vfs_vnode.c Wed Jan 11 09:08:58 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_vnode.c,v 1.71 2017/01/11 09:04:37 hannken Exp $ */
+/* $NetBSD: vfs_vnode.c,v 1.72 2017/01/11 09:08:58 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.71 2017/01/11 09:04:37 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.72 2017/01/11 09:08:58 hannken Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -1022,6 +1022,7 @@
vip = pool_cache_get(vcache_pool, PR_WAITOK);
memset(vip, 0, sizeof(*vip));
+ rw_init(&vip->vi_lock);
/* SLIST_INIT(&vip->vi_hash); */
/* LIST_INIT(&vip->vi_nclist); */
/* LIST_INIT(&vip->vi_dnclist); */
@@ -1030,7 +1031,6 @@
uvm_obj_init(&vp->v_uobj, &uvm_vnodeops, true, 0);
cv_init(&vp->v_cv, "vnode");
- rw_init(&vp->v_lock);
vp->v_usecount = 1;
vp->v_type = VNON;
vp->v_size = vp->v_writesize = VSIZENOTSET;
@@ -1064,7 +1064,7 @@
if (vp->v_type == VBLK || vp->v_type == VCHR)
spec_node_destroy(vp);
- rw_destroy(&vp->v_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 297fd5a986e0 -r 7691d71494b4 sys/miscfs/genfs/genfs_vnops.c
--- a/sys/miscfs/genfs/genfs_vnops.c Wed Jan 11 09:07:57 2017 +0000
+++ b/sys/miscfs/genfs/genfs_vnops.c Wed Jan 11 09:08:58 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: genfs_vnops.c,v 1.192 2014/03/24 13:42:40 hannken Exp $ */
+/* $NetBSD: genfs_vnops.c,v 1.193 2017/01/11 09:08:59 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.192 2014/03/24 13:42:40 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.193 2017/01/11 09:08:59 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -66,7 +66,7 @@
#include <sys/mount.h>
#include <sys/fstrans.h>
#include <sys/namei.h>
-#include <sys/vnode.h>
+#include <sys/vnode_impl.h>
#include <sys/fcntl.h>
#include <sys/kmem.h>
#include <sys/poll.h>
@@ -287,14 +287,15 @@
struct vnode *a_vp;
int a_flags;
} */ *ap = v;
- struct vnode *vp = ap->a_vp;
+ vnode_t *vp = ap->a_vp;
+ vnode_impl_t *vip = VNODE_TO_VIMPL(vp);
int flags = ap->a_flags;
krw_t op;
int error;
op = (ISSET(flags, LK_EXCLUSIVE) ? RW_WRITER : RW_READER);
if (ISSET(flags, LK_NOWAIT)) {
- if (! rw_tryenter(&vp->v_lock, op))
+ if (! rw_tryenter(&vip->vi_lock, op))
return EBUSY;
if (mutex_tryenter(vp->v_interlock)) {
error = vdead_check(vp, VDEAD_NOWAIT);
@@ -304,25 +305,25 @@
} else
error = EBUSY;
if (error)
- rw_exit(&vp->v_lock);
+ rw_exit(&vip->vi_lock);
return error;
}
- rw_enter(&vp->v_lock, op);
+ rw_enter(&vip->vi_lock, op);
mutex_enter(vp->v_interlock);
error = vdead_check(vp, VDEAD_NOWAIT);
if (error == EBUSY) {
- rw_exit(&vp->v_lock);
+ rw_exit(&vip->vi_lock);
error = vdead_check(vp, 0);
KASSERT(error == ENOENT);
mutex_exit(vp->v_interlock);
- rw_enter(&vp->v_lock, op);
+ rw_enter(&vip->vi_lock, op);
mutex_enter(vp->v_interlock);
}
KASSERT(error == ENOENT);
mutex_exit(vp->v_interlock);
if (! ISSET(flags, LK_RETRY)) {
- rw_exit(&vp->v_lock);
+ rw_exit(&vip->vi_lock);
return ENOENT;
}
return 0;
@@ -337,9 +338,10 @@
struct vop_unlock_args /* {
struct vnode *a_vp;
} */ *ap = v;
- struct vnode *vp = ap->a_vp;
+ vnode_t *vp = ap->a_vp;
+ vnode_impl_t *vip = VNODE_TO_VIMPL(vp);
- rw_exit(&vp->v_lock);
+ rw_exit(&vip->vi_lock);
return 0;
}
@@ -354,7 +356,8 @@
struct vnode *a_vp;
int a_flags;
} */ *ap = v;
- struct vnode *vp = ap->a_vp;
+ vnode_t *vp = ap->a_vp;
+ vnode_impl_t *vip = VNODE_TO_VIMPL(vp);
struct mount *mp = vp->v_mount;
int flags = ap->a_flags;
krw_t op;
@@ -364,7 +367,7 @@
if (ISSET(flags, LK_NOWAIT)) {
if (fstrans_start_nowait(mp, FSTRANS_SHARED))
return EBUSY;
- if (! rw_tryenter(&vp->v_lock, op)) {
+ if (! rw_tryenter(&vip->vi_lock, op)) {
fstrans_done(mp);
return EBUSY;
}
@@ -374,18 +377,18 @@
} else
error = EBUSY;
if (error) {
- rw_exit(&vp->v_lock);
+ rw_exit(&vip->vi_lock);
fstrans_done(mp);
}
return error;
}
fstrans_start(mp, FSTRANS_SHARED);
- rw_enter(&vp->v_lock, op);
+ rw_enter(&vip->vi_lock, op);
mutex_enter(vp->v_interlock);
error = vdead_check(vp, VDEAD_NOWAIT);
if (error) {
- rw_exit(&vp->v_lock);
+ rw_exit(&vip->vi_lock);
fstrans_done(mp);
error = vdead_check(vp, 0);
KASSERT(error == ENOENT);
@@ -403,10 +406,11 @@
struct vop_unlock_args /* {
struct vnode *a_vp;
} */ *ap = v;
- struct vnode *vp = ap->a_vp;
+ vnode_t *vp = ap->a_vp;
+ vnode_impl_t *vip = VNODE_TO_VIMPL(vp);
struct mount *mp = vp->v_mount;
- rw_exit(&vp->v_lock);
+ rw_exit(&vip->vi_lock);
fstrans_done(mp);
return 0;
@@ -421,12 +425,13 @@
struct vop_islocked_args /* {
struct vnode *a_vp;
} */ *ap = v;
- struct vnode *vp = ap->a_vp;
+ vnode_t *vp = ap->a_vp;
+ vnode_impl_t *vip = VNODE_TO_VIMPL(vp);
- if (rw_write_held(&vp->v_lock))
+ if (rw_write_held(&vip->vi_lock))
return LK_EXCLUSIVE;
- if (rw_read_held(&vp->v_lock))
+ if (rw_read_held(&vip->vi_lock))
return LK_SHARED;
return 0;
diff -r 297fd5a986e0 -r 7691d71494b4 sys/sys/vnode.h
--- a/sys/sys/vnode.h Wed Jan 11 09:07:57 2017 +0000
+++ b/sys/sys/vnode.h Wed Jan 11 09:08:58 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vnode.h,v 1.271 2017/01/11 09:07:57 hannken Exp $ */
+/* $NetBSD: vnode.h,v 1.272 2017/01/11 09:08:59 hannken Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -157,7 +157,6 @@
} v_un;
enum vtype v_type; /* :: vnode type */
enum vtagtype v_tag; /* :: type of underlying data */
- krwlock_t v_lock; /* v: lock for this vnode */
void *v_data; /* :: private data for fs */
struct klist v_klist; /* i: notes attached to vnode */
};
diff -r 297fd5a986e0 -r 7691d71494b4 sys/sys/vnode_impl.h
--- a/sys/sys/vnode_impl.h Wed Jan 11 09:07:57 2017 +0000
+++ b/sys/sys/vnode_impl.h Wed Jan 11 09:08:58 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vnode_impl.h,v 1.10 2017/01/11 09:07:58 hannken Exp $ */
+/* $NetBSD: vnode_impl.h,v 1.11 2017/01/11 09:08:59 hannken Exp $ */
/*-
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -76,6 +76,7 @@
TAILQ_ENTRY(vnode_impl) vi_synclist; /* s: vnodes with dirty bufs */
Home |
Main Index |
Thread Index |
Old Index