summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2003-05-01 21:13:06 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2003-05-01 21:13:06 +0000
commit4fbb5d2cdb497598cffbcbfdf18f3d83d4a77367 (patch)
tree7fca7015b255d0a819cf54e4f153211bb7fc8d23 /sys
parentba43886222ebe38c78b14183f7471b4555bc4fa7 (diff)
several related changes:
vfs_subr.c: add a missing simple_lock_init for vnode interlock try to avoid reclaiming locked or layered vnodes initialize vnlock pointer to NULL remove old code to free vnlock, never used lockinit the new vnode lock vfs_syscalls.c: support for VLAYER flag vnode_if.sh: support for splitting VDESC flags vnode_if.src: split VDESC flags WILLPUT is the combination of WILLRELE and WILLUNLOCK most uses for WILLRELE become WILLPUT vnode.h: add v_lock to struct vnode add VLAYER flag update for new VDESC flags
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/vfs_subr.c23
-rw-r--r--sys/kern/vfs_syscalls.c4
-rw-r--r--sys/kern/vnode_if.sh22
-rw-r--r--sys/kern/vnode_if.src24
-rw-r--r--sys/sys/vnode.h24
5 files changed, 64 insertions, 33 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index f41d151c96d..b4192a84ee9 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_subr.c,v 1.89 2003/04/06 18:54:20 ho Exp $ */
+/* $OpenBSD: vfs_subr.c,v 1.90 2003/05/01 21:13:05 tedu Exp $ */
/* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */
/*
@@ -409,12 +409,19 @@ getnewvnode(tag, mp, vops, vpp)
simple_unlock(&vnode_free_list_slock);
vp = pool_get(&vnode_pool, PR_WAITOK);
bzero((char *)vp, sizeof *vp);
+ simple_lock_init(&vp->v_interlock);
numvnodes++;
} else {
for (vp = TAILQ_FIRST(listhd); vp != NULLVP;
vp = TAILQ_NEXT(vp, v_freelist)) {
- if (simple_lock_try(&vp->v_interlock))
- break;
+ if (simple_lock_try(&vp->v_interlock)) {
+ if ((vp->v_flag & VLAYER) == 0)
+ break;
+ if (VOP_ISLOCKED(vp) == 0)
+ break;
+ else
+ simple_unlock(&vp->v_interlock);
+ }
}
/*
* Unless this is a bad time of the month, at most
@@ -457,6 +464,8 @@ getnewvnode(tag, mp, vops, vpp)
}
vp->v_type = VNON;
cache_purge(vp);
+ vp->v_vnlock = NULL;
+ lockinit(&vp->v_lock, PVFS, "v_lock", 0, 0);
vp->v_tag = tag;
vp->v_op = vops;
insmntque(vp, mp);
@@ -633,6 +642,8 @@ loop:
VOP_UNLOCK(vp, 0, p);
simple_lock(&vp->v_interlock);
vclean(vp, 0, p);
+ vp->v_vnlock = NULL;
+ lockinit(&vp->v_lock, PVFS, "v_lock", 0, 0);
vp->v_op = nvp->v_op;
vp->v_tag = nvp->v_tag;
nvp->v_type = VNON;
@@ -1060,12 +1071,6 @@ vclean(vp, flags, p)
simple_unlock(&vp->v_interlock);
}
cache_purge(vp);
- if (vp->v_vnlock) {
- if ((vp->v_vnlock->lk_flags & LK_DRAINED) == 0)
- vprint("vclean: lock not drained", vp);
- FREE(vp->v_vnlock, M_VNODE);
- vp->v_vnlock = NULL;
- }
/*
* Done with purge, notify sleepers of the grim news.
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 8b5fcdf033d..59a9fc7a9d4 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_syscalls.c,v 1.100 2003/04/11 01:48:41 tedu Exp $ */
+/* $OpenBSD: vfs_syscalls.c,v 1.101 2003/05/01 21:13:05 tedu Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
/*
@@ -2603,7 +2603,7 @@ sys_revoke(p, v, retval)
if (p->p_ucred->cr_uid != vattr.va_uid &&
(error = suser(p->p_ucred, &p->p_acflag)))
goto out;
- if (vp->v_usecount > 1 || (vp->v_flag & VALIASED))
+ if (vp->v_usecount > 1 || (vp->v_flag & (VALIASED | VLAYER)))
VOP_REVOKE(vp, REVOKEALL);
out:
vrele(vp);
diff --git a/sys/kern/vnode_if.sh b/sys/kern/vnode_if.sh
index 70c02cabad8..743b3485011 100644
--- a/sys/kern/vnode_if.sh
+++ b/sys/kern/vnode_if.sh
@@ -33,7 +33,7 @@ copyright="\
* SUCH DAMAGE.
*/
"
-SCRIPT_ID='$OpenBSD: vnode_if.sh,v 1.10 2002/03/14 23:47:05 millert Exp $'
+SCRIPT_ID='$OpenBSD: vnode_if.sh,v 1.11 2003/05/01 21:13:05 tedu Exp $'
# SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.9 1996/02/29 20:58:22 cgd Exp $'
# Script to produce VFS front-end sugar.
@@ -112,9 +112,18 @@ awk_parser='
$3 == "WILLRELE") {
willrele[argc] = 1;
i++;
+ } else if ($2 == "WILLUNLOCK" ||
+ $3 == "WILLUNLOCK") {
+ willrele[argc] = 2;
+ i++;
+ } else if ($2 == "WILLPUT" ||
+ $3 == "WILLPUT") {
+ willrele[argc] = 3;
+ i++;
} else
willrele[argc] = 0;
+
if ($2 == "SHOULDBELOCKED") {
shouldbelocked[argc] = 1;
i++;
@@ -280,10 +289,17 @@ function doit() {
vpnum = 0;
for (i=0; i<argc; i++) {
if (willrele[i]) {
+ if (willrele[i] == 2) {
+ word = "UNLOCK";
+ } else if (willrele[i] == 3) {
+ word = "PUT";
+ } else {
+ word = "RELE";
+ }
if (argdir[i] ~ /OUT/) {
- printf(" | VDESC_VPP_WILLRELE");
+ printf(" | VDESC_VPP_WILL%s", word);
} else {
- printf(" | VDESC_VP%s_WILLRELE", vpnum);
+ printf(" | VDESC_VP%s_WILL%s", vpnum, word);
};
vpnum++;
}
diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src
index 4eb88e93191..bf5c220660a 100644
--- a/sys/kern/vnode_if.src
+++ b/sys/kern/vnode_if.src
@@ -1,4 +1,4 @@
-# $OpenBSD: vnode_if.src,v 1.19 2002/02/22 20:37:45 drahn Exp $
+# $OpenBSD: vnode_if.src,v 1.20 2003/05/01 21:13:05 tedu Exp $
# $NetBSD: vnode_if.src,v 1.10 1996/05/11 18:26:27 mycroft Exp $
#
# Copyright (c) 1992, 1993
@@ -94,7 +94,7 @@ vop_lookup {
#
vop_create {
- IN SHOULDBELOCKED WILLRELE struct vnode *dvp;
+ IN SHOULDBELOCKED WILLPUT struct vnode *dvp;
OUT struct vnode **vpp;
IN struct componentname *cnp;
IN struct vattr *vap;
@@ -106,7 +106,7 @@ vop_create {
#
vop_mknod {
- IN SHOULDBELOCKED WILLRELE struct vnode *dvp;
+ IN SHOULDBELOCKED WILLPUT struct vnode *dvp;
OUT WILLRELE struct vnode **vpp;
IN struct componentname *cnp;
IN struct vattr *vap;
@@ -258,8 +258,8 @@ vop_fsync {
#
vop_remove {
- IN SHOULDBELOCKED WILLRELE struct vnode *dvp;
- IN SHOULDBELOCKED WILLRELE struct vnode *vp;
+ IN SHOULDBELOCKED WILLPUT struct vnode *dvp;
+ IN SHOULDBELOCKED WILLPUT struct vnode *vp;
IN struct componentname *cnp;
};
@@ -268,7 +268,7 @@ vop_remove {
#% link tdvp L U U
#
vop_link {
- IN SHOULDBELOCKED WILLRELE struct vnode *dvp;
+ IN SHOULDBELOCKED WILLPUT struct vnode *dvp;
IN struct vnode *vp;
IN struct componentname *cnp;
};
@@ -284,7 +284,7 @@ vop_rename {
IN WILLRELE struct vnode *fdvp;
IN WILLRELE struct vnode *fvp;
IN struct componentname *fcnp;
- IN SHOULDBELOCKED WILLRELE struct vnode *tdvp;
+ IN SHOULDBELOCKED WILLPUT struct vnode *tdvp;
IN WILLRELE struct vnode *tvp;
IN struct componentname *tcnp;
};
@@ -295,7 +295,7 @@ vop_rename {
#
vop_mkdir {
- IN SHOULDBELOCKED WILLRELE struct vnode *dvp;
+ IN SHOULDBELOCKED WILLPUT struct vnode *dvp;
OUT struct vnode **vpp;
IN struct componentname *cnp;
IN struct vattr *vap;
@@ -307,8 +307,8 @@ vop_mkdir {
#
vop_rmdir {
- IN SHOULDBELOCKED WILLRELE struct vnode *dvp;
- IN SHOULDBELOCKED WILLRELE struct vnode *vp;
+ IN SHOULDBELOCKED WILLPUT struct vnode *dvp;
+ IN SHOULDBELOCKED WILLPUT struct vnode *vp;
IN struct componentname *cnp;
};
@@ -322,7 +322,7 @@ vop_rmdir {
#
vop_symlink {
- IN SHOULDBELOCKED WILLRELE struct vnode *dvp;
+ IN SHOULDBELOCKED WILLPUT struct vnode *dvp;
OUT WILLRELE struct vnode **vpp;
IN struct componentname *cnp;
IN struct vattr *vap;
@@ -364,7 +364,7 @@ vop_abortop {
#% inactive vp L U U
#
vop_inactive {
- IN SHOULDBELOCKED struct vnode *vp;
+ IN SHOULDBELOCKED WILLUNLOCK struct vnode *vp;
IN struct proc *p;
};
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h
index df1d61151b4..b890471dd18 100644
--- a/sys/sys/vnode.h
+++ b/sys/sys/vnode.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vnode.h,v 1.52 2003/02/24 02:17:22 deraadt Exp $ */
+/* $OpenBSD: vnode.h,v 1.53 2003/05/01 21:13:05 tedu Exp $ */
/* $NetBSD: vnode.h,v 1.38 1996/02/29 20:59:05 cgd Exp $ */
/*
@@ -113,6 +113,7 @@ struct vnode {
} v_un;
struct simplelock v_interlock; /* lock on usecount and flag */
+ struct lock v_lock;
struct lock *v_vnlock; /* used for non-locking fs's */
enum vtagtype v_tag; /* type of underlying data */
void *v_data; /* private data for fs */
@@ -136,6 +137,7 @@ struct vnode {
#define VXLOCK 0x0100 /* vnode is locked to change underlying type */
#define VXWANT 0x0200 /* process is waiting for vnode */
#define VALIASED 0x0800 /* vnode has an alias */
+#define VLAYER 0x2000 /* vnode is on a layer file system */
#define VLOCKSWORK 0x4000 /* FS supports locking discipline */
/*
@@ -286,12 +288,20 @@ extern struct vattr va_null; /* predefined null vattr structure */
*/
#define VDESC_MAX_VPS 16
/* Low order 16 flag bits are reserved for willrele flags for vp arguments. */
-#define VDESC_VP0_WILLRELE 0x0001
-#define VDESC_VP1_WILLRELE 0x0002
-#define VDESC_VP2_WILLRELE 0x0004
-#define VDESC_VP3_WILLRELE 0x0008
-#define VDESC_NOMAP_VPP 0x0100
-#define VDESC_VPP_WILLRELE 0x0200
+#define VDESC_VP0_WILLRELE 0x00000001
+#define VDESC_VP1_WILLRELE 0x00000002
+#define VDESC_VP2_WILLRELE 0x00000004
+#define VDESC_VP3_WILLRELE 0x00000008
+#define VDESC_VP0_WILLUNLOCK 0x00000100
+#define VDESC_VP1_WILLUNLOCK 0x00000200
+#define VDESC_VP2_WILLUNLOCK 0x00000400
+#define VDESC_VP3_WILLUNLOCK 0x00000800
+#define VDESC_VP0_WILLPUT 0x00000101
+#define VDESC_VP1_WILLPUT 0x00000202
+#define VDESC_VP2_WILLPUT 0x00000404
+#define VDESC_VP3_WILLPUT 0x00000808
+#define VDESC_NOMAP_VPP 0x00010000
+#define VDESC_VPP_WILLRELE 0x00020000
/*
* VDESC_NO_OFFSET is used to identify the end of the offset list