Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

vfs 4

From: Ted Unangst <tedu(at)Stanford.EDU>
Date: Sun Dec 29 2002 - 21:07:08 EST


This is patch 4. Add the VLAYER flag which will be used later. Add more flags to the vop descriptions to allow more precision. Add a lock to the vnode. Add a missing simple_lock_init for v_interlock. This should have no effect on existing file systems, but is used for future work.

diff -ruNX nodiff vfs3/kern/vfs_subr.c vfs4/kern/vfs_subr.c

--- vfs3/kern/vfs_subr.c	Wed Dec 25 09:24:51 2002
+++ vfs4/kern/vfs_subr.c	Wed Dec 25 22:23:56 2002

@@ -409,12 +409,19 @@
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 @@
} 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 @@
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 @@
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 -ruNX nodiff vfs3/kern/vfs_syscalls.c vfs4/kern/vfs_syscalls.c --- vfs3/kern/vfs_syscalls.c Wed Dec 25 09:24:51 2002 +++ vfs4/kern/vfs_syscalls.c Wed Dec 25 22:08:51 2002
@@ -2607,7 +2607,7 @@
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)))
Do you need help?X
VOP_REVOKE(vp, REVOKEALL); out: vrele(vp); diff -ruNX nodiff vfs3/kern/vnode_if.c vfs4/kern/vnode_if.c --- vfs3/kern/vnode_if.c Wed Dec 25 09:24:52 2002 +++ vfs4/kern/vnode_if.c Wed Dec 25 22:08:51 2002

