Source-Changes-HG archive

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

[src/trunk]: src/sys/ufs/ufs VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them ...



details:   https://anonhg.NetBSD.org/src/rev/991bc10b4978
branches:  trunk
changeset: 968466:991bc10b4978
user:      ad <ad%NetBSD.org@localhost>
date:      Fri Jan 17 20:08:06 2020 +0000

description:
VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to
allow us to get shared locks (or no lock) on the returned vnode.  Matches
FreeBSD.

diffstat:

 external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c |   4 +-
 external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c |  27 +++-------------
 sys/coda/coda_vfsops.c                                  |  14 ++++----
 sys/coda/coda_vfsops.h                                  |   8 ++--
 sys/coda/coda_vnops.c                                   |   6 +-
 sys/compat/common/vfs_syscalls_20.c                     |   7 ++-
 sys/compat/common/vfs_syscalls_30.c                     |   7 ++-
 sys/compat/netbsd32/netbsd32_compat_30.c                |   6 +-
 sys/fs/adosfs/adlookup.c                                |  11 +++---
 sys/fs/adosfs/advfsops.c                                |  20 ++++++-----
 sys/fs/adosfs/advnops.c                                 |   7 ++-
 sys/fs/autofs/autofs_vfsops.c                           |   6 +-
 sys/fs/autofs/autofs_vnops.c                            |   6 +-
 sys/fs/cd9660/cd9660_vfsops.c                           |  16 +++++-----
 sys/fs/efs/efs_vfsops.c                                 |  16 +++++-----
 sys/fs/filecorefs/filecore_vfsops.c                     |  17 +++++-----
 sys/fs/hfs/hfs_vfsops.c                                 |  14 ++++----
 sys/fs/msdosfs/msdosfs_vfsops.c                         |  17 +++++-----
 sys/fs/nilfs/nilfs_vfsops.c                             |  12 +++---
 sys/fs/ntfs/ntfs_subr.c                                 |   6 +-
 sys/fs/ntfs/ntfs_vfsops.c                               |  27 ++++++++--------
 sys/fs/ptyfs/ptyfs.h                                    |   4 +-
 sys/fs/ptyfs/ptyfs_vfsops.c                             |  10 +++---
 sys/fs/puffs/puffs_vfsops.c                             |  13 ++++---
 sys/fs/smbfs/smbfs_vfsops.c                             |  10 +++---
 sys/fs/sysvbfs/sysvbfs_vfsops.c                         |  15 +++++----
 sys/fs/sysvbfs/sysvbfs_vnops.c                          |  11 ++++--
 sys/fs/tmpfs/tmpfs_vfsops.c                             |  15 +++++----
 sys/fs/udf/udf_rename.c                                 |   9 +++--
 sys/fs/udf/udf_subr.c                                   |  23 ++++++++-----
 sys/fs/udf/udf_subr.h                                   |   4 +-
 sys/fs/udf/udf_vfsops.c                                 |  12 +++---
 sys/fs/udf/udf_vnops.c                                  |   9 +++--
 sys/fs/union/union_vfsops.c                             |  10 +++---
 sys/fs/union/union_vnops.c                              |   6 +-
 sys/fs/unionfs/unionfs_vfsops.c                         |   8 ++--
 sys/fs/v7fs/v7fs_vfsops.c                               |  14 ++++----
 sys/fs/v7fs/v7fs_vnops.c                                |  19 +++++++----
 sys/kern/vfs_lookup.c                                   |   6 +-
 sys/kern/vfs_mount.c                                    |   8 ++--
 sys/kern/vfs_subr.c                                     |  12 +++---
 sys/kern/vfs_syscalls.c                                 |  10 +++---
 sys/miscfs/fdesc/fdesc.h                                |   4 +-
 sys/miscfs/fdesc/fdesc_vfsops.c                         |  10 +++---
 sys/miscfs/genfs/layer_extern.h                         |   8 ++--
 sys/miscfs/genfs/layer_vfsops.c                         |  21 ++++++------
 sys/miscfs/kernfs/kernfs.h                              |   4 +-
 sys/miscfs/kernfs/kernfs_vfsops.c                       |  10 +++---
 sys/miscfs/procfs/procfs.h                              |   4 +-
 sys/miscfs/procfs/procfs_vfsops.c                       |  10 +++---
 sys/nfs/nfs_export.c                                    |   6 +-
 sys/nfs/nfs_serv.c                                      |  10 +++--
 sys/nfs/nfs_srvsubs.c                                   |   6 +-
 sys/nfs/nfs_vfsops.c                                    |  13 ++++---
 sys/rump/librump/rumpvfs/rump_vfs.c                     |   8 ++--
 sys/rump/librump/rumpvfs/rumpfs.c                       |  10 +++---
 sys/sys/mount.h                                         |  20 ++++++------
 sys/ufs/chfs/chfs_vfsops.c                              |  20 ++++++------
 sys/ufs/chfs/chfs_vnode.c                               |   4 +-
 sys/ufs/chfs/chfs_vnops.c                               |  10 +++--
 sys/ufs/ext2fs/ext2fs_vfsops.c                          |   8 ++--
 sys/ufs/ffs/ffs_quota2.c                                |  10 +++--
 sys/ufs/ffs/ffs_snapshot.c                              |  10 +++---
 sys/ufs/ffs/ffs_vfsops.c                                |   8 ++--
 sys/ufs/ffs/ffs_wapbl.c                                 |  11 +++---
 sys/ufs/lfs/lfs_alloc.c                                 |   7 ++-
 sys/ufs/lfs/lfs_rfw.c                                   |   6 +-
 sys/ufs/lfs/lfs_vfsops.c                                |  14 ++++----
 sys/ufs/lfs/ulfs_extattr.c                              |   6 +-
 sys/ufs/lfs/ulfs_extern.h                               |   6 +-
 sys/ufs/lfs/ulfs_quota2.c                               |  10 +++--
 sys/ufs/lfs/ulfs_vfsops.c                               |  13 ++++---
 sys/ufs/ufs/ufs_extattr.c                               |   6 +-
 sys/ufs/ufs/ufs_extern.h                                |   8 ++--
 sys/ufs/ufs/ufs_vfsops.c                                |  16 +++++-----
 75 files changed, 411 insertions(+), 388 deletions(-)

