Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys change vop_symlink and vop_mknod to return vpp (the crea...



details:   https://anonhg.NetBSD.org/src/rev/08ce79e49ccd
branches:  trunk
changeset: 513105:08ce79e49ccd
user:      assar <assar%NetBSD.org@localhost>
date:      Tue Jul 24 15:39:30 2001 +0000

description:
change vop_symlink and vop_mknod to return vpp (the created node)
refed, so that the caller can actually use it.  update callers and
file systems that implement these vnode operations

diffstat:

 sys/coda/coda_vnops.c            |  17 +----------------
 sys/kern/vfs_syscalls.c          |  11 +++++++++--
 sys/kern/vnode_if.c              |   6 +++---
 sys/kern/vnode_if.src            |  14 +++++---------
 sys/lkm/netinet/if_ipl/mln_ipl.c |   3 ++-
 sys/miscfs/genfs/layer_vnops.c   |   7 +++----
 sys/miscfs/union/union_vnops.c   |  17 +++++++----------
 sys/nfs/nfs_serv.c               |  39 ++++++++++-----------------------------
 sys/nfs/nfs_vnops.c              |  31 +++++++++++++++++++++----------
 sys/ufs/ext2fs/ext2fs_vnops.c    |  15 ++++++++++++---
 sys/ufs/lfs/lfs_vnops.c          |  12 ++++++++++--
 sys/ufs/ufs/ufs_vnops.c          |  17 +++++++++++++----
 12 files changed, 96 insertions(+), 93 deletions(-)

diffs (truncated from 513 to 300 lines):

diff -r 2406f8427dff -r 08ce79e49ccd sys/coda/coda_vnops.c
--- a/sys/coda/coda_vnops.c     Tue Jul 24 15:32:02 2001 +0000
+++ b/sys/coda/coda_vnops.c     Tue Jul 24 15:39:30 2001 +0000
@@ -6,7 +6,7 @@
 rmdir
 symlink
 */
-/*     $NetBSD: coda_vnops.c,v 1.25 2001/07/03 06:46:52 chs Exp $      */
+/*     $NetBSD: coda_vnops.c,v 1.26 2001/07/24 15:39:30 assar Exp $    */
 
 /*
  * 
@@ -1655,21 +1655,6 @@
     }
 
     /* 
-     * Okay, now we have to drop locks on dvp.  vpp 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
-     * 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
-                                  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);
-    }
-
-    /* 
      * Free the name buffer 
      */
     if ((cnp->cn_flags & SAVESTART) == 0) {
diff -r 2406f8427dff -r 08ce79e49ccd sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c   Tue Jul 24 15:32:02 2001 +0000
+++ b/sys/kern/vfs_syscalls.c   Tue Jul 24 15:39:30 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls.c,v 1.167 2001/06/28 08:04:18 jdolecek Exp $      */
+/*     $NetBSD: vfs_syscalls.c,v 1.168 2001/07/24 15:39:31 assar Exp $ */
 
 /*
  * Copyright (c) 1989, 1993
@@ -1381,6 +1381,8 @@
                } else {
                        error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp,
                                                &nd.ni_cnd, &vattr);
+                       if (error == 0)
+                               vput(nd.ni_vp);
                }
        } else {
                VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
@@ -1428,7 +1430,10 @@
        vattr.va_type = VFIFO;
        vattr.va_mode = (SCARG(uap, mode) & ALLPERMS) &~ p->p_cwdi->cwdi_cmask;
        VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
-       return (VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr));
+       error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
+       if (error == 0)
+               vput(nd.ni_vp);
+       return (error);
 }
 
 /*
@@ -1514,6 +1519,8 @@
        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);
+       if (error == 0)
+               vput(nd.ni_vp);
 out:
        PNBUF_PUT(path);
        return (error);
diff -r 2406f8427dff -r 08ce79e49ccd sys/kern/vnode_if.c
--- a/sys/kern/vnode_if.c       Tue Jul 24 15:32:02 2001 +0000
+++ b/sys/kern/vnode_if.c       Tue Jul 24 15:39:30 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vnode_if.c,v 1.36 2001/05/26 21:34:04 chs Exp $        */
+/*     $NetBSD: vnode_if.c,v 1.37 2001/07/24 15:39:31 assar Exp $      */
 
 /*
  * Warning: This file is generated automatically.
@@ -198,7 +198,7 @@
 const struct vnodeop_desc vop_mknod_desc = {
        5,
        "vop_mknod",
-       0 | VDESC_VP0_WILLPUT | VDESC_VPP_WILLRELE,
+       0 | VDESC_VP0_WILLPUT,
        vop_mknod_vp_offsets,
        VOPARG_OFFSETOF(struct vop_mknod_args, a_vpp),
        VDESC_NO_OFFSET,
@@ -868,7 +868,7 @@
 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,
diff -r 2406f8427dff -r 08ce79e49ccd sys/kern/vnode_if.src
--- a/sys/kern/vnode_if.src     Tue Jul 24 15:32:02 2001 +0000
+++ b/sys/kern/vnode_if.src     Tue Jul 24 15:39:30 2001 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: vnode_if.src,v 1.28 2001/05/26 21:33:11 chs Exp $
+#      $NetBSD: vnode_if.src,v 1.29 2001/07/24 15:39:31 assar Exp $
 #
 # Copyright (c) 1992, 1993
 #      The Regents of the University of California.  All rights reserved.
@@ -113,13 +113,13 @@
 
 #
 #% mknod      dvp     L U U
-#% mknod      vpp     - X -
+#% mknod      vpp     - L -
 #
 #! mknod cnp   CREATE, LOCKPARENT
 #
 vop_mknod {
        IN WILLPUT struct vnode *dvp;
-       OUT WILLRELE struct vnode **vpp;
+       OUT struct vnode **vpp;
        IN struct componentname *cnp;
        IN struct vattr *vap;
 };
@@ -338,17 +338,13 @@
 
 #
 #% symlink    dvp     L U U
-#% symlink    vpp     - U -
+#% symlink    vpp     - L -
 #
 #! 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;
+       OUT struct vnode **vpp;
        IN struct componentname *cnp;
        IN struct vattr *vap;
        IN char *target;
diff -r 2406f8427dff -r 08ce79e49ccd sys/lkm/netinet/if_ipl/mln_ipl.c
--- a/sys/lkm/netinet/if_ipl/mln_ipl.c  Tue Jul 24 15:32:02 2001 +0000
+++ b/sys/lkm/netinet/if_ipl/mln_ipl.c  Tue Jul 24 15:39:30 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mln_ipl.c,v 1.24 2001/02/05 10:42:42 chs Exp $ */
+/*     $NetBSD: mln_ipl.c,v 1.25 2001/07/24 15:39:32 assar Exp $       */
 
 /*
  * Copyright (C) 1993-2000 by Darren Reed.
@@ -253,6 +253,7 @@
                error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
                if (error)
                        return error;
+               vput(nd.ni_vp);
        }
        return error;
 }
diff -r 2406f8427dff -r 08ce79e49ccd sys/miscfs/genfs/layer_vnops.c
--- a/sys/miscfs/genfs/layer_vnops.c    Tue Jul 24 15:32:02 2001 +0000
+++ b/sys/miscfs/genfs/layer_vnops.c    Tue Jul 24 15:39:30 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: layer_vnops.c,v 1.6 2001/06/07 13:32:47 wiz Exp $      */
+/*     $NetBSD: layer_vnops.c,v 1.7 2001/07/24 15:39:32 assar Exp $    */
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -71,7 +71,7 @@
  *
  * Ancestors:
  *     @(#)lofs_vnops.c        1.2 (Berkeley) 6/18/92
- *     $Id: layer_vnops.c,v 1.6 2001/06/07 13:32:47 wiz Exp $
+ *     $Id: layer_vnops.c,v 1.7 2001/07/24 15:39:32 assar Exp $
  *     ...and...
  *     @(#)null_vnodeops.c 1.20 92/07/07 UCLA Ficus project
  */
@@ -393,8 +393,7 @@
                                 descp->vdesc_vpp_offset,ap);
                /*
                 * Only vop_lookup, vop_create, vop_makedir, vop_bmap,
-                * vop_mknod, and vop_symlink return vpp's. The latter
-                * two are VPP_WILLRELE, so we won't get here, and vop_bmap
+                * vop_mknod, and vop_symlink return vpp's. vop_bmap
                 * doesn't call bypass as the lower vpp is fine (we're just
                 * going to do i/o on it). vop_loookup doesn't call bypass
                 * as a lookup on "." would generate a locking error.
diff -r 2406f8427dff -r 08ce79e49ccd sys/miscfs/union/union_vnops.c
--- a/sys/miscfs/union/union_vnops.c    Tue Jul 24 15:32:02 2001 +0000
+++ b/sys/miscfs/union/union_vnops.c    Tue Jul 24 15:39:30 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: union_vnops.c,v 1.53 2001/07/04 21:38:00 chs Exp $     */
+/*     $NetBSD: union_vnops.c,v 1.54 2001/07/24 15:39:32 assar Exp $   */
 
 /*
  * Copyright (c) 1992, 1993, 1994, 1995 Jan-Simon Pendry.
@@ -610,12 +610,10 @@
                if (error)
                        return (error);
 
-               if (vp != NULLVP) {
-                       error = union_allocvp(ap->a_vpp, mp, NULLVP, NULLVP,
-                                       cnp, vp, NULLVP, 1);
-                       if (error)
-                               vput(vp);
-               }
+               error = union_allocvp(ap->a_vpp, mp, NULLVP, NULLVP,
+                                     cnp, vp, NULLVP, 1);
+               if (error)
+                   vput(vp);
                return (error);
        }
 
@@ -1527,14 +1525,13 @@
 
        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, ap->a_vpp, cnp, ap->a_vap,
+                                   ap->a_target);
                return (error);
        }
 
diff -r 2406f8427dff -r 08ce79e49ccd sys/nfs/nfs_serv.c
--- a/sys/nfs/nfs_serv.c        Tue Jul 24 15:32:02 2001 +0000
+++ b/sys/nfs/nfs_serv.c        Tue Jul 24 15:39:30 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs_serv.c,v 1.59 2000/11/27 08:39:49 chs Exp $        */
+/*     $NetBSD: nfs_serv.c,v 1.60 2001/07/24 15:39:33 assar Exp $      */
 
 /*
  * Copyright (c) 1989, 1993
@@ -1417,14 +1417,6 @@
                                vrele(nd.ni_startdir);
                                nfsm_reply(0);
                        }
-                       nd.ni_cnd.cn_nameiop = LOOKUP;
-                       nd.ni_cnd.cn_flags &= ~(LOCKPARENT | SAVESTART);
-                       nd.ni_cnd.cn_proc = procp;
-                       nd.ni_cnd.cn_cred = cred;
-                       if ((error = lookup(&nd)) != 0) {
-                               PNBUF_PUT(nd.ni_cnd.cn_pnbuf);
-                               nfsm_reply(0);
-                       }
                        PNBUF_PUT(nd.ni_cnd.cn_pnbuf);
                        if (nd.ni_cnd.cn_flags & ISSYMLINK) {
                                vrele(nd.ni_dvp);
@@ -1618,11 +1610,6 @@
                        vrele(nd.ni_startdir);
                        goto out;
                }
-               nd.ni_cnd.cn_nameiop = LOOKUP;
-               nd.ni_cnd.cn_flags &= ~(LOCKPARENT | SAVESTART);
-               nd.ni_cnd.cn_proc = procp;
-               nd.ni_cnd.cn_cred = procp->p_ucred;
-               error = lookup(&nd);
                PNBUF_PUT(nd.ni_cnd.cn_pnbuf);
                if (error)
                        goto out;
@@ -2146,23 +2133,17 @@
                vrele(nd.ni_startdir);
        else {
            if (v3) {
-               nd.ni_cnd.cn_nameiop = LOOKUP;
-               nd.ni_cnd.cn_flags &= ~(LOCKPARENT | SAVESTART | FOLLOW);
-               nd.ni_cnd.cn_flags |= (NOFOLLOW | LOCKLEAF);
-               nd.ni_cnd.cn_proc = procp;
-               nd.ni_cnd.cn_cred = cred;
-               error = lookup(&nd);
-               if (!error) {
-                       memset((caddr_t)fhp, 0, sizeof(nfh));
-                       fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid;
-                       error = VFS_VPTOFH(nd.ni_vp, &fhp->fh_fid);
-                       if (!error)
-                               error = VOP_GETATTR(nd.ni_vp, &va, cred,
+               memset((caddr_t)fhp, 0, sizeof(nfh));
+               fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid;
+               error = VFS_VPTOFH(nd.ni_vp, &fhp->fh_fid);
+               if (!error)
+                   error = VOP_GETATTR(nd.ni_vp, &va, cred,
                                        procp);
-                       vput(nd.ni_vp);
-               }
-           } else
+               vput(nd.ni_vp);
+           } else {
                vrele(nd.ni_startdir);
+               vput(nd.ni_vp);
+           }
            PNBUF_PUT(nd.ni_cnd.cn_pnbuf);



Home | Main Index | Thread Index | Old Index