@@ -5,7 +5,7 @@
  • Created from the file:
  • OpenBSD: vnode_if.src,v 1.19 2002/02/22 20:37:45 drahn Exp
  • by the script: - * OpenBSD: vnode_if.sh,v 1.8 2001/02/26 17:34:18 art Exp + * OpenBSD: vnode_if.sh,v 1.10 2002/03/14 23:47:05 millert Exp */

 /*
@@ -119,7 +119,7 @@

 struct vnodeop_desc vop_create_desc = {

 	0,
 	"vop_create",
-	0 | VDESC_VP0_WILLRELE,
+	0 | VDESC_VP0_WILLPUT,
 	vop_create_vp_offsets,
 	VOPARG_OFFSETOF(struct vop_create_args, a_vpp),
 	VDESC_NO_OFFSET,

@@ -154,7 +154,7 @@

 struct vnodeop_desc vop_mknod_desc = {
 	0,
 	"vop_mknod",
-	0 | VDESC_VP0_WILLRELE | VDESC_VPP_WILLRELE,
+	0 | VDESC_VP0_WILLPUT | VDESC_VPP_WILLRELE,
 	vop_mknod_vp_offsets,
 	VOPARG_OFFSETOF(struct vop_mknod_args, a_vpp),
 	VDESC_NO_OFFSET,

@@ -611,7 +611,7 @@

 struct vnodeop_desc vop_remove_desc = {
 	0,
 	"vop_remove",
-	0 | VDESC_VP0_WILLRELE | VDESC_VP1_WILLRELE,
+	0 | VDESC_VP0_WILLPUT | VDESC_VP1_WILLPUT,
 	vop_remove_vp_offsets,
 	VDESC_NO_OFFSET,
 	VDESC_NO_OFFSET,

@@ -649,7 +649,7 @@

 struct vnodeop_desc vop_link_desc = {
 	0,
 	"vop_link",
-	0 | VDESC_VP0_WILLRELE,
+	0 | VDESC_VP0_WILLPUT,
 	vop_link_vp_offsets,
 	VDESC_NO_OFFSET,
 	VDESC_NO_OFFSET,

@@ -685,7 +685,7 @@

 struct vnodeop_desc vop_rename_desc = {
 	0,
 	"vop_rename",
-	0 | VDESC_VP0_WILLRELE | VDESC_VP1_WILLRELE | VDESC_VP2_WILLRELE | VDESC_VP3_WILLRELE,
+	0 | VDESC_VP0_WILLRELE | VDESC_VP1_WILLRELE | VDESC_VP2_WILLPUT | VDESC_VP3_WILLRELE,
 	vop_rename_vp_offsets,
 	VDESC_NO_OFFSET,
 	VDESC_NO_OFFSET,

@@ -724,7 +724,7 @@

 struct vnodeop_desc vop_mkdir_desc = {
 	0,
 	"vop_mkdir",
-	0 | VDESC_VP0_WILLRELE,
+	0 | VDESC_VP0_WILLPUT,
 	vop_mkdir_vp_offsets,
 	VOPARG_OFFSETOF(struct vop_mkdir_args, a_vpp),
 	VDESC_NO_OFFSET,

@@ -760,7 +760,7 @@

 struct vnodeop_desc vop_rmdir_desc = {
 	0,
 	"vop_rmdir",
-	0 | VDESC_VP0_WILLRELE | VDESC_VP1_WILLRELE,
+	0 | VDESC_VP0_WILLPUT | VDESC_VP1_WILLPUT,
 	vop_rmdir_vp_offsets,
 	VDESC_NO_OFFSET,
 	VDESC_NO_OFFSET,

@@ -797,7 +797,7 @@

 struct vnodeop_desc vop_symlink_desc = {
 	0,
 	"vop_symlink",
-	0 | VDESC_VP0_WILLRELE | VDESC_VPP_WILLRELE,
+	0 | VDESC_VP0_WILLPUT | VDESC_VPP_WILLRELE,
 	vop_symlink_vp_offsets,
 	VOPARG_OFFSETOF(struct vop_symlink_args, a_vpp),
 	VDESC_NO_OFFSET,

@@ -933,7 +933,7 @@

 struct vnodeop_desc vop_inactive_desc = {
 	0,
 	"vop_inactive",
-	0,
+	0 | VDESC_VP0_WILLUNLOCK,
 	vop_inactive_vp_offsets,
Do you need more help?X
VDESC_NO_OFFSET, VDESC_NO_OFFSET, diff -ruNX nodiff vfs3/kern/vnode_if.sh vfs4/kern/vnode_if.sh --- vfs3/kern/vnode_if.sh Wed Dec 25 09:24:52 2002 +++ vfs4/kern/vnode_if.sh Wed Dec 25 22:08:51 2002
@@ -112,8 +112,17 @@
$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;

@@ -280,10 +289,17 @@
vpnum = 0; for (i=0; i
@@ -94,7 +94,7 @@
 #

 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_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_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;
Can we help you?X

 };

@@ -268,7 +268,7 @@

 #% 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 @@
 	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_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 @@

 #
Can't find what you're looking for?X

 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_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 @@
#% inactive vp L U U

 #
 vop_inactive {
-	IN SHOULDBELOCKED struct vnode *vp;
+	IN SHOULDBELOCKED WILLUNLOCK struct vnode *vp;
 	IN struct proc *p;

 };

diff -ruNX nodiff vfs3/sys/vnode.h vfs4/sys/vnode.h

--- vfs3/sys/vnode.h	Wed Dec 25 09:25:06 2002
+++ vfs4/sys/vnode.h	Wed Dec 25 22:08:51 2002

@@ -113,6 +113,7 @@
} 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 @@
#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 filesystem */
Don't know where to look next?X
#define VLOCKSWORK 0x4000 /* FS supports locking discipline */

 /*
@@ -286,12 +288,20 @@

  */
 #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 diff -ruNX nodiff vfs3/sys/vnode_if.h vfs4/sys/vnode_if.h --- vfs3/sys/vnode_if.h Wed Dec 25 09:25:06 2002 +++ vfs4/sys/vnode_if.h Wed Dec 25 22:08:51 2002
    @@ -5,7 +5,7 @@
  • Created from the file:
  • OpenBSD: vnode_if.src,v 1.19 2002/02/22 20:37:45 drahn Exp
  • by the script: - * OpenBSD: vnode_if.sh,v 1.8 2001/02/26 17:34:18 art Exp + * OpenBSD: vnode_if.sh,v 1.10 2002/03/14 23:47:05 millert Exp */

 /*
@@ -121,8 +121,7 @@

         struct proc *a_p;
 };
 extern struct vnodeop_desc vop_getattr_desc; -int VOP_GETATTR(struct vnode *, struct vattr *, struct ucred *, - struct proc *);
+int VOP_GETATTR(struct vnode *, struct vattr *, struct ucred *, struct proc *);

Confused? Frustrated?X

 struct vop_setattr_args {

         struct vnodeop_desc *a_desc;
@@ -132,8 +131,7 @@

         struct proc *a_p;
 };
 extern struct vnodeop_desc vop_setattr_desc; -int VOP_SETATTR(struct vnode *, struct vattr *, struct ucred *, - struct proc *);
+int VOP_SETATTR(struct vnode *, struct vattr *, struct ucred *, struct proc *);

 struct vop_read_args {

         struct vnodeop_desc *a_desc;
@@ -275,8 +273,8 @@

         char *a_target;
 };
 extern struct vnodeop_desc vop_symlink_desc; -int VOP_SYMLINK(struct vnode *, struct vnode **, - struct componentname *, struct vattr *, char *); +int VOP_SYMLINK(struct vnode *, struct vnode **, struct componentname *, + struct vattr *, char *);

 struct vop_readdir_args {

         struct vnodeop_desc *a_desc;
@@ -288,8 +286,8 @@

Call Pantek today for Open Source Technical Support at 1-877-546-8934 - 24/7/365X

         u_long **a_cookies;
 };
 extern struct vnodeop_desc vop_readdir_desc; -int VOP_READDIR(struct vnode *, struct uio *, struct ucred *, int *, - int *, u_long **);
+int VOP_READDIR(struct vnode *, struct uio *, struct ucred *, int *, int *, + u_long **);

 struct vop_readlink_args {

         struct vnodeop_desc *a_desc;

--
"I promise you a police car on every sidewalk."
      - M. Barry, Mayor of Washington, DC
Received on Sun Dec 29 21:57:26 2002

This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 13:29:40 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library