diffs (truncated from 3297 to 300 lines):

diff -r fd51b490afcd -r 991bc10b4978 external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c   Fri Jan 17 19:56:49 2020 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c   Fri Jan 17 20:08:06 2020 +0000
@@ -1430,7 +1430,7 @@
 
        /* Return the mounted root rather than the covered mount point.  */
        ASSERT(vp->v_mountedhere);
-       error = VFS_ROOT(vp->v_mountedhere, vpp);
+       error = VFS_ROOT(vp->v_mountedhere, LK_EXCLUSIVE, vpp);
        vrele(vp);
        if (error)
                return error;
@@ -1949,7 +1949,7 @@
 
        zc = kmem_alloc(sizeof(*zc), KM_SLEEP);
 
-       VERIFY(0 == VFS_ROOT(zfsvfs->z_vfs, &vp));
+       VERIFY(0 == VFS_ROOT(zfsvfs->z_vfs, LK_EXCLUSIVE, &vp));
        VERIFY(0 == sa_lookup(VTOZ(vp)->z_sa_hdl, SA_ZPL_CRTIME(zfsvfs),
            &crtime, sizeof(crtime)));
        vput(vp);
diff -r fd51b490afcd -r 991bc10b4978 external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c   Fri Jan 17 19:56:49 2020 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c   Fri Jan 17 20:08:06 2020 +0000
@@ -135,11 +135,10 @@
 static int zfs_mount(vfs_t *vfsp, const char *path, void *data, size_t *data_len);
 static int zfs_umount(vfs_t *vfsp, int fflag);
 static int zfs_root(vfs_t *vfsp, int flags, vnode_t **vpp);
