Subject: vop_symlink and unused vpp?
To: None <tech-kern@netbsd.org>
From: Assar Westerlund <assar@netbsd.org>
List: tech-kern
Date: 07/16/2001 18:11:06
--=-=-=

VOP_SYMLINK takes an argument `struct vnode **vpp' that is never used
by any of the callers.  It would be hard to use it too, since it's not
supposed to be returned vrefed.  And only some of the filesystems
actually fill it in.

Appended is a patch for removing it.  Any comments?

/assar

--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=netbsd-sys.diff

Index: adosfs/advnops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/adosfs/advnops.c,v
retrieving revision 1.60
diff -u -w -r1.60 advnops.c
--- adosfs/advnops.c	2001/05/30 11:40:35	1.60
+++ adosfs/advnops.c	2001/07/16 16:02:28
@@ -444,7 +444,6 @@
 {
 	struct vop_symlink_args /* {
 		struct vnode *a_dvp;
-		struct vnode **a_vpp;
 		struct componentname *a_cnp;
 		struct vattr *a_vap;
 		char *a_target;
Index: coda/coda_vnops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/coda/coda_vnops.c,v
retrieving revision 1.25
diff -u -w -r1.25 coda_vnops.c
--- coda/coda_vnops.c	2001/07/03 06:46:52	1.25
+++ coda/coda_vnops.c	2001/07/16 16:03:38
@@ -1603,6 +1603,7 @@
     const char *nm = cnp->cn_nameptr;
     int len = cnp->cn_namelen;
     int plen = strlen(path);
+    struct vnode *vp = NULL;
 
     /* XXX What about the vpp argument?  Do we need it? */
     /* 
@@ -1651,22 +1652,22 @@
 	nd.ni_pathlen = len;
 	vput(tdvp);
 	error = lookup(&nd);
-	*ap->a_vpp = nd.ni_vp;
+	vp = nd.ni_vp;
     }
 
     /* 
-     * Okay, now we have to drop locks on dvp.  vpp is unlocked, but
+     * Okay, now we have to drop locks on dvp.  nd.ni_vp is unlocked, but
      * ref'd.  It doesn't matter what happens in either symlink or
-     * lookup.  Furthermore, there isn't any way for (dvp == *vpp), so
+     * lookup.  Furthermore, there isn't any way for (dvp == nd.ni_vp), so
      * we don't bother checking.  
      */
 /*  vput(ap->a_dvp);		released earlier */
-    if (*ap->a_vpp) {
-    	VOP_UNLOCK(*ap->a_vpp, 0);	/* this line is new!! It is necessary because lookup() calls
+    if (vp) {
+    	VOP_UNLOCK(vp, 0);	/* this line is new!! It is necessary because lookup() calls
 				   VOP_LOOKUP (coda_lookup) which returns vpp locked.  cfs_nb_lookup
 				   merged with coda_lookup() to become coda_lookup so UNLOCK is
 				   necessary */
-    	vrele(*ap->a_vpp);
+    	vrele(vp);
     }
 
     /* 
Index: filecorefs/filecore_vnops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/filecorefs/filecore_vnops.c,v
retrieving revision 1.13
diff -u -w -r1.13 filecore_vnops.c
--- filecorefs/filecore_vnops.c	2001/05/28 02:50:51	1.13
+++ filecorefs/filecore_vnops.c	2001/07/16 16:03:47
@@ -400,7 +400,6 @@
 {
 	struct vop_symlink_args /* {
 		struct vnode *a_dvp;
-		struct vnode **a_vpp;
 		struct componentname *a_cnp;
 		struct vattr *a_vap;
 		char *a_target;
Index: isofs/cd9660/cd9660_vnops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/isofs/cd9660/cd9660_vnops.c,v
retrieving revision 1.64
diff -u -w -r1.64 cd9660_vnops.c
--- isofs/cd9660/cd9660_vnops.c	2001/05/28 02:50:52	1.64
+++ isofs/cd9660/cd9660_vnops.c	2001/07/16 16:03:47
@@ -737,7 +737,6 @@
 {
 	struct vop_symlink_args /* {
 		struct vnode *a_dvp;
-		struct vnode **a_vpp;
 		struct componentname *a_cnp;
 		struct vattr *a_vap;
 		char *a_target;
Index: kern/vfs_syscalls.c
===================================================================
RCS file: /cvsroot/syssrc/sys/kern/vfs_syscalls.c,v
retrieving revision 1.167
diff -u -w -r1.167 vfs_syscalls.c
--- kern/vfs_syscalls.c	2001/06/28 08:04:18	1.167
+++ kern/vfs_syscalls.c	2001/07/16 16:03:48
@@ -1513,7 +1513,7 @@
 	VATTR_NULL(&vattr);
 	vattr.va_mode = ACCESSPERMS &~ p->p_cwdi->cwdi_cmask;
 	VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
-	error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr, path);
+	error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_cnd, &vattr, path);
 out:
 	PNBUF_PUT(path);
 	return (error);
Index: kern/vnode_if.c
===================================================================
RCS file: /cvsroot/syssrc/sys/kern/vnode_if.c,v
retrieving revision 1.36
diff -u -w -r1.36 vnode_if.c
--- kern/vnode_if.c	2001/05/26 21:34:04	1.36
+++ kern/vnode_if.c	2001/07/16 16:03:49
@@ -868,9 +868,9 @@
 const struct vnodeop_desc vop_symlink_desc = {
 	25,
 	"vop_symlink",
-	0 | VDESC_VP0_WILLPUT | VDESC_VPP_WILLRELE,
+	0 | VDESC_VP0_WILLPUT,
 	vop_symlink_vp_offsets,
-	VOPARG_OFFSETOF(struct vop_symlink_args, a_vpp),
+	VDESC_NO_OFFSET,
 	VDESC_NO_OFFSET,
 	VDESC_NO_OFFSET,
 	VOPARG_OFFSETOF(struct vop_symlink_args, a_cnp),
@@ -878,9 +878,8 @@
 };
 #ifdef VNODE_OP_NOINLINE
 int
-VOP_SYMLINK(dvp, vpp, cnp, vap, target)
+VOP_SYMLINK(dvp, cnp, vap, target)
 	struct vnode *dvp;
-	struct vnode **vpp;
 	struct componentname *cnp;
 	struct vattr *vap;
 	char *target;
@@ -888,7 +887,6 @@
 	struct vop_symlink_args a;
 	a.a_desc = VDESC(vop_symlink);
 	a.a_dvp = dvp;
-	a.a_vpp = vpp;
 	a.a_cnp = cnp;
 	a.a_vap = vap;
 	a.a_target = target;
Index: kern/vnode_if.src
===================================================================
RCS file: /cvsroot/syssrc/sys/kern/vnode_if.src,v
retrieving revision 1.28
diff -u -w -r1.28 vnode_if.src
--- kern/vnode_if.src	2001/05/26 21:33:11	1.28
+++ kern/vnode_if.src	2001/07/16 16:03:49
@@ -338,17 +338,11 @@
 
 #
 #% symlink    dvp     L U U
-#% symlink    vpp     - U -
 #
 #! symlink cnp	CREATE, LOCKPARENT
 #
-# XXX - note that the return vnode has already been VRELE'ed
-#     by the filesystem layer.  To use it you must use vget,
-#     possibly with a further namei.
-#
 vop_symlink {
 	IN WILLPUT struct vnode *dvp;
-	OUT WILLRELE struct vnode **vpp;
 	IN struct componentname *cnp;
 	IN struct vattr *vap;
 	IN char *target;
Index: miscfs/fdesc/fdesc_vnops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/miscfs/fdesc/fdesc_vnops.c,v
retrieving revision 1.64
diff -u -w -r1.64 fdesc_vnops.c
--- miscfs/fdesc/fdesc_vnops.c	2001/06/16 08:28:39	1.64
+++ miscfs/fdesc/fdesc_vnops.c	2001/07/16 16:03:56
@@ -1053,7 +1053,6 @@
 {
 	struct vop_symlink_args /* {
 		struct vnode *a_dvp;
-		struct vnode **a_vpp;
 		struct componentname *a_cnp;
 		struct vattr *a_vap;
 		char *a_target;
Index: miscfs/kernfs/kernfs_vnops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/miscfs/kernfs/kernfs_vnops.c,v
retrieving revision 1.76
diff -u -w -r1.76 kernfs_vnops.c
--- miscfs/kernfs/kernfs_vnops.c	2001/06/03 02:23:31	1.76
+++ miscfs/kernfs/kernfs_vnops.c	2001/07/16 16:03:56
@@ -796,7 +796,6 @@
 {
 	struct vop_symlink_args /* {
 		struct vnode *a_dvp;
-		struct vnode **a_vpp;
 		struct componentname *a_cnp;
 		struct vattr *a_vap;
 		char *a_target;
Index: miscfs/portal/portal_vnops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/miscfs/portal/portal_vnops.c,v
retrieving revision 1.38
diff -u -w -r1.38 portal_vnops.c
--- miscfs/portal/portal_vnops.c	2001/06/03 02:22:40	1.38
+++ miscfs/portal/portal_vnops.c	2001/07/16 16:03:56
@@ -718,7 +718,6 @@
 {
 	struct vop_symlink_args /* {
 		struct vnode *a_dvp;
-		struct vnode **a_vpp;
 		struct componentname *a_cnp;
 		struct vattr *a_vap;
 		char *a_target;
Index: miscfs/procfs/procfs_vnops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/miscfs/procfs/procfs_vnops.c,v
retrieving revision 1.82
diff -u -w -r1.82 procfs_vnops.c
--- miscfs/procfs/procfs_vnops.c	2001/06/03 02:21:35	1.82
+++ miscfs/procfs/procfs_vnops.c	2001/07/16 16:03:57
@@ -428,7 +428,6 @@
 {
 	struct vop_symlink_args /* {
 		struct vnode *a_dvp;
-		struct vnode **a_vpp;
 		struct componentname *a_cnp;
 		struct vattr *a_vap;
 		char *a_target;
Index: miscfs/union/union_vnops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/miscfs/union/union_vnops.c,v
retrieving revision 1.53
diff -u -w -r1.53 union_vnops.c
--- miscfs/union/union_vnops.c	2001/07/04 21:38:00	1.53
+++ miscfs/union/union_vnops.c	2001/07/16 16:03:57
@@ -1516,7 +1516,6 @@
 {
 	struct vop_symlink_args /* {
 		struct vnode *a_dvp;
-		struct vnode **a_vpp;
 		struct componentname *a_cnp;
 		struct vattr *a_vap;
 		char *a_target;
@@ -1527,14 +1526,12 @@
 
 	if (dvp != NULLVP) {
 		int error;
-		struct vnode *vp;
 
 		FIXUP(un);
 		VREF(dvp);
 		un->un_flags |= UN_KLOCK;
 		vput(ap->a_dvp);
-		error = VOP_SYMLINK(dvp, &vp, cnp, ap->a_vap, ap->a_target);
-		*ap->a_vpp = NULLVP;
+		error = VOP_SYMLINK(dvp, cnp, ap->a_vap, ap->a_target);
 		return (error);
 	}
 
Index: msdosfs/msdosfs_vnops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/msdosfs/msdosfs_vnops.c,v
retrieving revision 1.109
diff -u -w -r1.109 msdosfs_vnops.c
--- msdosfs/msdosfs_vnops.c	2001/06/12 14:59:29	1.109
+++ msdosfs/msdosfs_vnops.c	2001/07/16 16:03:58
@@ -1390,7 +1390,6 @@
 {
 	struct vop_symlink_args /* {
 		struct vnode *a_dvp;
-		struct vnode **a_vpp;
 		struct componentname *a_cnp;
 		struct vattr *a_vap;
 		char *a_target;
Index: nfs/nfs_serv.c
===================================================================
RCS file: /cvsroot/syssrc/sys/nfs/nfs_serv.c,v
retrieving revision 1.59
diff -u -w -r1.59 nfs_serv.c
--- nfs/nfs_serv.c	2000/11/27 08:39:49	1.59
+++ nfs/nfs_serv.c	2001/07/16 16:03:59
@@ -2141,7 +2141,7 @@
 		goto out;
 	}
 	nqsrv_getl(nd.ni_dvp, ND_WRITE);
-	error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va, pathcp);
+	error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_cnd, &va, pathcp);
 	if (error)
 		vrele(nd.ni_startdir);
 	else {
Index: nfs/nfs_vnops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/nfs/nfs_vnops.c,v
retrieving revision 1.134
diff -u -w -r1.134 nfs_vnops.c
--- nfs/nfs_vnops.c	2001/06/07 01:04:40	1.134
+++ nfs/nfs_vnops.c	2001/07/16 16:03:59
@@ -1851,7 +1851,6 @@
 {
 	struct vop_symlink_args /* {
 		struct vnode *a_dvp;
-		struct vnode **a_vpp;
 		struct componentname *a_cnp;
 		struct vattr *a_vap;
 		char *a_target;
Index: smbfs/smbfs_vnops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/smbfs/smbfs_vnops.c,v
retrieving revision 1.1
diff -u -w -r1.1 smbfs_vnops.c
--- smbfs/smbfs_vnops.c	2000/12/07 03:33:47	1.1
+++ smbfs/smbfs_vnops.c	2001/07/16 16:04:00
@@ -740,7 +740,6 @@
 smbfs_symlink(ap)
 	struct vop_symlink_args /* {
 		struct vnode *a_dvp;
-		struct vnode **a_vpp;
 		struct componentname *a_cnp;
 		struct vattr *a_vap;
 		char *a_target;
Index: sys/vnode_if.h
===================================================================
RCS file: /cvsroot/syssrc/sys/sys/vnode_if.h,v
retrieving revision 1.36
diff -u -w -r1.36 vnode_if.h
--- sys/vnode_if.h	2001/05/26 21:34:04	1.36
+++ sys/vnode_if.h	2001/07/16 16:04:00
@@ -797,7 +797,6 @@
 struct vop_symlink_args {
 	const struct vnodeop_desc *a_desc;
 	struct vnode *a_dvp;
-	struct vnode **a_vpp;
 	struct componentname *a_cnp;
 	struct vattr *a_vap;
 	char *a_target;
@@ -806,16 +805,15 @@
 #ifndef VNODE_OP_NOINLINE
 static __inline
 #endif
-int VOP_SYMLINK(struct vnode *, struct vnode **, struct componentname *, 
-    struct vattr *, char *)
+int VOP_SYMLINK(struct vnode *, struct componentname *, struct vattr *, 
+    char *)
 #ifndef VNODE_OP_NOINLINE
 __attribute__((__unused__))
 #endif
 ;
 #ifndef VNODE_OP_NOINLINE
-static __inline int VOP_SYMLINK(dvp, vpp, cnp, vap, target)
+static __inline int VOP_SYMLINK(dvp, cnp, vap, target)
 	struct vnode *dvp;
-	struct vnode **vpp;
 	struct componentname *cnp;
 	struct vattr *vap;
 	char *target;
@@ -823,7 +821,6 @@
 	struct vop_symlink_args a;
 	a.a_desc = VDESC(vop_symlink);
 	a.a_dvp = dvp;
-	a.a_vpp = vpp;
 	a.a_cnp = cnp;
 	a.a_vap = vap;
 	a.a_target = target;
Index: ufs/ext2fs/ext2fs_vnops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/ufs/ext2fs/ext2fs_vnops.c,v
retrieving revision 1.33
diff -u -w -r1.33 ext2fs_vnops.c
--- ufs/ext2fs/ext2fs_vnops.c	2001/03/23 21:11:08	1.33
+++ ufs/ext2fs/ext2fs_vnops.c	2001/07/16 16:04:01
@@ -1182,20 +1182,18 @@
 {
 	struct vop_symlink_args /* {
 		struct vnode *a_dvp;
-		struct vnode **a_vpp;
 		struct componentname *a_cnp;
 		struct vattr *a_vap;
 		char *a_target;
 	} */ *ap = v;
-	struct vnode *vp, **vpp = ap->a_vpp;
+	struct vnode *vp;
 	struct inode *ip;
 	int len, error;
 
 	error = ext2fs_makeinode(IFLNK | ap->a_vap->va_mode, ap->a_dvp,
-			      vpp, ap->a_cnp);
+			      &vp, ap->a_cnp);
 	if (error)
 		return (error);
-	vp = *vpp;
 	len = strlen(ap->a_target);
 	if (len < vp->v_mount->mnt_maxsymlinklen) {
 		ip = VTOI(vp);
Index: ufs/lfs/lfs_vnops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/ufs/lfs/lfs_vnops.c,v
retrieving revision 1.50
diff -u -w -r1.50 lfs_vnops.c
--- ufs/lfs/lfs_vnops.c	2001/01/22 12:17:43	1.50
+++ ufs/lfs/lfs_vnops.c	2001/07/16 16:04:01
@@ -424,7 +424,6 @@
 {
 	struct vop_symlink_args /* {
 		struct vnode *a_dvp;
-		struct vnode **a_vpp;
 		struct componentname *a_cnp;
 		struct vattr *a_vap;
 		char *a_target;
@@ -438,8 +437,6 @@
 	MARK_VNODE(ap->a_dvp);
 	error = ufs_symlink(ap);
 	UNMARK_VNODE(ap->a_dvp);
-	if (*(ap->a_vpp))
-		UNMARK_VNODE(*(ap->a_vpp));
 	SET_ENDOP(VTOI(ap->a_dvp)->i_lfs,ap->a_dvp,"symlink");
 	return (error);
 }
Index: ufs/ufs/ufs_vnops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/ufs/ufs/ufs_vnops.c,v
retrieving revision 1.78
diff -u -w -r1.78 ufs_vnops.c
--- ufs/ufs/ufs_vnops.c	2001/05/28 02:50:53	1.78
+++ ufs/ufs/ufs_vnops.c	2001/07/16 16:04:01
@@ -1425,21 +1425,18 @@
 {
 	struct vop_symlink_args /* {
 		struct vnode		*a_dvp;
-		struct vnode		**a_vpp;
 		struct componentname	*a_cnp;
 		struct vattr		*a_vap;
 		char			*a_target;
 	} */ *ap = v;
-	struct vnode	*vp, **vpp;
+	struct vnode	*vp;
 	struct inode	*ip;
 	int		len, error;
 
-	vpp = ap->a_vpp;
 	error = ufs_makeinode(IFLNK | ap->a_vap->va_mode, ap->a_dvp,
-			      vpp, ap->a_cnp);
+			      &vp, ap->a_cnp);
 	if (error)
 		return (error);
-	vp = *vpp;
 	len = strlen(ap->a_target);
 	if (len < vp->v_mount->mnt_maxsymlinklen) {
 		ip = VTOI(vp);

--=-=-=--