-static int zfs_netbsd_root(vfs_t *vfsp, vnode_t **vpp);
 static int zfs_statvfs(vfs_t *vfsp, struct statvfs *statp);
 static int zfs_netbsd_vptofh(vnode_t *vp, fid_t *fidp, size_t *fh_size);
-static int zfs_netbsd_fhtovp(vfs_t *vfsp, fid_t *fidp, vnode_t **vpp);
-static int zfs_vget(vfs_t *vfsp, ino_t ino, vnode_t **vpp);
+static int zfs_netbsd_fhtovp(vfs_t *vfsp, fid_t *fidp, int lktype, vnode_t **vpp);
+static int zfs_vget(vfs_t *vfsp, ino_t ino, int lktype, vnode_t **vpp);
 static int zfs_sync(vfs_t *vfsp, int waitfor);
 static int zfs_netbsd_sync(vfs_t *vfsp, int waitfor, cred_t *cr);
 static void zfs_freevfs(vfs_t *vfsp);
@@ -166,7 +165,7 @@
        .vfs_opv_descs = zfs_vnodeop_descs,
        .vfs_mount = zfs_mount,
        .vfs_unmount = zfs_umount,
-       .vfs_root = zfs_netbsd_root,
+       .vfs_root = zfs_root,
        .vfs_statvfs = zfs_statvfs,
        .vfs_sync = zfs_netbsd_sync,
        .vfs_vget = zfs_vget,
@@ -254,13 +253,6 @@
 }
 
 static int
-zfs_netbsd_root(vfs_t *vfsp, vnode_t **vpp)
-{
-
-       return zfs_root(vfsp, LK_EXCLUSIVE | LK_RETRY, vpp);
-}
-
-static int
 zfs_netbsd_vptofh(vnode_t *vp, fid_t *fidp, size_t *fh_size)
 {
        znode_t         *zp;
@@ -330,7 +322,7 @@
 }
 
 static int
-zfs_netbsd_fhtovp(vfs_t *vfsp, fid_t *fidp, vnode_t **vpp)
+zfs_netbsd_fhtovp(vfs_t *vfsp, fid_t *fidp, int lktype, vnode_t **vpp)
 {
        zfsvfs_t        *zfsvfs = vfsp->vfs_data;
        znode_t         *zp;
@@ -417,7 +409,7 @@
 
        *vpp = ZTOV(zp);
        ZFS_EXIT(zfsvfs);
-       err = vn_lock(*vpp, LK_EXCLUSIVE);
+       err = vn_lock(*vpp, lktype);
        if (err) {
                vrele(*vpp);
                *vpp = NULL;
@@ -2475,21 +2467,12 @@
        return (0);
 }
 
-#ifdef __FreeBSD_kernel__
 static int
 zfs_vget(vfs_t *vfsp, ino_t ino, int flags, vnode_t **vpp)
-#endif
-#ifdef __NetBSD__
-static int
-zfs_vget(vfs_t *vfsp, ino_t ino, vnode_t **vpp)
-#endif
 {
        zfsvfs_t        *zfsvfs = vfsp->vfs_data;
        znode_t         *zp;
        int             err;
-#ifdef __NetBSD__
-       int             flags = LK_EXCLUSIVE;
-#endif
 
        /*
         * zfs_zget() can't operate on virtual entries like .zfs/ or
diff -r fd51b490afcd -r 991bc10b4978 sys/coda/coda_vfsops.c
--- a/sys/coda/coda_vfsops.c    Fri Jan 17 19:56:49 2020 +0000
+++ b/sys/coda/coda_vfsops.c    Fri Jan 17 20:08:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: coda_vfsops.c,v 1.86 2017/04/04 07:36:38 hannken Exp $ */
+/*     $NetBSD: coda_vfsops.c,v 1.87 2020/01/17 20:08:06 ad Exp $      */
 
 /*
  *
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: coda_vfsops.c,v 1.86 2017/04/04 07:36:38 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coda_vfsops.c,v 1.87 2020/01/17 20:08:06 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -346,7 +346,7 @@
  * find root of cfs
  */
 int
-coda_root(struct mount *vfsp, struct vnode **vpp)
+coda_root(struct mount *vfsp, int lktype, struct vnode **vpp)
 {
     struct coda_mntinfo *mi = vftomi(vfsp);
     int error;
@@ -363,7 +363,7 @@
                *vpp = mi->mi_rootvp;
                /* On Mach, this is vref.  On NetBSD, VOP_LOCK */
                vref(*vpp);
-               vn_lock(*vpp, LK_EXCLUSIVE);
+               vn_lock(*vpp, lktype);
                MARK_INT_SAT(CODA_ROOT_STATS);
                return(0);
            }
@@ -475,7 +475,7 @@
 }
 
 int
-coda_vget(struct mount *vfsp, ino_t ino,
+coda_vget(struct mount *vfsp, ino_t ino, int lktype,
     struct vnode **vpp)
 {
     ENTRY;
@@ -515,7 +515,7 @@
 int
 coda_fhtovp(struct mount *vfsp, struct fid *fhp, struct mbuf *nam,
     struct vnode **vpp, int *exflagsp,
-    kauth_cred_t *creadanonp)
+    kauth_cred_t *creadanonp, int lktype)
 {
     struct cfid *cfid = (struct cfid *)fhp;
     struct cnode *cp = 0;
@@ -621,7 +621,7 @@
        return ENODEV;
 
     return coda_fhtovp(mi->mi_vfsp, (struct fid*)&cfid, NULL, vpp,
-                     NULL, NULL);
+                     NULL, NULL, LK_EXCLUSIVE);
 }
 
 /* Get the mount structure corresponding to a given device.
diff -r fd51b490afcd -r 991bc10b4978 sys/coda/coda_vfsops.h
--- a/sys/coda/coda_vfsops.h    Fri Jan 17 19:56:49 2020 +0000
+++ b/sys/coda/coda_vfsops.h    Fri Jan 17 20:08:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: coda_vfsops.h,v 1.20 2017/06/08 22:29:59 chs Exp $     */
+/*     $NetBSD: coda_vfsops.h,v 1.21 2020/01/17 20:08:06 ad Exp $      */
 
 /*
  *
@@ -50,14 +50,14 @@
 int coda_mount(struct mount *, const char *, void *, size_t *);
 int coda_start(struct mount *, int);
 int coda_unmount(struct mount *, int);
-int coda_root(struct mount *, struct vnode **);
+int coda_root(struct mount *, int, struct vnode **);
 int coda_nb_statvfs(struct mount *, struct statvfs *);
 int coda_sync(struct mount *, int, kauth_cred_t);
-int coda_vget(struct mount *, ino_t, struct vnode **);
+int coda_vget(struct mount *, ino_t, int, struct vnode **);
 int coda_loadvnode(struct mount *, struct vnode *, const void *, size_t,
     const void **);
 int coda_fhtovp(struct mount *, struct fid *, struct mbuf *, struct vnode **,
-                      int *, kauth_cred_t *);
+                      int *, kauth_cred_t *, int);
 int coda_vptofh(struct vnode *, struct fid *);
 void coda_init(void);
 void coda_done(void);
diff -r fd51b490afcd -r 991bc10b4978 sys/coda/coda_vnops.c
--- a/sys/coda/coda_vnops.c     Fri Jan 17 19:56:49 2020 +0000
+++ b/sys/coda/coda_vnops.c     Fri Jan 17 20:08:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: coda_vnops.c,v 1.107 2018/11/20 19:05:25 christos Exp $        */
+/*     $NetBSD: coda_vnops.c,v 1.108 2020/01/17 20:08:06 ad Exp $      */
 
 /*
  *
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: coda_vnops.c,v 1.107 2018/11/20 19:05:25 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coda_vnops.c,v 1.108 2020/01/17 20:08:06 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1757,7 +1757,7 @@
     /*
      * Obtain vnode from mount point and inode.
      */
-    error = VFS_VGET(mp, ino, vpp);
+    error = VFS_VGET(mp, ino, LK_EXCLUSIVE, vpp);
     if (error) {
        myprintf(("%s: iget/vget(0x%llx, %llu) returns %p, err %d\n", __func__,
            (unsigned long long)dev, (unsigned long long)ino, *vpp, error));
diff -r fd51b490afcd -r 991bc10b4978 sys/compat/common/vfs_syscalls_20.c
--- a/sys/compat/common/vfs_syscalls_20.c       Fri Jan 17 19:56:49 2020 +0000
+++ b/sys/compat/common/vfs_syscalls_20.c       Fri Jan 17 20:08:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls_20.c,v 1.44 2019/10/04 01:28:03 christos Exp $    */
+/*     $NetBSD: vfs_syscalls_20.c,v 1.45 2020/01/17 20:08:06 ad Exp $  */
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_20.c,v 1.44 2019/10/04 01:28:03 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_20.c,v 1.45 2020/01/17 20:08:06 ad Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -181,7 +181,8 @@
 
        if ((mp = vfs_getvfs(&fh.fh_fsid)) == NULL)
                return (ESTALE);
-       if ((error = VFS_FHTOVP(mp, (struct fid*)&fh.fh_fid, &vp)))
+       error = VFS_FHTOVP(mp, (struct fid*)&fh.fh_fid, LK_EXCLUSIVE, &vp);
+       if (error != 0)
                return (error);
        mp = vp->v_mount;
        VOP_UNLOCK(vp);
diff -r fd51b490afcd -r 991bc10b4978 sys/compat/common/vfs_syscalls_30.c
--- a/sys/compat/common/vfs_syscalls_30.c       Fri Jan 17 19:56:49 2020 +0000
+++ b/sys/compat/common/vfs_syscalls_30.c       Fri Jan 17 20:08:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls_30.c,v 1.39 2019/09/22 22:59:38 christos Exp $    */
+/*     $NetBSD: vfs_syscalls_30.c,v 1.40 2020/01/17 20:08:06 ad Exp $  */
 
 /*-
  * Copyright (c) 2005, 2008 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_30.c,v 1.39 2019/09/22 22:59:38 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_30.c,v 1.40 2020/01/17 20:08:06 ad Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -182,7 +182,8 @@
                return (ESTALE);
        if (mp->mnt_op->vfs_fhtovp == NULL)
                return EOPNOTSUPP;
-       if ((error = VFS_FHTOVP(mp, (struct fid*)&fh.fh_fid, &vp)))
+       error = VFS_FHTOVP(mp, (struct fid*)&fh.fh_fid, LK_EXCLUSIVE, &vp);
+       if (error != 0)
                return (error);
        error = vn_stat(vp, &sb);
        vput(vp);
diff -r fd51b490afcd -r 991bc10b4978 sys/compat/netbsd32/netbsd32_compat_30.c
--- a/sys/compat/netbsd32/netbsd32_compat_30.c  Fri Jan 17 19:56:49 2020 +0000
+++ b/sys/compat/netbsd32/netbsd32_compat_30.c  Fri Jan 17 20:08:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_compat_30.c,v 1.33 2019/01/27 02:08:40 pgoyette Exp $ */
+/*     $NetBSD: netbsd32_compat_30.c,v 1.34 2020/01/17 20:08:06 ad Exp $       */
 
 /*
  * Copyright (c) 1998, 2001 Matthew R. Green
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_30.c,v 1.33 2019/01/27 02:08:40 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_30.c,v 1.34 2020/01/17 20:08:06 ad Exp $");
 
 #if defined(_KERNEL_OPT)
 #include <opt_ntp.h>
@@ -192,7 +192,7 @@
                return (ESTALE);
        if (mp->mnt_op->vfs_fhtovp == NULL)
                return EOPNOTSUPP;
-       if ((error = VFS_FHTOVP(mp, (struct fid*)&fh.fh_fid, &vp)))
+       if ((error = VFS_FHTOVP(mp, (struct fid*)&fh.fh_fid, LK_EXCLUSIVE, &vp)))
                return (error);
        error = vn_stat(vp, &sb);



Home | Main Index | Thread Index | Old Index