Module Name: src Committed By: ad Date: Fri Jan 17 20:08:10 UTC 2020
Modified Files: src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_ctldir.c zfs_vfsops.c src/sys/coda: coda_vfsops.c coda_vfsops.h coda_vnops.c src/sys/compat/common: vfs_syscalls_20.c vfs_syscalls_30.c src/sys/compat/netbsd32: netbsd32_compat_30.c src/sys/fs/adosfs: adlookup.c advfsops.c advnops.c src/sys/fs/autofs: autofs_vfsops.c autofs_vnops.c src/sys/fs/cd9660: cd9660_vfsops.c src/sys/fs/efs: efs_vfsops.c src/sys/fs/filecorefs: filecore_vfsops.c src/sys/fs/hfs: hfs_vfsops.c src/sys/fs/msdosfs: msdosfs_vfsops.c src/sys/fs/nilfs: nilfs_vfsops.c src/sys/fs/ntfs: ntfs_subr.c ntfs_vfsops.c src/sys/fs/ptyfs: ptyfs.h ptyfs_vfsops.c src/sys/fs/puffs: puffs_vfsops.c src/sys/fs/smbfs: smbfs_vfsops.c src/sys/fs/sysvbfs: sysvbfs_vfsops.c sysvbfs_vnops.c src/sys/fs/tmpfs: tmpfs_vfsops.c src/sys/fs/udf: udf_rename.c udf_subr.c udf_subr.h udf_vfsops.c udf_vnops.c src/sys/fs/union: union_vfsops.c union_vnops.c src/sys/fs/unionfs: unionfs_vfsops.c src/sys/fs/v7fs: v7fs_vfsops.c v7fs_vnops.c src/sys/kern: vfs_lookup.c vfs_mount.c vfs_subr.c vfs_syscalls.c src/sys/miscfs/fdesc: fdesc.h fdesc_vfsops.c src/sys/miscfs/genfs: layer_extern.h layer_vfsops.c src/sys/miscfs/kernfs: kernfs.h kernfs_vfsops.c src/sys/miscfs/procfs: procfs.h procfs_vfsops.c src/sys/nfs: nfs_export.c nfs_serv.c nfs_srvsubs.c nfs_vfsops.c src/sys/rump/librump/rumpvfs: rump_vfs.c rumpfs.c src/sys/sys: mount.h src/sys/ufs/chfs: chfs_vfsops.c chfs_vnode.c chfs_vnops.c src/sys/ufs/ext2fs: ext2fs_vfsops.c src/sys/ufs/ffs: ffs_quota2.c ffs_snapshot.c ffs_vfsops.c ffs_wapbl.c src/sys/ufs/lfs: lfs_alloc.c lfs_rfw.c lfs_vfsops.c ulfs_extattr.c ulfs_extern.h ulfs_quota2.c ulfs_vfsops.c src/sys/ufs/ufs: ufs_extattr.c ufs_extern.h ufs_vfsops.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 \ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c cvs rdiff -u -r1.25 -r1.26 \ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c cvs rdiff -u -r1.86 -r1.87 src/sys/coda/coda_vfsops.c cvs rdiff -u -r1.20 -r1.21 src/sys/coda/coda_vfsops.h cvs rdiff -u -r1.107 -r1.108 src/sys/coda/coda_vnops.c cvs rdiff -u -r1.44 -r1.45 src/sys/compat/common/vfs_syscalls_20.c cvs rdiff -u -r1.39 -r1.40 src/sys/compat/common/vfs_syscalls_30.c cvs rdiff -u -r1.33 -r1.34 src/sys/compat/netbsd32/netbsd32_compat_30.c cvs rdiff -u -r1.20 -r1.21 src/sys/fs/adosfs/adlookup.c cvs rdiff -u -r1.77 -r1.78 src/sys/fs/adosfs/advfsops.c cvs rdiff -u -r1.50 -r1.51 src/sys/fs/adosfs/advnops.c cvs rdiff -u -r1.8 -r1.9 src/sys/fs/autofs/autofs_vfsops.c cvs rdiff -u -r1.4 -r1.5 src/sys/fs/autofs/autofs_vnops.c cvs rdiff -u -r1.93 -r1.94 src/sys/fs/cd9660/cd9660_vfsops.c cvs rdiff -u -r1.28 -r1.29 src/sys/fs/efs/efs_vfsops.c cvs rdiff -u -r1.81 -r1.82 src/sys/fs/filecorefs/filecore_vfsops.c cvs rdiff -u -r1.35 -r1.36 src/sys/fs/hfs/hfs_vfsops.c cvs rdiff -u -r1.130 -r1.131 src/sys/fs/msdosfs/msdosfs_vfsops.c cvs rdiff -u -r1.24 -r1.25 src/sys/fs/nilfs/nilfs_vfsops.c cvs rdiff -u -r1.62 -r1.63 src/sys/fs/ntfs/ntfs_subr.c cvs rdiff -u -r1.108 -r1.109 src/sys/fs/ntfs/ntfs_vfsops.c cvs rdiff -u -r1.14 -r1.15 src/sys/fs/ptyfs/ptyfs.h cvs rdiff -u -r1.56 -r1.57 src/sys/fs/ptyfs/ptyfs_vfsops.c cvs rdiff -u -r1.123 -r1.124 src/sys/fs/puffs/puffs_vfsops.c cvs rdiff -u -r1.106 -r1.107 src/sys/fs/smbfs/smbfs_vfsops.c cvs rdiff -u -r1.46 -r1.47 src/sys/fs/sysvbfs/sysvbfs_vfsops.c cvs rdiff -u -r1.63 -r1.64 src/sys/fs/sysvbfs/sysvbfs_vnops.c cvs rdiff -u -r1.75 -r1.76 src/sys/fs/tmpfs/tmpfs_vfsops.c cvs rdiff -u -r1.12 -r1.13 src/sys/fs/udf/udf_rename.c cvs rdiff -u -r1.147 -r1.148 src/sys/fs/udf/udf_subr.c cvs rdiff -u -r1.20 -r1.21 src/sys/fs/udf/udf_subr.h cvs rdiff -u -r1.76 -r1.77 src/sys/fs/udf/udf_vfsops.c cvs rdiff -u -r1.107 -r1.108 src/sys/fs/udf/udf_vnops.c cvs rdiff -u -r1.79 -r1.80 src/sys/fs/union/union_vfsops.c cvs rdiff -u -r1.70 -r1.71 src/sys/fs/union/union_vnops.c cvs rdiff -u -r1.13 -r1.14 src/sys/fs/unionfs/unionfs_vfsops.c cvs rdiff -u -r1.16 -r1.17 src/sys/fs/v7fs/v7fs_vfsops.c cvs rdiff -u -r1.26 -r1.27 src/sys/fs/v7fs/v7fs_vnops.c cvs rdiff -u -r1.212 -r1.213 src/sys/kern/vfs_lookup.c cvs rdiff -u -r1.73 -r1.74 src/sys/kern/vfs_mount.c cvs rdiff -u -r1.478 -r1.479 src/sys/kern/vfs_subr.c cvs rdiff -u -r1.539 -r1.540 src/sys/kern/vfs_syscalls.c cvs rdiff -u -r1.22 -r1.23 src/sys/miscfs/fdesc/fdesc.h cvs rdiff -u -r1.92 -r1.93 src/sys/miscfs/fdesc/fdesc_vfsops.c cvs rdiff -u -r1.40 -r1.41 src/sys/miscfs/genfs/layer_extern.h cvs rdiff -u -r1.52 -r1.53 src/sys/miscfs/genfs/layer_vfsops.c cvs rdiff -u -r1.41 -r1.42 src/sys/miscfs/kernfs/kernfs.h cvs rdiff -u -r1.96 -r1.97 src/sys/miscfs/kernfs/kernfs_vfsops.c cvs rdiff -u -r1.77 -r1.78 src/sys/miscfs/procfs/procfs.h cvs rdiff -u -r1.101 -r1.102 src/sys/miscfs/procfs/procfs_vfsops.c cvs rdiff -u -r1.61 -r1.62 src/sys/nfs/nfs_export.c cvs rdiff -u -r1.178 -r1.179 src/sys/nfs/nfs_serv.c cvs rdiff -u -r1.14 -r1.15 src/sys/nfs/nfs_srvsubs.c cvs rdiff -u -r1.237 -r1.238 src/sys/nfs/nfs_vfsops.c cvs rdiff -u -r1.88 -r1.89 src/sys/rump/librump/rumpvfs/rump_vfs.c cvs rdiff -u -r1.153 -r1.154 src/sys/rump/librump/rumpvfs/rumpfs.c cvs rdiff -u -r1.235 -r1.236 src/sys/sys/mount.h cvs rdiff -u -r1.20 -r1.21 src/sys/ufs/chfs/chfs_vfsops.c cvs rdiff -u -r1.17 -r1.18 src/sys/ufs/chfs/chfs_vnode.c cvs rdiff -u -r1.34 -r1.35 src/sys/ufs/chfs/chfs_vnops.c cvs rdiff -u -r1.214 -r1.215 src/sys/ufs/ext2fs/ext2fs_vfsops.c cvs rdiff -u -r1.6 -r1.7 src/sys/ufs/ffs/ffs_quota2.c cvs rdiff -u -r1.149 -r1.150 src/sys/ufs/ffs/ffs_snapshot.c cvs rdiff -u -r1.362 -r1.363 src/sys/ufs/ffs/ffs_vfsops.c cvs rdiff -u -r1.44 -r1.45 src/sys/ufs/ffs/ffs_wapbl.c cvs rdiff -u -r1.137 -r1.138 src/sys/ufs/lfs/lfs_alloc.c cvs rdiff -u -r1.34 -r1.35 src/sys/ufs/lfs/lfs_rfw.c cvs rdiff -u -r1.368 -r1.369 src/sys/ufs/lfs/lfs_vfsops.c cvs rdiff -u -r1.14 -r1.15 src/sys/ufs/lfs/ulfs_extattr.c cvs rdiff -u -r1.24 -r1.25 src/sys/ufs/lfs/ulfs_extern.h cvs rdiff -u -r1.31 -r1.32 src/sys/ufs/lfs/ulfs_quota2.c cvs rdiff -u -r1.15 -r1.16 src/sys/ufs/lfs/ulfs_vfsops.c cvs rdiff -u -r1.50 -r1.51 src/sys/ufs/ufs/ufs_extattr.c cvs rdiff -u -r1.83 -r1.84 src/sys/ufs/ufs/ufs_extern.h cvs rdiff -u -r1.58 -r1.59 src/sys/ufs/ufs/ufs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c:1.10 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c:1.11 --- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c:1.10 Sun Dec 22 19:47:34 2019 +++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_ctldir.c Fri Jan 17 20:08:06 2020 @@ -1430,7 +1430,7 @@ sfs_lookup_snapshot(vnode_t *dvp, struct /* 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 @@ zfsctl_create(zfsvfs_t *zfsvfs) 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); Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c:1.25 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c:1.26 --- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c:1.25 Wed Aug 7 20:45:53 2019 +++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c Fri Jan 17 20:08:06 2020 @@ -135,11 +135,10 @@ kmutex_t zfs_debug_mtx; 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 @@ struct vfsops zfs_vfsops = { .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 @@ zfs_netbsd_sync(vfs_t *vfsp, int waitfor } 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 @@ zfs_netbsd_vptofh(vnode_t *vp, fid_t *fi } 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 @@ zfs_netbsd_fhtovp(vfs_t *vfsp, fid_t *fi *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 @@ zfs_umount(vfs_t *vfsp, int fflag) 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 Index: src/sys/coda/coda_vfsops.c diff -u src/sys/coda/coda_vfsops.c:1.86 src/sys/coda/coda_vfsops.c:1.87 --- src/sys/coda/coda_vfsops.c:1.86 Tue Apr 4 07:36:38 2017 +++ src/sys/coda/coda_vfsops.c Fri Jan 17 20:08:06 2020 @@ -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 @@ coda_unmount(struct mount *vfsp, int mnt * 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 @@ coda_root(struct mount *vfsp, struct vno *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 @@ coda_sync(struct mount *vfsp, int waitfo } 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 @@ coda_loadvnode(struct mount *mp, struct 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 @@ getNewVnode(struct vnode **vpp) 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. Index: src/sys/coda/coda_vfsops.h diff -u src/sys/coda/coda_vfsops.h:1.20 src/sys/coda/coda_vfsops.h:1.21 --- src/sys/coda/coda_vfsops.h:1.20 Thu Jun 8 22:29:59 2017 +++ src/sys/coda/coda_vfsops.h Fri Jan 17 20:08:06 2020 @@ -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_vfsopstats_init(void); 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); Index: src/sys/coda/coda_vnops.c diff -u src/sys/coda/coda_vnops.c:1.107 src/sys/coda/coda_vnops.c:1.108 --- src/sys/coda/coda_vnops.c:1.107 Tue Nov 20 19:05:25 2018 +++ src/sys/coda/coda_vnops.c Fri Jan 17 20:08:06 2020 @@ -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 @@ coda_grab_vnode(vnode_t *uvp, dev_t dev, /* * 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)); Index: src/sys/compat/common/vfs_syscalls_20.c diff -u src/sys/compat/common/vfs_syscalls_20.c:1.44 src/sys/compat/common/vfs_syscalls_20.c:1.45 --- src/sys/compat/common/vfs_syscalls_20.c:1.44 Fri Oct 4 01:28:03 2019 +++ src/sys/compat/common/vfs_syscalls_20.c Fri Jan 17 20:08:06 2020 @@ -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 @@ compat_20_sys_fhstatfs(struct lwp *l, co 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); Index: src/sys/compat/common/vfs_syscalls_30.c diff -u src/sys/compat/common/vfs_syscalls_30.c:1.39 src/sys/compat/common/vfs_syscalls_30.c:1.40 --- src/sys/compat/common/vfs_syscalls_30.c:1.39 Sun Sep 22 22:59:38 2019 +++ src/sys/compat/common/vfs_syscalls_30.c Fri Jan 17 20:08:06 2020 @@ -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 @@ compat_30_sys_fhstat(struct lwp *l, 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); Index: src/sys/compat/netbsd32/netbsd32_compat_30.c diff -u src/sys/compat/netbsd32/netbsd32_compat_30.c:1.33 src/sys/compat/netbsd32/netbsd32_compat_30.c:1.34 --- src/sys/compat/netbsd32/netbsd32_compat_30.c:1.33 Sun Jan 27 02:08:40 2019 +++ src/sys/compat/netbsd32/netbsd32_compat_30.c Fri Jan 17 20:08:06 2020 @@ -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 @@ compat_30_netbsd32_fhstat(struct lwp *l, 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); vput(vp); Index: src/sys/fs/adosfs/adlookup.c diff -u src/sys/fs/adosfs/adlookup.c:1.20 src/sys/fs/adosfs/adlookup.c:1.21 --- src/sys/fs/adosfs/adlookup.c:1.20 Mon Sep 3 16:29:34 2018 +++ src/sys/fs/adosfs/adlookup.c Fri Jan 17 20:08:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: adlookup.c,v 1.20 2018/09/03 16:29:34 riastradh Exp $ */ +/* $NetBSD: adlookup.c,v 1.21 2020/01/17 20:08:07 ad Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: adlookup.c,v 1.20 2018/09/03 16:29:34 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: adlookup.c,v 1.21 2020/01/17 20:08:07 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -145,7 +145,8 @@ adosfs_lookup(void *v) * */ VOP_UNLOCK(vdp); /* race */ - error = VFS_VGET(vdp->v_mount, (ino_t)adp->pblock, vpp); + error = VFS_VGET(vdp->v_mount, (ino_t)adp->pblock, + LK_EXCLUSIVE, vpp); vn_lock(vdp, LK_EXCLUSIVE | LK_RETRY); if (error) { *vpp = NULL; @@ -163,8 +164,8 @@ adosfs_lookup(void *v) bn = adp->tab[hval]; i = uimin(adp->tabi[hval], 0); while (bn != 0) { - if ((error = VFS_VGET(vdp->v_mount, (ino_t)bn, vpp - )) != 0) { + if ((error = VFS_VGET(vdp->v_mount, (ino_t)bn, + LK_EXCLUSIVE, vpp)) != 0) { #ifdef ADOSFS_DIAGNOSTIC printf("[aget] %d)", error); #endif Index: src/sys/fs/adosfs/advfsops.c diff -u src/sys/fs/adosfs/advfsops.c:1.77 src/sys/fs/adosfs/advfsops.c:1.78 --- src/sys/fs/adosfs/advfsops.c:1.77 Thu Jun 1 02:45:12 2017 +++ src/sys/fs/adosfs/advfsops.c Fri Jan 17 20:08:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: advfsops.c,v 1.77 2017/06/01 02:45:12 chs Exp $ */ +/* $NetBSD: advfsops.c,v 1.78 2020/01/17 20:08:07 ad Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: advfsops.c,v 1.77 2017/06/01 02:45:12 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: advfsops.c,v 1.78 2020/01/17 20:08:07 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -264,7 +264,7 @@ adosfs_mountfs(struct vnode *devvp, stru /* * get the root anode, if not a valid fs this will fail. */ - if ((error = VFS_ROOT(mp, &rvp)) != 0) + if ((error = VFS_ROOT(mp, LK_EXCLUSIVE, &rvp)) != 0) goto fail; /* allocate and load bitmap, set free space */ bitmap_sz = ((amp->numblks + 31) / 32) * sizeof(*amp->bitmap); @@ -328,12 +328,13 @@ adosfs_unmount(struct mount *mp, int mnt } int -adosfs_root(struct mount *mp, struct vnode **vpp) +adosfs_root(struct mount *mp, int lktype, struct vnode **vpp) { struct vnode *nvp; int error; - if ((error = VFS_VGET(mp, (ino_t)VFSTOADOSFS(mp)->rootb, &nvp)) != 0) + error = VFS_VGET(mp, (ino_t)VFSTOADOSFS(mp)->rootb, lktype, &nvp); + if (error != 0) return (error); /* XXX verify it's a root block? */ *vpp = nvp; @@ -366,7 +367,7 @@ adosfs_statvfs(struct mount *mp, struct * return locked and referenced */ int -adosfs_vget(struct mount *mp, ino_t an, struct vnode **vpp) +adosfs_vget(struct mount *mp, ino_t an, int lktype, struct vnode **vpp) { u_long block; int error; @@ -376,7 +377,7 @@ adosfs_vget(struct mount *mp, ino_t an, error = vcache_get(mp, &block, sizeof(block), vpp); if (error) return error; - error = vn_lock(*vpp, LK_EXCLUSIVE); + error = vn_lock(*vpp, lktype); if (error) { vrele(*vpp); *vpp = NULL; @@ -690,7 +691,8 @@ struct ifid { }; int -adosfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) +adosfs_fhtovp(struct mount *mp, struct fid *fhp, int lktype, + struct vnode **vpp) { struct ifid ifh; #if 0 @@ -708,7 +710,7 @@ adosfs_fhtovp(struct mount *mp, struct f memcpy(&ifh, fhp, sizeof(ifh)); - if ((error = VFS_VGET(mp, ifh.ifid_ino, &nvp)) != 0) { + if ((error = VFS_VGET(mp, ifh.ifid_ino, lktype, &nvp)) != 0) { *vpp = NULLVP; return (error); } Index: src/sys/fs/adosfs/advnops.c diff -u src/sys/fs/adosfs/advnops.c:1.50 src/sys/fs/adosfs/advnops.c:1.51 --- src/sys/fs/adosfs/advnops.c:1.50 Fri May 26 14:21:00 2017 +++ src/sys/fs/adosfs/advnops.c Fri Jan 17 20:08:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: advnops.c,v 1.50 2017/05/26 14:21:00 riastradh Exp $ */ +/* $NetBSD: advnops.c,v 1.51 2020/01/17 20:08:07 ad Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: advnops.c,v 1.50 2017/05/26 14:21:00 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: advnops.c,v 1.51 2020/01/17 20:08:07 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -657,7 +657,8 @@ adosfs_readdir(void *v) */ ap = NULL; do { - error = VFS_VGET(pap->amp->mp, (ino_t)nextbn, &vp); + error = VFS_VGET(pap->amp->mp, (ino_t)nextbn, + LK_EXCLUSIVE, &vp); if (error) goto reterr; ap = VTOA(vp); Index: src/sys/fs/autofs/autofs_vfsops.c diff -u src/sys/fs/autofs/autofs_vfsops.c:1.8 src/sys/fs/autofs/autofs_vfsops.c:1.9 --- src/sys/fs/autofs/autofs_vfsops.c:1.8 Tue Nov 26 16:17:31 2019 +++ src/sys/fs/autofs/autofs_vfsops.c Fri Jan 17 20:08:07 2020 @@ -33,7 +33,7 @@ * */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: autofs_vfsops.c,v 1.8 2019/11/26 16:17:31 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autofs_vfsops.c,v 1.9 2020/01/17 20:08:07 ad Exp $"); #include "autofs.h" @@ -262,7 +262,7 @@ autofs_start(struct mount *mp, int flags } static int -autofs_root(struct mount *mp, struct vnode **vpp) +autofs_root(struct mount *mp, int lktype, struct vnode **vpp) { struct autofs_node *anp = VFSTOAUTOFS(mp)->am_root; int error; @@ -270,7 +270,7 @@ autofs_root(struct mount *mp, struct vno error = vcache_get(mp, &anp, sizeof(anp), vpp); if (error) return error; - error = vn_lock(*vpp, LK_EXCLUSIVE); + error = vn_lock(*vpp, lktype); if (error) { vrele(*vpp); *vpp = NULLVP; Index: src/sys/fs/autofs/autofs_vnops.c diff -u src/sys/fs/autofs/autofs_vnops.c:1.4 src/sys/fs/autofs/autofs_vnops.c:1.5 --- src/sys/fs/autofs/autofs_vnops.c:1.4 Tue Nov 26 16:17:31 2019 +++ src/sys/fs/autofs/autofs_vnops.c Fri Jan 17 20:08:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: autofs_vnops.c,v 1.4 2019/11/26 16:17:31 tkusumi Exp $ */ +/* $NetBSD: autofs_vnops.c,v 1.5 2020/01/17 20:08:07 ad Exp $ */ /*- * Copyright (c) 2017 The NetBSD Foundation, Inc. * Copyright (c) 2016 The DragonFly Project @@ -34,7 +34,7 @@ * */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: autofs_vnops.c,v 1.4 2019/11/26 16:17:31 tkusumi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autofs_vnops.c,v 1.5 2020/01/17 20:08:07 ad Exp $"); #include "autofs.h" @@ -183,7 +183,7 @@ mounted: autofs_node_uncache(anp); } - error = VFS_ROOT(vp->v_mountedhere, newvp); + error = VFS_ROOT(vp->v_mountedhere, LK_EXCLUSIVE, newvp); if (error) { AUTOFS_WARN("VFS_ROOT() failed with error %d", error); return error; Index: src/sys/fs/cd9660/cd9660_vfsops.c diff -u src/sys/fs/cd9660/cd9660_vfsops.c:1.93 src/sys/fs/cd9660/cd9660_vfsops.c:1.94 --- src/sys/fs/cd9660/cd9660_vfsops.c:1.93 Mon Apr 17 08:32:00 2017 +++ src/sys/fs/cd9660/cd9660_vfsops.c Fri Jan 17 20:08:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cd9660_vfsops.c,v 1.93 2017/04/17 08:32:00 hannken Exp $ */ +/* $NetBSD: cd9660_vfsops.c,v 1.94 2020/01/17 20:08:07 ad Exp $ */ /*- * Copyright (c) 1994 @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.93 2017/04/17 08:32:00 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.94 2020/01/17 20:08:07 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -578,14 +578,14 @@ cd9660_unmount(struct mount *mp, int mnt * Return root of a filesystem */ int -cd9660_root(struct mount *mp, struct vnode **vpp) +cd9660_root(struct mount *mp, int lktype, struct vnode **vpp) { struct iso_mnt *imp = VFSTOISOFS(mp); struct iso_directory_record *dp = (struct iso_directory_record *)imp->root; ino_t ino = isodirino(dp, imp); - return cd9660_vget(mp, ino, vpp); + return cd9660_vget(mp, ino, lktype, vpp); } /* @@ -643,7 +643,7 @@ struct ifid { /* ARGSUSED */ int -cd9660_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) +cd9660_fhtovp(struct mount *mp, struct fid *fhp, int lktype, struct vnode **vpp) { struct ifid ifh; struct iso_node *ip; @@ -659,7 +659,7 @@ cd9660_fhtovp(struct mount *mp, struct f ifh.ifid_ino, ifh.ifid_start); #endif - if ((error = VFS_VGET(mp, ifh.ifid_ino, &nvp)) != 0) { + if ((error = VFS_VGET(mp, ifh.ifid_ino, lktype, &nvp)) != 0) { *vpp = NULLVP; return (error); } @@ -674,14 +674,14 @@ cd9660_fhtovp(struct mount *mp, struct f } int -cd9660_vget(struct mount *mp, ino_t ino, struct vnode **vpp) +cd9660_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { int error; error = vcache_get(mp, &ino, sizeof(ino), vpp); if (error) return error; - error = vn_lock(*vpp, LK_EXCLUSIVE); + error = vn_lock(*vpp, lktype); if (error) { vrele(*vpp); *vpp = NULL; Index: src/sys/fs/efs/efs_vfsops.c diff -u src/sys/fs/efs/efs_vfsops.c:1.28 src/sys/fs/efs/efs_vfsops.c:1.29 --- src/sys/fs/efs/efs_vfsops.c:1.28 Fri Feb 17 08:31:24 2017 +++ src/sys/fs/efs/efs_vfsops.c Fri Jan 17 20:08:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: efs_vfsops.c,v 1.28 2017/02/17 08:31:24 hannken Exp $ */ +/* $NetBSD: efs_vfsops.c,v 1.29 2020/01/17 20:08:07 ad Exp $ */ /* * Copyright (c) 2006 Stephen M. Rumble <rum...@ephemeral.org> @@ -17,7 +17,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: efs_vfsops.c,v 1.28 2017/02/17 08:31:24 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: efs_vfsops.c,v 1.29 2020/01/17 20:08:07 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -295,12 +295,12 @@ efs_unmount(struct mount *mp, int mntfla * Returns 0 on success. */ static int -efs_root(struct mount *mp, struct vnode **vpp) +efs_root(struct mount *mp, int lktype, struct vnode **vpp) { int err; struct vnode *vp; - if ((err = VFS_VGET(mp, EFS_ROOTINO, &vp))) + if ((err = VFS_VGET(mp, EFS_ROOTINO, lktype, &vp))) return (err); *vpp = vp; @@ -343,14 +343,14 @@ efs_statvfs(struct mount *mp, struct sta * Returns 0 on success. */ static int -efs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) +efs_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { int error; error = vcache_get(mp, &ino, sizeof(ino), vpp); if (error) return error; - error = vn_lock(*vpp, LK_EXCLUSIVE); + error = vn_lock(*vpp, lktype); if (error) { vrele(*vpp); *vpp = NULL; @@ -453,7 +453,7 @@ efs_loadvnode(struct mount *mp, struct v * Returns 0 on success. */ static int -efs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) +efs_fhtovp(struct mount *mp, struct fid *fhp, int lktype, struct vnode **vpp) { int err; struct vnode *vp; @@ -465,7 +465,7 @@ efs_fhtovp(struct mount *mp, struct fid efp = (struct efs_fid *)fhp; - if ((err = VFS_VGET(mp, efp->ef_ino, &vp))) { + if ((err = VFS_VGET(mp, efp->ef_ino, lktype, &vp))) { *vpp = NULL; return (err); } Index: src/sys/fs/filecorefs/filecore_vfsops.c diff -u src/sys/fs/filecorefs/filecore_vfsops.c:1.81 src/sys/fs/filecorefs/filecore_vfsops.c:1.82 --- src/sys/fs/filecorefs/filecore_vfsops.c:1.81 Mon Apr 17 08:32:00 2017 +++ src/sys/fs/filecorefs/filecore_vfsops.c Fri Jan 17 20:08:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: filecore_vfsops.c,v 1.81 2017/04/17 08:32:00 hannken Exp $ */ +/* $NetBSD: filecore_vfsops.c,v 1.82 2020/01/17 20:08:07 ad Exp $ */ /*- * Copyright (c) 1994 The Regents of the University of California. @@ -66,7 +66,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: filecore_vfsops.c,v 1.81 2017/04/17 08:32:00 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: filecore_vfsops.c,v 1.82 2020/01/17 20:08:07 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -460,12 +460,12 @@ filecore_unmount(struct mount *mp, int m * Return root of a filesystem */ int -filecore_root(struct mount *mp, struct vnode **vpp) +filecore_root(struct mount *mp, int lktype, struct vnode **vpp) { struct vnode *nvp; int error; - if ((error = VFS_VGET(mp, FILECORE_ROOTINO, &nvp)) != 0) + if ((error = VFS_VGET(mp, FILECORE_ROOTINO, lktype, &nvp)) != 0) return (error); *vpp = nvp; return (0); @@ -519,7 +519,8 @@ struct ifid { /* ARGSUSED */ int -filecore_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) +filecore_fhtovp(struct mount *mp, struct fid *fhp, int lktype, + struct vnode **vpp) { struct ifid ifh; struct vnode *nvp; @@ -530,7 +531,7 @@ filecore_fhtovp(struct mount *mp, struct return EINVAL; memcpy(&ifh, fhp, sizeof(ifh)); - if ((error = VFS_VGET(mp, ifh.ifid_ino, &nvp)) != 0) { + if ((error = VFS_VGET(mp, ifh.ifid_ino, lktype, &nvp)) != 0) { *vpp = NULLVP; return (error); } @@ -553,14 +554,14 @@ filecore_fhtovp(struct mount *mp, struct */ int -filecore_vget(struct mount *mp, ino_t ino, struct vnode **vpp) +filecore_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { int error; error = vcache_get(mp, &ino, sizeof(ino), vpp); if (error) return error; - error = vn_lock(*vpp, LK_EXCLUSIVE); + error = vn_lock(*vpp, lktype); if (error) { vrele(*vpp); *vpp = NULL; Index: src/sys/fs/hfs/hfs_vfsops.c diff -u src/sys/fs/hfs/hfs_vfsops.c:1.35 src/sys/fs/hfs/hfs_vfsops.c:1.36 --- src/sys/fs/hfs/hfs_vfsops.c:1.35 Mon Dec 10 14:46:24 2018 +++ src/sys/fs/hfs/hfs_vfsops.c Fri Jan 17 20:08:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hfs_vfsops.c,v 1.35 2018/12/10 14:46:24 maxv Exp $ */ +/* $NetBSD: hfs_vfsops.c,v 1.36 2020/01/17 20:08:07 ad Exp $ */ /*- * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc. @@ -99,7 +99,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hfs_vfsops.c,v 1.35 2018/12/10 14:46:24 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hfs_vfsops.c,v 1.36 2020/01/17 20:08:07 ad Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -439,7 +439,7 @@ hfs_unmount(struct mount *mp, int mntfla } int -hfs_root(struct mount *mp, struct vnode **vpp) +hfs_root(struct mount *mp, int lktype, struct vnode **vpp) { struct vnode *nvp; int error; @@ -448,7 +448,7 @@ hfs_root(struct mount *mp, struct vnode printf("vfsop = hfs_root()\n"); #endif /* HFS_DEBUG */ - if ((error = VFS_VGET(mp, HFS_CNID_ROOT_FOLDER, &nvp)) != 0) + if ((error = VFS_VGET(mp, HFS_CNID_ROOT_FOLDER, lktype, &nvp)) != 0) return error; *vpp = nvp; @@ -495,14 +495,14 @@ hfs_sync(struct mount *mp, int waitfor, * since both are conveniently 32-bit numbers */ int -hfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) +hfs_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { int error; error = hfs_vget_internal(mp, ino, HFS_DATAFORK, vpp); if (error) return error; - error = vn_lock(*vpp, LK_EXCLUSIVE); + error = vn_lock(*vpp, lktype); if (error) { vrele(*vpp); *vpp = NULL; @@ -612,7 +612,7 @@ hfs_loadvnode(struct mount *mp, struct v } int -hfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) +hfs_fhtovp(struct mount *mp, struct fid *fhp, int lktype, struct vnode **vpp) { #ifdef HFS_DEBUG Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.130 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.131 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.130 Mon Sep 3 16:29:34 2018 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Fri Jan 17 20:08:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.130 2018/09/03 16:29:34 riastradh Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.131 2020/01/17 20:08:07 ad Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.130 2018/09/03 16:29:34 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.131 2020/01/17 20:08:07 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -209,7 +209,8 @@ update_mp(struct mount *mp, struct msdos if (FAT32(pmp)) pmp->pm_flags |= MSDOSFSMNT_LONGNAME; else { - if ((error = msdosfs_root(mp, &rtvp)) != 0) + error = msdosfs_root(mp, LK_EXCLUSIVE, &rtvp); + if (error != 0) return error; pmp->pm_flags |= findwin95(VTODE(rtvp)) ? MSDOSFSMNT_LONGNAME @@ -950,7 +951,7 @@ msdosfs_unmount(struct mount *mp, int mn } int -msdosfs_root(struct mount *mp, struct vnode **vpp) +msdosfs_root(struct mount *mp, int lktype, struct vnode **vpp) { struct msdosfsmount *pmp = VFSTOMSDOSFS(mp); int error; @@ -960,7 +961,7 @@ msdosfs_root(struct mount *mp, struct vn #endif if ((error = deget(pmp, MSDOSFSROOT, MSDOSFSROOT_OFS, vpp)) != 0) return error; - error = vn_lock(*vpp, LK_EXCLUSIVE); + error = vn_lock(*vpp, lktype); if (error) { vrele(*vpp); *vpp = NULL; @@ -1064,7 +1065,7 @@ msdosfs_sync(struct mount *mp, int waitf } int -msdosfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) +msdosfs_fhtovp(struct mount *mp, struct fid *fhp, int lktype, struct vnode **vpp) { struct msdosfsmount *pmp = VFSTOMSDOSFS(mp); struct defid defh; @@ -1090,7 +1091,7 @@ msdosfs_fhtovp(struct mount *mp, struct *vpp = NULLVP; return error; } - error = vn_lock(*vpp, LK_EXCLUSIVE); + error = vn_lock(*vpp, lktype); if (error) { vrele(*vpp); *vpp = NULLVP; @@ -1125,7 +1126,7 @@ msdosfs_vptofh(struct vnode *vp, struct } int -msdosfs_vget(struct mount *mp, ino_t ino, +msdosfs_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { Index: src/sys/fs/nilfs/nilfs_vfsops.c diff -u src/sys/fs/nilfs/nilfs_vfsops.c:1.24 src/sys/fs/nilfs/nilfs_vfsops.c:1.25 --- src/sys/fs/nilfs/nilfs_vfsops.c:1.24 Mon May 28 21:04:37 2018 +++ src/sys/fs/nilfs/nilfs_vfsops.c Fri Jan 17 20:08:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nilfs_vfsops.c,v 1.24 2018/05/28 21:04:37 chs Exp $ */ +/* $NetBSD: nilfs_vfsops.c,v 1.25 2020/01/17 20:08:07 ad Exp $ */ /* * Copyright (c) 2008, 2009 Reinoud Zandijk @@ -28,7 +28,7 @@ #include <sys/cdefs.h> #ifndef lint -__KERNEL_RCSID(0, "$NetBSD: nilfs_vfsops.c,v 1.24 2018/05/28 21:04:37 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nilfs_vfsops.c,v 1.25 2020/01/17 20:08:07 ad Exp $"); #endif /* not lint */ @@ -1023,7 +1023,7 @@ nilfs_start(struct mount *mp, int flags) /* --------------------------------------------------------------------- */ int -nilfs_root(struct mount *mp, struct vnode **vpp) +nilfs_root(struct mount *mp, int lktype, struct vnode **vpp) { uint64_t ino = NILFS_ROOT_INO; int error; @@ -1032,7 +1032,7 @@ nilfs_root(struct mount *mp, struct vnod error = vcache_get(mp, &ino, sizeof(ino), vpp); if (error == 0) { - error = vn_lock(*vpp, LK_EXCLUSIVE); + error = vn_lock(*vpp, lktype); if (error) { vrele(*vpp); *vpp = NULL; @@ -1090,7 +1090,7 @@ nilfs_sync(struct mount *mp, int waitfor * (optional) TODO lookup why some sources state NFSv3 */ int -nilfs_vget(struct mount *mp, ino_t ino, +nilfs_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { DPRINTF(NOTIMPL, ("nilfs_vget called\n")); @@ -1189,7 +1189,7 @@ nilfs_loadvnode(struct mount *mp, struct * Lookup vnode for file handle specified */ int -nilfs_fhtovp(struct mount *mp, struct fid *fhp, +nilfs_fhtovp(struct mount *mp, struct fid *fhp, int lktype, struct vnode **vpp) { DPRINTF(NOTIMPL, ("nilfs_fhtovp called\n")); Index: src/sys/fs/ntfs/ntfs_subr.c diff -u src/sys/fs/ntfs/ntfs_subr.c:1.62 src/sys/fs/ntfs/ntfs_subr.c:1.63 --- src/sys/fs/ntfs/ntfs_subr.c:1.62 Fri Oct 18 08:19:33 2019 +++ src/sys/fs/ntfs/ntfs_subr.c Fri Jan 17 20:08:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ntfs_subr.c,v 1.62 2019/10/18 08:19:33 hannken Exp $ */ +/* $NetBSD: ntfs_subr.c,v 1.63 2020/01/17 20:08:08 ad Exp $ */ /*- * Copyright (c) 1998, 1999 Semen Ustimenko (sem...@freebsd.org) @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.62 2019/10/18 08:19:33 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ntfs_subr.c,v 1.63 2020/01/17 20:08:08 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -1772,7 +1772,7 @@ ntfs_toupper_use(struct mount *mp, struc ntfs_toupper_tab = malloc(256 * 256 * sizeof(*ntfs_toupper_tab), M_NTFSRDATA, M_WAITOK); - if ((error = VFS_VGET(mp, NTFS_UPCASEINO, &vp))) + if ((error = VFS_VGET(mp, NTFS_UPCASEINO, LK_EXCLUSIVE, &vp))) goto out; error = ntfs_readattr(ntmp, VTONT(vp), NTFS_A_DATA, NULL, 0, 256 * 256 * sizeof(*ntfs_toupper_tab), (char *)ntfs_toupper_tab, Index: src/sys/fs/ntfs/ntfs_vfsops.c diff -u src/sys/fs/ntfs/ntfs_vfsops.c:1.108 src/sys/fs/ntfs/ntfs_vfsops.c:1.109 --- src/sys/fs/ntfs/ntfs_vfsops.c:1.108 Fri Oct 18 08:18:40 2019 +++ src/sys/fs/ntfs/ntfs_vfsops.c Fri Jan 17 20:08:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ntfs_vfsops.c,v 1.108 2019/10/18 08:18:40 hannken Exp $ */ +/* $NetBSD: ntfs_vfsops.c,v 1.109 2020/01/17 20:08:08 ad Exp $ */ /*- * Copyright (c) 1998, 1999 Semen Ustimenko @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.108 2019/10/18 08:18:40 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.109 2020/01/17 20:08:08 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -67,12 +67,12 @@ MALLOC_JUSTDEFINE(M_NTFSDIR,"NTFS dir", static int ntfs_superblock_validate(struct ntfsmount *); static int ntfs_mount(struct mount *, const char *, void *, size_t *); -static int ntfs_root(struct mount *, struct vnode **); +static int ntfs_root(struct mount *, int, struct vnode **); static int ntfs_start(struct mount *, int); static int ntfs_statvfs(struct mount *, struct statvfs *); static int ntfs_sync(struct mount *, int, kauth_cred_t); static int ntfs_unmount(struct mount *, int); -static int ntfs_vget(struct mount *mp, ino_t ino, +static int ntfs_vget(struct mount *mp, ino_t ino, int, struct vnode **vpp); static int ntfs_loadvnode(struct mount *, struct vnode *, const void *, size_t, const void **); @@ -83,7 +83,7 @@ static int ntfs_vptofh(struct vnode *, s static void ntfs_init(void); static void ntfs_reinit(void); static void ntfs_done(void); -static int ntfs_fhtovp(struct mount *, struct fid *, +static int ntfs_fhtovp(struct mount *, struct fid *, int, struct vnode **); static int ntfs_mountroot(void); @@ -387,7 +387,8 @@ ntfs_mountfs(struct vnode *devvp, struct { int pi[3] = { NTFS_MFTINO, NTFS_ROOTINO, NTFS_BITMAPINO }; for (i = 0; i < 3; i++) { - error = VFS_VGET(mp, pi[i], &(ntmp->ntm_sysvn[pi[i]])); + error = VFS_VGET(mp, pi[i], LK_EXCLUSIVE, + &(ntmp->ntm_sysvn[pi[i]])); if (error) goto out1; ntmp->ntm_sysvn[pi[i]]->v_vflag |= VV_SYSTEM; @@ -417,7 +418,7 @@ ntfs_mountfs(struct vnode *devvp, struct struct attrdef ad; /* Open $AttrDef */ - error = VFS_VGET(mp, NTFS_ATTRDEFINO, &vp); + error = VFS_VGET(mp, NTFS_ATTRDEFINO, LK_EXCLUSIVE, &vp); if (error) goto out1; @@ -570,14 +571,14 @@ ntfs_unmount(struct mount *mp, int mntfl } static int -ntfs_root(struct mount *mp, struct vnode **vpp) +ntfs_root(struct mount *mp, int lktype, struct vnode **vpp) { struct vnode *nvp; int error = 0; dprintf(("ntfs_root(): sysvn: %p\n", VFSTONTFS(mp)->ntm_sysvn[NTFS_ROOTINO])); - error = VFS_VGET(mp, (ino_t)NTFS_ROOTINO, &nvp); + error = VFS_VGET(mp, (ino_t)NTFS_ROOTINO, lktype, &nvp); if (error) { printf("ntfs_root: VFS_VGET failed: %d\n", error); return (error); @@ -649,7 +650,7 @@ ntfs_sync(struct mount *mp, int waitfor, /*ARGSUSED*/ static int -ntfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) +ntfs_fhtovp(struct mount *mp, struct fid *fhp, int lktype, struct vnode **vpp) { struct ntfid ntfh; int error; @@ -661,7 +662,7 @@ ntfs_fhtovp(struct mount *mp, struct fid (unsigned long long)ntfh.ntfid_ino)); error = ntfs_vgetex(mp, ntfh.ntfid_ino, ntfh.ntfid_attr, "", - LK_EXCLUSIVE, vpp); + lktype, vpp); if (error != 0) { *vpp = NULLVP; return (error); @@ -822,9 +823,9 @@ out: } static int -ntfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) +ntfs_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { - return ntfs_vgetex(mp, ino, NTFS_A_DATA, "", LK_EXCLUSIVE, vpp); + return ntfs_vgetex(mp, ino, NTFS_A_DATA, "", lktype, vpp); } int Index: src/sys/fs/ptyfs/ptyfs.h diff -u src/sys/fs/ptyfs/ptyfs.h:1.14 src/sys/fs/ptyfs/ptyfs.h:1.15 --- src/sys/fs/ptyfs/ptyfs.h:1.14 Fri Aug 15 13:40:39 2014 +++ src/sys/fs/ptyfs/ptyfs.h Fri Jan 17 20:08:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ptyfs.h,v 1.14 2014/08/15 13:40:39 hannken Exp $ */ +/* $NetBSD: ptyfs.h,v 1.15 2020/01/17 20:08:08 ad Exp $ */ /* * Copyright (c) 1993 @@ -168,7 +168,7 @@ void ptyfs_itimes(struct ptyfsnode *, co extern int (**ptyfs_vnodeop_p)(void *); extern struct vfsops ptyfs_vfsops; -int ptyfs_root(struct mount *, struct vnode **); +int ptyfs_root(struct mount *, int, struct vnode **); #endif /* _KERNEL */ #endif /* _FS_PTYFS_PTYFS_H_ */ Index: src/sys/fs/ptyfs/ptyfs_vfsops.c diff -u src/sys/fs/ptyfs/ptyfs_vfsops.c:1.56 src/sys/fs/ptyfs/ptyfs_vfsops.c:1.57 --- src/sys/fs/ptyfs/ptyfs_vfsops.c:1.56 Fri Feb 17 08:31:24 2017 +++ src/sys/fs/ptyfs/ptyfs_vfsops.c Fri Jan 17 20:08:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ptyfs_vfsops.c,v 1.56 2017/02/17 08:31:24 hannken Exp $ */ +/* $NetBSD: ptyfs_vfsops.c,v 1.57 2020/01/17 20:08:08 ad Exp $ */ /* * Copyright (c) 1992, 1993, 1995 @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ptyfs_vfsops.c,v 1.56 2017/02/17 08:31:24 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ptyfs_vfsops.c,v 1.57 2020/01/17 20:08:08 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -388,7 +388,7 @@ ptyfs_unmount(struct mount *mp, int mntf } int -ptyfs_root(struct mount *mp, struct vnode **vpp) +ptyfs_root(struct mount *mp, int lktype, struct vnode **vpp) { int error; @@ -396,7 +396,7 @@ ptyfs_root(struct mount *mp, struct vnod error = ptyfs_allocvp(mp, vpp, PTYFSroot, 0); if (error) return error; - error = vn_lock(*vpp, LK_EXCLUSIVE); + error = vn_lock(*vpp, lktype); if (error) { vrele(*vpp); *vpp = NULL; @@ -460,7 +460,7 @@ ptyfs_loadvnode(struct mount *mp, struct */ /*ARGSUSED*/ int -ptyfs_vget(struct mount *mp, ino_t ino, +ptyfs_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { return EOPNOTSUPP; Index: src/sys/fs/puffs/puffs_vfsops.c diff -u src/sys/fs/puffs/puffs_vfsops.c:1.123 src/sys/fs/puffs/puffs_vfsops.c:1.124 --- src/sys/fs/puffs/puffs_vfsops.c:1.123 Fri Sep 27 22:36:57 2019 +++ src/sys/fs/puffs/puffs_vfsops.c Fri Jan 17 20:08:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vfsops.c,v 1.123 2019/09/27 22:36:57 christos Exp $ */ +/* $NetBSD: puffs_vfsops.c,v 1.124 2020/01/17 20:08:08 ad Exp $ */ /* * Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: puffs_vfsops.c,v 1.123 2019/09/27 22:36:57 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: puffs_vfsops.c,v 1.124 2020/01/17 20:08:08 ad Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -452,7 +452,7 @@ puffs_vfsop_unmount(struct mount *mp, in * This doesn't need to travel to userspace */ int -puffs_vfsop_root(struct mount *mp, struct vnode **vpp) +puffs_vfsop_root(struct mount *mp, int lktype, struct vnode **vpp) { struct puffs_mount *pmp = MPTOPUFFSMP(mp); int rv; @@ -461,7 +461,7 @@ puffs_vfsop_root(struct mount *mp, struc KASSERT(rv != PUFFS_NOSUCHCOOKIE); if (rv != 0) return rv; - rv = vn_lock(*vpp, LK_EXCLUSIVE); + rv = vn_lock(*vpp, lktype); if (rv != 0) { vrele(*vpp); *vpp = NULL; @@ -608,7 +608,8 @@ puffs_vfsop_sync(struct mount *mp, int w } int -puffs_vfsop_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) +puffs_vfsop_fhtovp(struct mount *mp, struct fid *fhp, int lktype, + struct vnode **vpp) { PUFFS_MSG_VARS(vfs, fhtonode); struct puffs_mount *pmp = MPTOPUFFSMP(mp); @@ -652,7 +653,7 @@ puffs_vfsop_fhtovp(struct mount *mp, str fhtonode_msg->pvfsr_rdev, &vp); if (error) goto out; - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + vn_lock(vp, lktype | LK_RETRY); *vpp = vp; out: Index: src/sys/fs/smbfs/smbfs_vfsops.c diff -u src/sys/fs/smbfs/smbfs_vfsops.c:1.106 src/sys/fs/smbfs/smbfs_vfsops.c:1.107 --- src/sys/fs/smbfs/smbfs_vfsops.c:1.106 Sat Apr 1 19:35:56 2017 +++ src/sys/fs/smbfs/smbfs_vfsops.c Fri Jan 17 20:08:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: smbfs_vfsops.c,v 1.106 2017/04/01 19:35:56 riastradh Exp $ */ +/* $NetBSD: smbfs_vfsops.c,v 1.107 2020/01/17 20:08:08 ad Exp $ */ /* * Copyright (c) 2000-2001, Boris Popov @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: smbfs_vfsops.c,v 1.106 2017/04/01 19:35:56 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: smbfs_vfsops.c,v 1.107 2020/01/17 20:08:08 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -305,7 +305,7 @@ smbfs_setroot(struct mount *mp) * Return locked root vnode of a filesystem. */ int -smbfs_root(struct mount *mp, struct vnode **vpp) +smbfs_root(struct mount *mp, int lktype, struct vnode **vpp) { struct smbmount *smp = VFSTOSMBFS(mp); int error; @@ -320,7 +320,7 @@ smbfs_root(struct mount *mp, struct vnod KASSERT(smp->sm_root != NULL && SMBTOV(smp->sm_root) != NULL); *vpp = SMBTOV(smp->sm_root); vref(*vpp); - error = vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY); + error = vn_lock(*vpp, lktype | LK_RETRY); if (error) vrele(*vpp); return error; @@ -446,7 +446,7 @@ smbfs_sync(struct mount *mp, int waitfor * smbfs flat namespace lookup. Unsupported. */ /* ARGSUSED */ -int smbfs_vget(struct mount *mp, ino_t ino, +int smbfs_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { return (EOPNOTSUPP); Index: src/sys/fs/sysvbfs/sysvbfs_vfsops.c diff -u src/sys/fs/sysvbfs/sysvbfs_vfsops.c:1.46 src/sys/fs/sysvbfs/sysvbfs_vfsops.c:1.47 --- src/sys/fs/sysvbfs/sysvbfs_vfsops.c:1.46 Fri Jan 2 16:51:02 2015 +++ src/sys/fs/sysvbfs/sysvbfs_vfsops.c Fri Jan 17 20:08:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sysvbfs_vfsops.c,v 1.46 2015/01/02 16:51:02 hannken Exp $ */ +/* $NetBSD: sysvbfs_vfsops.c,v 1.47 2020/01/17 20:08:08 ad Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vfsops.c,v 1.46 2015/01/02 16:51:02 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vfsops.c,v 1.47 2020/01/17 20:08:08 ad Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -239,13 +239,13 @@ sysvbfs_unmount(struct mount *mp, int mn } int -sysvbfs_root(struct mount *mp, struct vnode **vpp) +sysvbfs_root(struct mount *mp, int lktype, struct vnode **vpp) { struct vnode *vp; int error; DPRINTF("%s:\n", __func__); - if ((error = VFS_VGET(mp, BFS_ROOT_INODE, &vp)) != 0) + if ((error = VFS_VGET(mp, BFS_ROOT_INODE, lktype, &vp)) != 0) return error; *vpp = vp; @@ -362,7 +362,7 @@ sysvbfs_loadvnode(struct mount *mp, stru } int -sysvbfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) +sysvbfs_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { int error; uint16_t number; @@ -376,7 +376,7 @@ sysvbfs_vget(struct mount *mp, ino_t ino error = vcache_get(mp, &number, sizeof(number), &vp); if (error) return error; - error = vn_lock(vp, LK_EXCLUSIVE); + error = vn_lock(vp, lktype); if (error) { vrele(vp); return error; @@ -388,7 +388,8 @@ sysvbfs_vget(struct mount *mp, ino_t ino } int -sysvbfs_fhtovp(struct mount *mp, struct fid *fid, struct vnode **vpp) +sysvbfs_fhtovp(struct mount *mp, struct fid *fid, int lktype, + struct vnode **vpp) { DPRINTF("%s:\n", __func__); Index: src/sys/fs/sysvbfs/sysvbfs_vnops.c diff -u src/sys/fs/sysvbfs/sysvbfs_vnops.c:1.63 src/sys/fs/sysvbfs/sysvbfs_vnops.c:1.64 --- src/sys/fs/sysvbfs/sysvbfs_vnops.c:1.63 Fri May 26 14:21:01 2017 +++ src/sys/fs/sysvbfs/sysvbfs_vnops.c Fri Jan 17 20:08:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sysvbfs_vnops.c,v 1.63 2017/05/26 14:21:01 riastradh Exp $ */ +/* $NetBSD: sysvbfs_vnops.c,v 1.64 2020/01/17 20:08:08 ad Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.63 2017/05/26 14:21:01 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.64 2020/01/17 20:08:08 ad Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -114,7 +114,9 @@ sysvbfs_lookup(void *arg) } /* Allocate v-node */ - if ((error = sysvbfs_vget(v->v_mount, dirent->inode, &vpp)) != 0) { + error = sysvbfs_vget(v->v_mount, dirent->inode, + LK_EXCLUSIVE, &vpp); + if (error != 0) { DPRINTF("%s: can't get vnode.\n", __func__); return error; } @@ -159,7 +161,8 @@ sysvbfs_create(void *arg) if (!bfs_dirent_lookup_by_name(bfs, a->a_cnp->cn_nameptr, &dirent)) panic("no dirent for created file."); - if ((err = sysvbfs_vget(mp, dirent->inode, a->a_vpp)) != 0) { + err = sysvbfs_vget(mp, dirent->inode, LK_EXCLUSIVE, a->a_vpp); + if (err != 0) { DPRINTF("%s: sysvbfs_vget failed.\n", __func__); return err; } Index: src/sys/fs/tmpfs/tmpfs_vfsops.c diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.75 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.76 --- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.75 Fri Oct 4 12:34:40 2019 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c Fri Jan 17 20:08:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vfsops.c,v 1.75 2019/10/04 12:34:40 mrg Exp $ */ +/* $NetBSD: tmpfs_vfsops.c,v 1.76 2020/01/17 20:08:08 ad Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.75 2019/10/04 12:34:40 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.76 2020/01/17 20:08:08 ad Exp $"); #include <sys/param.h> #include <sys/atomic.h> @@ -296,7 +296,7 @@ tmpfs_unmount(struct mount *mp, int mntf } int -tmpfs_root(struct mount *mp, vnode_t **vpp) +tmpfs_root(struct mount *mp, int lktype, vnode_t **vpp) { tmpfs_node_t *node = VFS_TO_TMPFS(mp)->tm_root; int error; @@ -304,7 +304,7 @@ tmpfs_root(struct mount *mp, vnode_t **v error = vcache_get(mp, &node, sizeof(node), vpp); if (error) return error; - error = vn_lock(*vpp, LK_EXCLUSIVE); + error = vn_lock(*vpp, lktype); if (error) { vrele(*vpp); *vpp = NULL; @@ -315,14 +315,14 @@ tmpfs_root(struct mount *mp, vnode_t **v } int -tmpfs_vget(struct mount *mp, ino_t ino, vnode_t **vpp) +tmpfs_vget(struct mount *mp, ino_t ino, int lktype, vnode_t **vpp) { return EOPNOTSUPP; } int -tmpfs_fhtovp(struct mount *mp, struct fid *fhp, vnode_t **vpp) +tmpfs_fhtovp(struct mount *mp, struct fid *fhp, int lktype, vnode_t **vpp) { tmpfs_mount_t *tmp = VFS_TO_TMPFS(mp); tmpfs_node_t *node; @@ -335,6 +335,7 @@ tmpfs_fhtovp(struct mount *mp, struct fi memcpy(&tfh, fhp, sizeof(tmpfs_fid_t)); mutex_enter(&tmp->tm_lock); + /* XXX big oof .. use a better data structure */ LIST_FOREACH(node, &tmp->tm_nodes, tn_entries) { if (node->tn_id == tfh.tf_id) { /* Prevent this node from disappearing. */ @@ -354,7 +355,7 @@ tmpfs_fhtovp(struct mount *mp, struct fi } if (error) return (error == ENOENT ? ESTALE : error); - error = vn_lock(*vpp, LK_EXCLUSIVE); + error = vn_lock(*vpp, lktype); if (error) { vrele(*vpp); *vpp = NULL; Index: src/sys/fs/udf/udf_rename.c diff -u src/sys/fs/udf/udf_rename.c:1.12 src/sys/fs/udf/udf_rename.c:1.13 --- src/sys/fs/udf/udf_rename.c:1.12 Mon Nov 10 19:44:08 2014 +++ src/sys/fs/udf/udf_rename.c Fri Jan 17 20:08:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: udf_rename.c,v 1.12 2014/11/10 19:44:08 riz Exp $ */ +/* $NetBSD: udf_rename.c,v 1.13 2020/01/17 20:08:08 ad Exp $ */ /* * Copyright (c) 2013 Reinoud Zandijk @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: udf_rename.c,v 1.12 2014/11/10 19:44:08 riz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: udf_rename.c,v 1.13 2020/01/17 20:08:08 ad Exp $"); #include <sys/param.h> #include <sys/errno.h> @@ -465,7 +465,7 @@ udf_gro_lookup(struct mount *mp, struct return ENOENT; DPRINTF(LOOKUP, ("udf_gro_lookup found '%s'\n", name)); - error = udf_get_node(dir_node->ump, &icb_loc, &res_node); + error = udf_get_node(dir_node->ump, &icb_loc, &res_node, LK_EXCLUSIVE); if (error) return error; *vp_ret = res_node->vnode; @@ -598,7 +598,8 @@ udf_gro_genealogy(struct mount *mp, kaut */ DPRINTF(NODE, ("\tgetting the parent node\n")); VOP_UNLOCK(vp); - error = udf_get_node(ump, &parent_loc, &parent_node); + error = udf_get_node(ump, &parent_loc, &parent_node, + LK_EXCLUSIVE); vrele(vp); if (error) return error; Index: src/sys/fs/udf/udf_subr.c diff -u src/sys/fs/udf/udf_subr.c:1.147 src/sys/fs/udf/udf_subr.c:1.148 --- src/sys/fs/udf/udf_subr.c:1.147 Wed Sep 18 17:59:15 2019 +++ src/sys/fs/udf/udf_subr.c Fri Jan 17 20:08:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: udf_subr.c,v 1.147 2019/09/18 17:59:15 christos Exp $ */ +/* $NetBSD: udf_subr.c,v 1.148 2020/01/17 20:08:08 ad Exp $ */ /* * Copyright (c) 2006, 2008 Reinoud Zandijk @@ -29,7 +29,7 @@ #include <sys/cdefs.h> #ifndef lint -__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.147 2019/09/18 17:59:15 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.148 2020/01/17 20:08:08 ad Exp $"); #endif /* not lint */ @@ -3082,7 +3082,8 @@ udf_search_vat(struct udf_mount *ump, un icb_loc.loc.part_num = udf_rw16(UDF_VTOP_RAWPART); icb_loc.loc.lb_num = udf_rw32(vat_loc); - error = udf_get_node(ump, &icb_loc, &vat_node); + error = udf_get_node(ump, &icb_loc, &vat_node, + LK_EXCLUSIVE); if (!error) { error = udf_check_for_vat(vat_node); vat_node->i_flags = 0; /* reset access */ @@ -3197,7 +3198,8 @@ udf_read_metadata_nodes(struct udf_mount DPRINTF(VOLUMES, ("Metadata file\n")); icb_loc.loc.lb_num = pmm->meta_file_lbn; - error = udf_get_node(ump, &icb_loc, &ump->metadata_node); + error = udf_get_node(ump, &icb_loc, &ump->metadata_node, + LK_EXCLUSIVE); if (ump->metadata_node) { vp = ump->metadata_node->vnode; UDF_SET_SYSTEMFILE(vp); @@ -3206,7 +3208,8 @@ udf_read_metadata_nodes(struct udf_mount icb_loc.loc.lb_num = pmm->meta_mirror_file_lbn; if (icb_loc.loc.lb_num != -1) { DPRINTF(VOLUMES, ("Metadata copy file\n")); - error = udf_get_node(ump, &icb_loc, &ump->metadatamirror_node); + error = udf_get_node(ump, &icb_loc, &ump->metadatamirror_node, + LK_EXCLUSIVE); if (ump->metadatamirror_node) { vp = ump->metadatamirror_node->vnode; UDF_SET_SYSTEMFILE(vp); @@ -3216,7 +3219,8 @@ udf_read_metadata_nodes(struct udf_mount icb_loc.loc.lb_num = pmm->meta_bitmap_file_lbn; if (icb_loc.loc.lb_num != -1) { DPRINTF(VOLUMES, ("Metadata bitmap file\n")); - error = udf_get_node(ump, &icb_loc, &ump->metadatabitmap_node); + error = udf_get_node(ump, &icb_loc, &ump->metadatabitmap_node, + LK_EXCLUSIVE); if (ump->metadatabitmap_node) { vp = ump->metadatabitmap_node->vnode; UDF_SET_SYSTEMFILE(vp); @@ -3397,7 +3401,7 @@ udf_read_rootdirs(struct udf_mount *ump) /* try to read in the rootdir */ dir_loc = &ump->fileset_desc->rootdir_icb; - error = udf_get_node(ump, dir_loc, &rootdir_node); + error = udf_get_node(ump, dir_loc, &rootdir_node, LK_EXCLUSIVE); if (error) return ENOENT; @@ -3410,7 +3414,8 @@ udf_read_rootdirs(struct udf_mount *ump) dir_loc = &ump->fileset_desc->streamdir_icb; if (udf_rw32(dir_loc->len)) { printf("udf_read_rootdirs: streamdir defined "); - error = udf_get_node(ump, dir_loc, &streamdir_node); + error = udf_get_node(ump, dir_loc, &streamdir_node, + LK_EXCLUSIVE); if (error) { printf("but error in streamdir reading\n"); } else { @@ -5625,7 +5630,7 @@ udf_loadvnode(struct mount *mp, struct v int udf_get_node(struct udf_mount *ump, struct long_ad *node_icb_loc, - struct udf_node **udf_noderes) + struct udf_node **udf_noderes, int lktype) { int error; struct vnode *vp; Index: src/sys/fs/udf/udf_subr.h diff -u src/sys/fs/udf/udf_subr.h:1.20 src/sys/fs/udf/udf_subr.h:1.21 --- src/sys/fs/udf/udf_subr.h:1.20 Tue May 24 09:55:57 2016 +++ src/sys/fs/udf/udf_subr.h Fri Jan 17 20:08:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: udf_subr.h,v 1.20 2016/05/24 09:55:57 reinoud Exp $ */ +/* $NetBSD: udf_subr.h,v 1.21 2020/01/17 20:08:08 ad Exp $ */ /* * Copyright (c) 2006, 2008 Reinoud Zandijk @@ -132,7 +132,7 @@ uint64_t udf_advance_uniqueid(struct udf void udf_lock_node(struct udf_node *udf_node, int flag, char const *fname, const int lineno); void udf_unlock_node(struct udf_node *udf_node, int flag); -int udf_get_node(struct udf_mount *ump, struct long_ad *icbloc, struct udf_node **noderes); +int udf_get_node(struct udf_mount *ump, struct long_ad *icbloc, struct udf_node **noderes, int); int udf_writeout_node(struct udf_node *udf_node, int waitfor); int udf_dispose_node(struct udf_node *node); Index: src/sys/fs/udf/udf_vfsops.c diff -u src/sys/fs/udf/udf_vfsops.c:1.76 src/sys/fs/udf/udf_vfsops.c:1.77 --- src/sys/fs/udf/udf_vfsops.c:1.76 Sat Jun 24 12:13:16 2017 +++ src/sys/fs/udf/udf_vfsops.c Fri Jan 17 20:08:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: udf_vfsops.c,v 1.76 2017/06/24 12:13:16 hannken Exp $ */ +/* $NetBSD: udf_vfsops.c,v 1.77 2020/01/17 20:08:08 ad Exp $ */ /* * Copyright (c) 2006, 2008 Reinoud Zandijk @@ -28,7 +28,7 @@ #include <sys/cdefs.h> #ifndef lint -__KERNEL_RCSID(0, "$NetBSD: udf_vfsops.c,v 1.76 2017/06/24 12:13:16 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: udf_vfsops.c,v 1.77 2020/01/17 20:08:08 ad Exp $"); #endif /* not lint */ @@ -744,7 +744,7 @@ udf_start(struct mount *mp, int flags) /* --------------------------------------------------------------------- */ int -udf_root(struct mount *mp, struct vnode **vpp) +udf_root(struct mount *mp, int lktype, struct vnode **vpp) { struct vnode *vp; struct long_ad *dir_loc; @@ -755,7 +755,7 @@ udf_root(struct mount *mp, struct vnode DPRINTF(CALL, ("udf_root called\n")); dir_loc = &ump->fileset_desc->rootdir_icb; - error = udf_get_node(ump, dir_loc, &root_dir); + error = udf_get_node(ump, dir_loc, &root_dir, lktype); if (error) return error; @@ -895,7 +895,7 @@ udf_sync(struct mount *mp, int waitfor, * (optional) TODO lookup why some sources state NFSv3 */ int -udf_vget(struct mount *mp, ino_t ino, +udf_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { DPRINTF(NOTIMPL, ("udf_vget called\n")); @@ -908,7 +908,7 @@ udf_vget(struct mount *mp, ino_t ino, * Lookup vnode for file handle specified */ int -udf_fhtovp(struct mount *mp, struct fid *fhp, +udf_fhtovp(struct mount *mp, struct fid *fhp, int lktype, struct vnode **vpp) { DPRINTF(NOTIMPL, ("udf_fhtovp called\n")); Index: src/sys/fs/udf/udf_vnops.c diff -u src/sys/fs/udf/udf_vnops.c:1.107 src/sys/fs/udf/udf_vnops.c:1.108 --- src/sys/fs/udf/udf_vnops.c:1.107 Fri Dec 27 09:41:51 2019 +++ src/sys/fs/udf/udf_vnops.c Fri Jan 17 20:08:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: udf_vnops.c,v 1.107 2019/12/27 09:41:51 msaitoh Exp $ */ +/* $NetBSD: udf_vnops.c,v 1.108 2020/01/17 20:08:08 ad Exp $ */ /* * Copyright (c) 2006, 2008 Reinoud Zandijk @@ -32,7 +32,7 @@ #include <sys/cdefs.h> #ifndef lint -__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.107 2019/12/27 09:41:51 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.108 2020/01/17 20:08:08 ad Exp $"); #endif /* not lint */ @@ -750,7 +750,8 @@ udf_lookup(void *v) if (error == 0) { DPRINTF(LOOKUP, ("\tfound '..'\n")); /* try to create/reuse the node */ - error = udf_get_node(ump, &icb_loc, &res_node); + error = udf_get_node(ump, &icb_loc, &res_node, + LK_EXCLUSIVE); if (!error) { DPRINTF(LOOKUP, @@ -802,7 +803,7 @@ udf_lookup(void *v) */ /* try to create/reuse the node */ - error = udf_get_node(ump, &icb_loc, &res_node); + error = udf_get_node(ump, &icb_loc, &res_node, LK_EXCLUSIVE); if (error) goto out; Index: src/sys/fs/union/union_vfsops.c diff -u src/sys/fs/union/union_vfsops.c:1.79 src/sys/fs/union/union_vfsops.c:1.80 --- src/sys/fs/union/union_vfsops.c:1.79 Wed Feb 20 10:05:59 2019 +++ src/sys/fs/union/union_vfsops.c Fri Jan 17 20:08:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: union_vfsops.c,v 1.79 2019/02/20 10:05:59 hannken Exp $ */ +/* $NetBSD: union_vfsops.c,v 1.80 2020/01/17 20:08:08 ad Exp $ */ /* * Copyright (c) 1994 The Regents of the University of California. @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: union_vfsops.c,v 1.79 2019/02/20 10:05:59 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: union_vfsops.c,v 1.80 2020/01/17 20:08:08 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -391,7 +391,7 @@ union_unmount(struct mount *mp, int mntf } int -union_root(struct mount *mp, struct vnode **vpp) +union_root(struct mount *mp, int lktype, struct vnode **vpp) { struct union_mount *um = MOUNTTOUNIONMOUNT(mp); int error; @@ -412,7 +412,7 @@ union_root(struct mount *mp, struct vnod return error; } - vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY); + vn_lock(*vpp, lktype | LK_RETRY); return 0; } @@ -488,7 +488,7 @@ union_sync(struct mount *mp, int waitfor /*ARGSUSED*/ int -union_vget(struct mount *mp, ino_t ino, +union_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { Index: src/sys/fs/union/union_vnops.c diff -u src/sys/fs/union/union_vnops.c:1.70 src/sys/fs/union/union_vnops.c:1.71 --- src/sys/fs/union/union_vnops.c:1.70 Fri May 26 14:21:01 2017 +++ src/sys/fs/union/union_vnops.c Fri Jan 17 20:08:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: union_vnops.c,v 1.70 2017/05/26 14:21:01 riastradh Exp $ */ +/* $NetBSD: union_vnops.c,v 1.71 2020/01/17 20:08:08 ad Exp $ */ /* * Copyright (c) 1992, 1993, 1994, 1995 @@ -72,7 +72,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.70 2017/05/26 14:21:01 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.71 2020/01/17 20:08:08 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -253,7 +253,7 @@ union_lookup1(struct vnode *udvp, struct if (vfs_busy(mp)) continue; vput(dvp); - error = VFS_ROOT(mp, &tdvp); + error = VFS_ROOT(mp, LK_EXCLUSIVE, &tdvp); vfs_unbusy(mp); if (error) { return (error); Index: src/sys/fs/unionfs/unionfs_vfsops.c diff -u src/sys/fs/unionfs/unionfs_vfsops.c:1.13 src/sys/fs/unionfs/unionfs_vfsops.c:1.14 --- src/sys/fs/unionfs/unionfs_vfsops.c:1.13 Wed Apr 16 18:55:19 2014 +++ src/sys/fs/unionfs/unionfs_vfsops.c Fri Jan 17 20:08:08 2020 @@ -353,7 +353,7 @@ unionfs_unmount(struct mount *mp, int mn } int -unionfs_root(struct mount *mp, struct vnode **vpp) +unionfs_root(struct mount *mp, int lktype, struct vnode **vpp) { struct unionfs_mount *ump; struct vnode *vp; @@ -365,7 +365,7 @@ unionfs_root(struct mount *mp, struct vn vp, VOP_ISLOCKED(vp)); vref(vp); - vn_lock(vp, LK_EXCLUSIVE); + vn_lock(vp, lktype); *vpp = vp; @@ -442,13 +442,13 @@ unionfs_sync(struct mount *mp, int waitf } int -unionfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) +unionfs_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { return (EOPNOTSUPP); } int -unionfs_fhtovp(struct mount *mp, struct fid *fidp, struct vnode **vpp) +unionfs_fhtovp(struct mount *mp, struct fid *fidp, int lktype, struct vnode **vpp) { return (EOPNOTSUPP); } Index: src/sys/fs/v7fs/v7fs_vfsops.c diff -u src/sys/fs/v7fs/v7fs_vfsops.c:1.16 src/sys/fs/v7fs/v7fs_vfsops.c:1.17 --- src/sys/fs/v7fs/v7fs_vfsops.c:1.16 Thu Jun 1 02:45:13 2017 +++ src/sys/fs/v7fs/v7fs_vfsops.c Fri Jan 17 20:08:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: v7fs_vfsops.c,v 1.16 2017/06/01 02:45:13 chs Exp $ */ +/* $NetBSD: v7fs_vfsops.c,v 1.17 2020/01/17 20:08:09 ad Exp $ */ /*- * Copyright (c) 2004, 2011 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: v7fs_vfsops.c,v 1.16 2017/06/01 02:45:13 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: v7fs_vfsops.c,v 1.17 2020/01/17 20:08:09 ad Exp $"); #if defined _KERNEL_OPT #include "opt_v7fs.h" #endif @@ -321,13 +321,13 @@ v7fs_unmount(struct mount *mp, int mntfl } int -v7fs_root(struct mount *mp, struct vnode **vpp) +v7fs_root(struct mount *mp, int lktype, struct vnode **vpp) { struct vnode *vp; int error; DPRINTF("\n"); - if ((error = VFS_VGET(mp, V7FS_ROOT_INODE, &vp)) != 0) { + if ((error = VFS_VGET(mp, V7FS_ROOT_INODE, lktype, &vp)) != 0) { DPRINTF("error=%d\n", error); return error; } @@ -482,7 +482,7 @@ v7fs_loadvnode(struct mount *mp, struct int -v7fs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) +v7fs_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { int error; v7fs_ino_t number; @@ -494,7 +494,7 @@ v7fs_vget(struct mount *mp, ino_t ino, s error = vcache_get(mp, &number, sizeof(number), &vp); if (error) return error; - error = vn_lock(vp, LK_EXCLUSIVE); + error = vn_lock(vp, lktype); if (error) { vrele(vp); return error; @@ -506,7 +506,7 @@ v7fs_vget(struct mount *mp, ino_t ino, s } int -v7fs_fhtovp(struct mount *mp, struct fid *fid, struct vnode **vpp) +v7fs_fhtovp(struct mount *mp, struct fid *fid, int lktype, struct vnode **vpp) { DPRINTF("\n"); Index: src/sys/fs/v7fs/v7fs_vnops.c diff -u src/sys/fs/v7fs/v7fs_vnops.c:1.26 src/sys/fs/v7fs/v7fs_vnops.c:1.27 --- src/sys/fs/v7fs/v7fs_vnops.c:1.26 Fri May 26 14:21:01 2017 +++ src/sys/fs/v7fs/v7fs_vnops.c Fri Jan 17 20:08:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: v7fs_vnops.c,v 1.26 2017/05/26 14:21:01 riastradh Exp $ */ +/* $NetBSD: v7fs_vnops.c,v 1.27 2020/01/17 20:08:09 ad Exp $ */ /*- * Copyright (c) 2004, 2011 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.26 2017/05/26 14:21:01 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.27 2020/01/17 20:08:09 ad Exp $"); #if defined _KERNEL_OPT #include "opt_v7fs.h" #endif @@ -174,7 +174,8 @@ v7fs_lookup(void *v) VOP_UNLOCK(dvp); /* preserve reference count. (not vput) */ } DPRINTF("enter vget\n"); - if ((error = v7fs_vget(dvp->v_mount, ino, &vpp))) { + error = v7fs_vget(dvp->v_mount, ino, LK_EXCLUSIVE, &vpp); + if (error != 0) { DPRINTF("***can't get vnode.\n"); return error; } @@ -230,7 +231,8 @@ v7fs_create(void *v) /* Get myself vnode. */ *a->a_vpp = 0; - if ((error = v7fs_vget(mp, ino, a->a_vpp))) { + error = v7fs_vget(mp, ino, LK_EXCLUSIVE, a->a_vpp); + if (error != 0) { DPRINTF("v7fs_vget failed.\n"); return error; } @@ -284,7 +286,8 @@ v7fs_mknod(void *v) /* Sync dirent size change. */ uvm_vnp_setsize(dvp, v7fs_inode_filesize(&parent_node->inode)); - if ((error = v7fs_vget(mp, ino, a->a_vpp))) { + error = v7fs_vget(mp, ino, LK_EXCLUSIVE, a->a_vpp); + if (error != 0) { DPRINTF("can't get vnode.\n"); return error; } @@ -847,7 +850,8 @@ v7fs_mkdir(void *v) /* Sync dirent size change. */ uvm_vnp_setsize(dvp, v7fs_inode_filesize(&parent_node->inode)); - if ((error = v7fs_vget(mp, ino, a->a_vpp))) { + error = v7fs_vget(mp, ino, LK_EXCLUSIVE, a->a_vpp); + if (error != 0) { DPRINTF("can't get vnode.\n"); } struct v7fs_node *newnode = (*a->a_vpp)->v_data; @@ -1287,7 +1291,8 @@ v7fs_symlink(void *v) uvm_vnp_setsize(a->a_dvp, v7fs_inode_filesize(&parent_node->inode)); /* Get myself vnode. */ - if ((error = v7fs_vget(v7fsmount->mountp, ino, a->a_vpp))) { + error = v7fs_vget(v7fsmount->mountp, ino, LK_EXCLUSIVE, a->a_vpp); + if (error != 0) { DPRINTF("can't get vnode.\n"); } Index: src/sys/kern/vfs_lookup.c diff -u src/sys/kern/vfs_lookup.c:1.212 src/sys/kern/vfs_lookup.c:1.213 --- src/sys/kern/vfs_lookup.c:1.212 Thu Jul 18 09:39:40 2019 +++ src/sys/kern/vfs_lookup.c Fri Jan 17 20:08:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_lookup.c,v 1.212 2019/07/18 09:39:40 hannken Exp $ */ +/* $NetBSD: vfs_lookup.c,v 1.213 2020/01/17 20:08:09 ad Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.212 2019/07/18 09:39:40 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.213 2020/01/17 20:08:09 ad Exp $"); #ifdef _KERNEL_OPT #include "opt_magiclinks.h" @@ -1124,7 +1124,7 @@ unionlookup: VOP_UNLOCK(searchdir); } vput(foundobj); - error = VFS_ROOT(mp, &foundobj); + error = VFS_ROOT(mp, LK_EXCLUSIVE, &foundobj); vfs_unbusy(mp); if (error) { if (searchdir != NULL) { Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.73 src/sys/kern/vfs_mount.c:1.74 --- src/sys/kern/vfs_mount.c:1.73 Sun Dec 22 19:47:34 2019 +++ src/sys/kern/vfs_mount.c Fri Jan 17 20:08:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.73 2019/12/22 19:47:34 ad Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.74 2020/01/17 20:08:09 ad Exp $ */ /*- * Copyright (c) 1997-2019 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.73 2019/12/22 19:47:34 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.74 2020/01/17 20:08:09 ad Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -653,7 +653,7 @@ mount_checkdirs(vnode_t *olddp) if (olddp->v_usecount == 1) { return; } - if (VFS_ROOT(olddp->v_mountedhere, &newdp)) + if (VFS_ROOT(olddp->v_mountedhere, LK_EXCLUSIVE, &newdp)) panic("mount: lost mount"); do { @@ -1241,7 +1241,7 @@ done: * Get the vnode for '/'. Set cwdi0.cwdi_cdir to * reference it. */ - error = VFS_ROOT(mp, &rootvnode); + error = VFS_ROOT(mp, LK_SHARED, &rootvnode); if (error) panic("cannot find root vnode, error=%d", error); cwdi0.cwdi_cdir = rootvnode; Index: src/sys/kern/vfs_subr.c diff -u src/sys/kern/vfs_subr.c:1.478 src/sys/kern/vfs_subr.c:1.479 --- src/sys/kern/vfs_subr.c:1.478 Sun Dec 22 19:47:34 2019 +++ src/sys/kern/vfs_subr.c Fri Jan 17 20:08:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_subr.c,v 1.478 2019/12/22 19:47:34 ad Exp $ */ +/* $NetBSD: vfs_subr.c,v 1.479 2020/01/17 20:08:09 ad Exp $ */ /*- * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008, 2019 @@ -69,7 +69,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.478 2019/12/22 19:47:34 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.479 2020/01/17 20:08:09 ad Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -1350,14 +1350,14 @@ VFS_UNMOUNT(struct mount *mp, int a) } int -VFS_ROOT(struct mount *mp, struct vnode **a) +VFS_ROOT(struct mount *mp, int lktype, struct vnode **a) { int error; if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) { KERNEL_LOCK(1, NULL); } - error = (*(mp->mnt_op->vfs_root))(mp, a); + error = (*(mp->mnt_op->vfs_root))(mp, lktype, a); if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) { KERNEL_UNLOCK_ONE(NULL); } @@ -1414,14 +1414,14 @@ VFS_SYNC(struct mount *mp, int a, struct } int -VFS_FHTOVP(struct mount *mp, struct fid *a, struct vnode **b) +VFS_FHTOVP(struct mount *mp, struct fid *a, int b, struct vnode **c) { int error; if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) { KERNEL_LOCK(1, NULL); } - error = (*(mp->mnt_op->vfs_fhtovp))(mp, a, b); + error = (*(mp->mnt_op->vfs_fhtovp))(mp, a, b, c); if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) { KERNEL_UNLOCK_ONE(NULL); } Index: src/sys/kern/vfs_syscalls.c diff -u src/sys/kern/vfs_syscalls.c:1.539 src/sys/kern/vfs_syscalls.c:1.540 --- src/sys/kern/vfs_syscalls.c:1.539 Tue Dec 31 11:49:08 2019 +++ src/sys/kern/vfs_syscalls.c Fri Jan 17 20:08:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_syscalls.c,v 1.539 2019/12/31 11:49:08 ad Exp $ */ +/* $NetBSD: vfs_syscalls.c,v 1.540 2020/01/17 20:08:09 ad Exp $ */ /*- * Copyright (c) 2008, 2009, 2019 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.539 2019/12/31 11:49:08 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.540 2020/01/17 20:08:09 ad Exp $"); #ifdef _KERNEL_OPT #include "opt_fileassoc.h" @@ -1358,7 +1358,7 @@ sys_fchdir(struct lwp *l, const struct s vput(vp); if (error != 0) goto out; - error = VFS_ROOT(mp, &tdp); + error = VFS_ROOT(mp, LK_SHARED, &tdp); vfs_unbusy(mp); if (error) goto out; @@ -1405,7 +1405,7 @@ sys_fchroot(struct lwp *l, const struct if ((error = fd_getvnode(fd, &fp)) != 0) return error; vp = fp->f_vnode; - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + vn_lock(vp, LK_SHARED | LK_RETRY); if (vp->v_type != VDIR) error = ENOTDIR; else @@ -1831,7 +1831,7 @@ vfs_fhtovp(fhandle_t *fhp, struct vnode error = EOPNOTSUPP; goto out; } - error = VFS_FHTOVP(mp, FHANDLE_FILEID(fhp), vpp); + error = VFS_FHTOVP(mp, FHANDLE_FILEID(fhp), LK_EXCLUSIVE, vpp); out: return error; } Index: src/sys/miscfs/fdesc/fdesc.h diff -u src/sys/miscfs/fdesc/fdesc.h:1.22 src/sys/miscfs/fdesc/fdesc.h:1.23 --- src/sys/miscfs/fdesc/fdesc.h:1.22 Sun Jul 13 11:23:01 2014 +++ src/sys/miscfs/fdesc/fdesc.h Fri Jan 17 20:08:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: fdesc.h,v 1.22 2014/07/13 11:23:01 hannken Exp $ */ +/* $NetBSD: fdesc.h,v 1.23 2020/01/17 20:08:09 ad Exp $ */ /* * Copyright (c) 1992, 1993 @@ -70,7 +70,7 @@ struct fdescnode { extern dev_t devctty; extern void fdesc_init(void); extern void fdesc_done(void); -extern int fdesc_root(struct mount *, struct vnode **); +extern int fdesc_root(struct mount *, int, struct vnode **); extern int fdesc_allocvp(fdntype, int, struct mount *, struct vnode **); extern int (**fdesc_vnodeop_p)(void *); extern struct vfsops fdesc_vfsops; Index: src/sys/miscfs/fdesc/fdesc_vfsops.c diff -u src/sys/miscfs/fdesc/fdesc_vfsops.c:1.92 src/sys/miscfs/fdesc/fdesc_vfsops.c:1.93 --- src/sys/miscfs/fdesc/fdesc_vfsops.c:1.92 Fri Feb 17 08:31:25 2017 +++ src/sys/miscfs/fdesc/fdesc_vfsops.c Fri Jan 17 20:08:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: fdesc_vfsops.c,v 1.92 2017/02/17 08:31:25 hannken Exp $ */ +/* $NetBSD: fdesc_vfsops.c,v 1.93 2020/01/17 20:08:09 ad Exp $ */ /* * Copyright (c) 1992, 1993, 1995 @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fdesc_vfsops.c,v 1.92 2017/02/17 08:31:25 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdesc_vfsops.c,v 1.93 2020/01/17 20:08:09 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -136,7 +136,7 @@ fdesc_unmount(struct mount *mp, int mntf } int -fdesc_root(struct mount *mp, struct vnode **vpp) +fdesc_root(struct mount *mp, int lktype, struct vnode **vpp) { struct vnode *vp; @@ -145,7 +145,7 @@ fdesc_root(struct mount *mp, struct vnod */ vp = mp->mnt_data; vref(vp); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + vn_lock(vp, lktype | LK_RETRY); *vpp = vp; return (0); } @@ -164,7 +164,7 @@ fdesc_sync(struct mount *mp, int waitfor * Currently unsupported. */ int -fdesc_vget(struct mount *mp, ino_t ino, +fdesc_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { Index: src/sys/miscfs/genfs/layer_extern.h diff -u src/sys/miscfs/genfs/layer_extern.h:1.40 src/sys/miscfs/genfs/layer_extern.h:1.41 --- src/sys/miscfs/genfs/layer_extern.h:1.40 Sun Jun 4 08:02:26 2017 +++ src/sys/miscfs/genfs/layer_extern.h Fri Jan 17 20:08:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: layer_extern.h,v 1.40 2017/06/04 08:02:26 hannken Exp $ */ +/* $NetBSD: layer_extern.h,v 1.41 2020/01/17 20:08:09 ad Exp $ */ /* * Copyright (c) 1999 National Aeronautics & Space Administration @@ -80,14 +80,14 @@ int layer_node_create(struct mount *, st /* VFS routines */ int layerfs_start(struct mount *, int); -int layerfs_root(struct mount *, struct vnode **); +int layerfs_root(struct mount *, int, struct vnode **); int layerfs_quotactl(struct mount *, struct quotactl_args *); int layerfs_statvfs(struct mount *, struct statvfs *); int layerfs_sync(struct mount *, int, struct kauth_cred *); int layerfs_loadvnode(struct mount *, struct vnode *, const void *, size_t, const void **); -int layerfs_vget(struct mount *, ino_t, struct vnode **); -int layerfs_fhtovp(struct mount *, struct fid *, struct vnode **); +int layerfs_vget(struct mount *, ino_t, int, struct vnode **); +int layerfs_fhtovp(struct mount *, struct fid *, int, struct vnode **); int layerfs_vptofh(struct vnode *, struct fid *, size_t *); int layerfs_snapshot(struct mount *, struct vnode *, struct timespec *); int layerfs_suspendctl(struct mount *, int); Index: src/sys/miscfs/genfs/layer_vfsops.c diff -u src/sys/miscfs/genfs/layer_vfsops.c:1.52 src/sys/miscfs/genfs/layer_vfsops.c:1.53 --- src/sys/miscfs/genfs/layer_vfsops.c:1.52 Wed Aug 7 00:38:02 2019 +++ src/sys/miscfs/genfs/layer_vfsops.c Fri Jan 17 20:08:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: layer_vfsops.c,v 1.52 2019/08/07 00:38:02 pgoyette Exp $ */ +/* $NetBSD: layer_vfsops.c,v 1.53 2020/01/17 20:08:09 ad Exp $ */ /* * Copyright (c) 1999 National Aeronautics & Space Administration @@ -74,7 +74,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.52 2019/08/07 00:38:02 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.53 2020/01/17 20:08:09 ad Exp $"); #include <sys/param.h> #include <sys/sysctl.h> @@ -125,7 +125,7 @@ layerfs_start(struct mount *mp, int flag } int -layerfs_root(struct mount *mp, struct vnode **vpp) +layerfs_root(struct mount *mp, int lktype, struct vnode **vpp) { struct vnode *vp; @@ -138,7 +138,7 @@ layerfs_root(struct mount *mp, struct vn * Return root vnode with locked and with a reference held. */ vref(vp); - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + vn_lock(vp, lktype | LK_RETRY); *vpp = vp; return 0; } @@ -227,12 +227,12 @@ layerfs_loadvnode(struct mount *mp, stru } int -layerfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) +layerfs_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { struct vnode *vp; int error; - error = VFS_VGET(mp->mnt_lower, ino, &vp); + error = VFS_VGET(mp->mnt_lower, ino, lktype, &vp); if (error) { *vpp = NULL; return error; @@ -244,7 +244,7 @@ layerfs_vget(struct mount *mp, ino_t ino *vpp = NULL; return error; } - error = vn_lock(*vpp, LK_EXCLUSIVE); + error = vn_lock(*vpp, lktype); if (error) { vrele(*vpp); *vpp = NULL; @@ -254,12 +254,13 @@ layerfs_vget(struct mount *mp, ino_t ino } int -layerfs_fhtovp(struct mount *mp, struct fid *fidp, struct vnode **vpp) +layerfs_fhtovp(struct mount *mp, struct fid *fidp, int lktype, + struct vnode **vpp) { struct vnode *vp; int error; - error = VFS_FHTOVP(mp->mnt_lower, fidp, &vp); + error = VFS_FHTOVP(mp->mnt_lower, fidp, lktype, &vp); if (error) { *vpp = NULL; return error; @@ -271,7 +272,7 @@ layerfs_fhtovp(struct mount *mp, struct *vpp = NULL; return (error); } - error = vn_lock(*vpp, LK_EXCLUSIVE); + error = vn_lock(*vpp, lktype); if (error) { vrele(*vpp); *vpp = NULL; Index: src/sys/miscfs/kernfs/kernfs.h diff -u src/sys/miscfs/kernfs/kernfs.h:1.41 src/sys/miscfs/kernfs/kernfs.h:1.42 --- src/sys/miscfs/kernfs/kernfs.h:1.41 Thu Jan 2 15:42:27 2020 +++ src/sys/miscfs/kernfs/kernfs.h Fri Jan 17 20:08:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs.h,v 1.41 2020/01/02 15:42:27 thorpej Exp $ */ +/* $NetBSD: kernfs.h,v 1.42 2020/01/17 20:08:09 ad Exp $ */ /* * Copyright (c) 1992, 1993 @@ -126,7 +126,7 @@ extern struct vfsops kernfs_vfsops; extern dev_t rrootdev; extern kmutex_t kfs_lock; -int kernfs_root(struct mount *, struct vnode **); +int kernfs_root(struct mount *, int, struct vnode **); /* * Data types for the kernfs file operations. Index: src/sys/miscfs/kernfs/kernfs_vfsops.c diff -u src/sys/miscfs/kernfs/kernfs_vfsops.c:1.96 src/sys/miscfs/kernfs/kernfs_vfsops.c:1.97 --- src/sys/miscfs/kernfs/kernfs_vfsops.c:1.96 Fri Feb 17 08:31:25 2017 +++ src/sys/miscfs/kernfs/kernfs_vfsops.c Fri Jan 17 20:08:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kernfs_vfsops.c,v 1.96 2017/02/17 08:31:25 hannken Exp $ */ +/* $NetBSD: kernfs_vfsops.c,v 1.97 2020/01/17 20:08:09 ad Exp $ */ /* * Copyright (c) 1992, 1993, 1995 @@ -39,7 +39,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.96 2017/02/17 08:31:25 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kernfs_vfsops.c,v 1.97 2020/01/17 20:08:09 ad Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -189,7 +189,7 @@ kernfs_unmount(struct mount *mp, int mnt } int -kernfs_root(struct mount *mp, struct vnode **vpp) +kernfs_root(struct mount *mp, int lktype, struct vnode **vpp) { const struct kern_target *root_target = &kern_targets[0]; int error; @@ -198,7 +198,7 @@ kernfs_root(struct mount *mp, struct vno error = vcache_get(mp, &root_target, sizeof(root_target), vpp); if (error) return error; - error = vn_lock(*vpp, LK_EXCLUSIVE); + error = vn_lock(*vpp, lktype); if (error) { vrele(*vpp); *vpp = NULL; @@ -221,7 +221,7 @@ kernfs_sync(struct mount *mp, int waitfo * Currently unsupported. */ int -kernfs_vget(struct mount *mp, ino_t ino, +kernfs_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { Index: src/sys/miscfs/procfs/procfs.h diff -u src/sys/miscfs/procfs/procfs.h:1.77 src/sys/miscfs/procfs/procfs.h:1.78 --- src/sys/miscfs/procfs/procfs.h:1.77 Thu Sep 26 17:33:18 2019 +++ src/sys/miscfs/procfs/procfs.h Fri Jan 17 20:08:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: procfs.h,v 1.77 2019/09/26 17:33:18 christos Exp $ */ +/* $NetBSD: procfs.h,v 1.78 2020/01/17 20:08:09 ad Exp $ */ /* * Copyright (c) 1993 @@ -276,7 +276,7 @@ int procfs_getcpuinfstr(char *, size_t * extern int (**procfs_vnodeop_p)(void *); extern struct vfsops procfs_vfsops; -int procfs_root(struct mount *, struct vnode **); +int procfs_root(struct mount *, int, struct vnode **); #ifdef __HAVE_PROCFS_MACHDEP struct vattr; Index: src/sys/miscfs/procfs/procfs_vfsops.c diff -u src/sys/miscfs/procfs/procfs_vfsops.c:1.101 src/sys/miscfs/procfs/procfs_vfsops.c:1.102 --- src/sys/miscfs/procfs/procfs_vfsops.c:1.101 Sat Mar 30 23:28:30 2019 +++ src/sys/miscfs/procfs/procfs_vfsops.c Fri Jan 17 20:08:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: procfs_vfsops.c,v 1.101 2019/03/30 23:28:30 christos Exp $ */ +/* $NetBSD: procfs_vfsops.c,v 1.102 2020/01/17 20:08:09 ad Exp $ */ /* * Copyright (c) 1993 @@ -76,7 +76,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.101 2019/03/30 23:28:30 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: procfs_vfsops.c,v 1.102 2020/01/17 20:08:09 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -201,13 +201,13 @@ procfs_unmount(struct mount *mp, int mnt } int -procfs_root(struct mount *mp, struct vnode **vpp) +procfs_root(struct mount *mp, int lktype, struct vnode **vpp) { int error; error = procfs_allocvp(mp, vpp, 0, PFSroot, -1); if (error == 0) { - error = vn_lock(*vpp, LK_EXCLUSIVE); + error = vn_lock(*vpp, lktype); if (error != 0) { vrele(*vpp); *vpp = NULL; @@ -258,7 +258,7 @@ procfs_sync( /*ARGSUSED*/ int -procfs_vget(struct mount *mp, ino_t ino, +procfs_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { return (EOPNOTSUPP); Index: src/sys/nfs/nfs_export.c diff -u src/sys/nfs/nfs_export.c:1.61 src/sys/nfs/nfs_export.c:1.62 --- src/sys/nfs/nfs_export.c:1.61 Sun Dec 22 19:47:34 2019 +++ src/sys/nfs/nfs_export.c Fri Jan 17 20:08:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_export.c,v 1.61 2019/12/22 19:47:34 ad Exp $ */ +/* $NetBSD: nfs_export.c,v 1.62 2020/01/17 20:08:09 ad Exp $ */ /*- * Copyright (c) 1997, 1998, 2004, 2005, 2008, 2019 The NetBSD Foundation, Inc. @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nfs_export.c,v 1.61 2019/12/22 19:47:34 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_export.c,v 1.62 2020/01/17 20:08:09 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -770,7 +770,7 @@ setpublicfs(struct mount *mp, struct net /* * Get real filehandle for root of exported FS. */ - if ((error = VFS_ROOT(mp, &rvp))) + if ((error = VFS_ROOT(mp, LK_EXCLUSIVE, &rvp))) return error; fhsize = 0; Index: src/sys/nfs/nfs_serv.c diff -u src/sys/nfs/nfs_serv.c:1.178 src/sys/nfs/nfs_serv.c:1.179 --- src/sys/nfs/nfs_serv.c:1.178 Thu Jan 2 15:42:27 2020 +++ src/sys/nfs/nfs_serv.c Fri Jan 17 20:08:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_serv.c,v 1.178 2020/01/02 15:42:27 thorpej Exp $ */ +/* $NetBSD: nfs_serv.c,v 1.179 2020/01/17 20:08:09 ad Exp $ */ /* * Copyright (c) 1989, 1993 @@ -55,7 +55,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.178 2020/01/02 15:42:27 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.179 2020/01/17 20:08:09 ad Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -3056,7 +3056,8 @@ again: * even be here otherwise. */ if (!getret) { - if ((getret = VFS_VGET(vp->v_mount, at.va_fileid, &nvp))) + if ((getret = VFS_VGET(vp->v_mount, at.va_fileid, + LK_EXCLUSIVE, &nvp))) getret = (getret == EOPNOTSUPP) ? NFSERR_NOTSUPP : NFSERR_IO; else @@ -3144,7 +3145,8 @@ again: * For readdir_and_lookup get the vnode using * the file number. */ - if (VFS_VGET(vp->v_mount, dp->d_fileno, &nvp)) + if (VFS_VGET(vp->v_mount, dp->d_fileno, LK_EXCLUSIVE, + &nvp)) goto invalid; if (nfsrv_composefh(nvp, &nnsfh, true)) { vput(nvp); Index: src/sys/nfs/nfs_srvsubs.c diff -u src/sys/nfs/nfs_srvsubs.c:1.14 src/sys/nfs/nfs_srvsubs.c:1.15 --- src/sys/nfs/nfs_srvsubs.c:1.14 Mon Nov 5 19:06:27 2012 +++ src/sys/nfs/nfs_srvsubs.c Fri Jan 17 20:08:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_srvsubs.c,v 1.14 2012/11/05 19:06:27 dholland Exp $ */ +/* $NetBSD: nfs_srvsubs.c,v 1.15 2020/01/17 20:08:09 ad Exp $ */ /* * Copyright (c) 1989, 1993 @@ -70,7 +70,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nfs_srvsubs.c,v 1.14 2012/11/05 19:06:27 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_srvsubs.c,v 1.15 2020/01/17 20:08:09 ad Exp $"); #include <sys/param.h> #include <sys/proc.h> @@ -311,7 +311,7 @@ nfsrv_fhtovp(nfsrvfh_t *nsfh, int lockfl return error; } - error = VFS_FHTOVP(mp, &fhp->fh_fid, vpp); + error = VFS_FHTOVP(mp, &fhp->fh_fid, LK_EXCLUSIVE, vpp); if (error) return (error); Index: src/sys/nfs/nfs_vfsops.c diff -u src/sys/nfs/nfs_vfsops.c:1.237 src/sys/nfs/nfs_vfsops.c:1.238 --- src/sys/nfs/nfs_vfsops.c:1.237 Mon Sep 3 16:29:36 2018 +++ src/sys/nfs/nfs_vfsops.c Fri Jan 17 20:08:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_vfsops.c,v 1.237 2018/09/03 16:29:36 riastradh Exp $ */ +/* $NetBSD: nfs_vfsops.c,v 1.238 2020/01/17 20:08:09 ad Exp $ */ /* * Copyright (c) 1989, 1993, 1995 @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.237 2018/09/03 16:29:36 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.238 2020/01/17 20:08:09 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_nfs.h" @@ -937,7 +937,7 @@ err: * Return root of a filesystem */ int -nfs_root(struct mount *mp, struct vnode **vpp) +nfs_root(struct mount *mp, int lktype, struct vnode **vpp) { struct vnode *vp; struct nfsmount *nmp; @@ -946,7 +946,7 @@ nfs_root(struct mount *mp, struct vnode nmp = VFSTONFS(mp); vp = nmp->nm_vnode; vref(vp); - error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + error = vn_lock(vp, lktype | LK_RETRY); if (error != 0) { vrele(vp); return error; @@ -1005,7 +1005,7 @@ nfs_sync(struct mount *mp, int waitfor, */ /* ARGSUSED */ int -nfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) +nfs_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { return (EOPNOTSUPP); @@ -1070,7 +1070,7 @@ nfs_sysctl_fini(void) /* ARGSUSED */ int -nfs_fhtovp(struct mount *mp, struct fid *fid, struct vnode **vpp) +nfs_fhtovp(struct mount *mp, struct fid *fid, int lktype, struct vnode **vpp) { size_t fidsize; size_t fhsize; @@ -1095,6 +1095,7 @@ nfs_fhtovp(struct mount *mp, struct fid return EINVAL; } } + /* XXX lktype ignored */ error = nfs_nget(mp, (void *)fid->fid_data, fhsize, &np); if (error) { return error; Index: src/sys/rump/librump/rumpvfs/rump_vfs.c diff -u src/sys/rump/librump/rumpvfs/rump_vfs.c:1.88 src/sys/rump/librump/rumpvfs/rump_vfs.c:1.89 --- src/sys/rump/librump/rumpvfs/rump_vfs.c:1.88 Wed Feb 20 10:07:27 2019 +++ src/sys/rump/librump/rumpvfs/rump_vfs.c Fri Jan 17 20:08:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: rump_vfs.c,v 1.88 2019/02/20 10:07:27 hannken Exp $ */ +/* $NetBSD: rump_vfs.c,v 1.89 2020/01/17 20:08:09 ad Exp $ */ /* * Copyright (c) 2008 Antti Kantee. All Rights Reserved. @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.88 2019/02/20 10:07:27 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rump_vfs.c,v 1.89 2020/01/17 20:08:09 ad Exp $"); #include <sys/param.h> #include <sys/buf.h> @@ -411,7 +411,7 @@ rump_vfs_root(struct mount *mp, struct v { int rv; - rv = VFS_ROOT(mp, vpp); + rv = VFS_ROOT(mp, LK_EXCLUSIVE, vpp); if (rv) return rv; @@ -439,7 +439,7 @@ int rump_vfs_fhtovp(struct mount *mp, struct fid *fid, struct vnode **vpp) { - return VFS_FHTOVP(mp, fid, vpp); + return VFS_FHTOVP(mp, fid, LK_EXCLUSIVE, vpp); } int Index: src/sys/rump/librump/rumpvfs/rumpfs.c diff -u src/sys/rump/librump/rumpvfs/rumpfs.c:1.153 src/sys/rump/librump/rumpvfs/rumpfs.c:1.154 --- src/sys/rump/librump/rumpvfs/rumpfs.c:1.153 Mon Jun 4 02:29:53 2018 +++ src/sys/rump/librump/rumpvfs/rumpfs.c Fri Jan 17 20:08:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: rumpfs.c,v 1.153 2018/06/04 02:29:53 chs Exp $ */ +/* $NetBSD: rumpfs.c,v 1.154 2020/01/17 20:08:09 ad Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.153 2018/06/04 02:29:53 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.154 2020/01/17 20:08:09 ad Exp $"); #include <sys/param.h> #include <sys/atomic.h> @@ -1917,18 +1917,18 @@ rumpfs_unmount(struct mount *mp, int mnt } int -rumpfs_root(struct mount *mp, struct vnode **vpp) +rumpfs_root(struct mount *mp, int lktype, struct vnode **vpp) { struct rumpfs_mount *rfsmp = mp->mnt_data; vref(rfsmp->rfsmp_rvp); - vn_lock(rfsmp->rfsmp_rvp, LK_EXCLUSIVE | LK_RETRY); + vn_lock(rfsmp->rfsmp_rvp, lktype | LK_RETRY); *vpp = rfsmp->rfsmp_rvp; return 0; } int -rumpfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) +rumpfs_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { return EOPNOTSUPP; Index: src/sys/sys/mount.h diff -u src/sys/sys/mount.h:1.235 src/sys/sys/mount.h:1.236 --- src/sys/sys/mount.h:1.235 Sun Dec 22 19:47:34 2019 +++ src/sys/sys/mount.h Fri Jan 17 20:08:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: mount.h,v 1.235 2019/12/22 19:47:34 ad Exp $ */ +/* $NetBSD: mount.h,v 1.236 2020/01/17 20:08:10 ad Exp $ */ /* * Copyright (c) 1989, 1991, 1993 @@ -190,17 +190,17 @@ struct vfsops { size_t *); int (*vfs_start) (struct mount *, int); int (*vfs_unmount) (struct mount *, int); - int (*vfs_root) (struct mount *, struct vnode **); + int (*vfs_root) (struct mount *, int, struct vnode **); int (*vfs_quotactl) (struct mount *, struct quotactl_args *); int (*vfs_statvfs) (struct mount *, struct statvfs *); int (*vfs_sync) (struct mount *, int, struct kauth_cred *); - int (*vfs_vget) (struct mount *, ino_t, struct vnode **); + int (*vfs_vget) (struct mount *, ino_t, int, struct vnode **); int (*vfs_loadvnode) (struct mount *, struct vnode *, const void *, size_t, const void **); int (*vfs_newvnode) (struct mount *, struct vnode *, struct vnode *, struct vattr *, kauth_cred_t, void *, size_t *, const void **); - int (*vfs_fhtovp) (struct mount *, struct fid *, + int (*vfs_fhtovp) (struct mount *, struct fid *, int, struct vnode **); int (*vfs_vptofh) (struct vnode *, struct fid *, size_t *); void (*vfs_init) (void); @@ -221,7 +221,7 @@ struct vfsops { }; /* XXX vget is actually file system internal. */ -#define VFS_VGET(MP, INO, VPP) (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP) +#define VFS_VGET(MP, INO, LK, VPP) (*(MP)->mnt_op->vfs_vget)(MP, INO, LK, VPP) #define VFS_LOADVNODE(MP, VP, KEY, KEY_LEN, NEW_KEY) \ (*(MP)->mnt_op->vfs_loadvnode)(MP, VP, KEY, KEY_LEN, NEW_KEY) #define VFS_NEWVNODE(MP, DVP, VP, VAP, CRED, EXTRA, NEW_LEN, NEW_KEY) \ @@ -235,11 +235,11 @@ struct vfsops { int VFS_MOUNT(struct mount *, const char *, void *, size_t *); int VFS_START(struct mount *, int); int VFS_UNMOUNT(struct mount *, int); -int VFS_ROOT(struct mount *, struct vnode **); +int VFS_ROOT(struct mount *, int, struct vnode **); int VFS_QUOTACTL(struct mount *, struct quotactl_args *); int VFS_STATVFS(struct mount *, struct statvfs *); int VFS_SYNC(struct mount *, int, struct kauth_cred *); -int VFS_FHTOVP(struct mount *, struct fid *, struct vnode **); +int VFS_FHTOVP(struct mount *, struct fid *, int, struct vnode **); int VFS_VPTOFH(struct vnode *, struct fid *, size_t *); int VFS_SNAPSHOT(struct mount *, struct vnode *, struct timespec *); int VFS_EXTATTRCTL(struct mount *, int, struct vnode *, int, const char *); @@ -255,17 +255,17 @@ int fsname##_mount(struct mount *, const size_t *); \ int fsname##_start(struct mount *, int); \ int fsname##_unmount(struct mount *, int); \ -int fsname##_root(struct mount *, struct vnode **); \ +int fsname##_root(struct mount *, int, struct vnode **); \ int fsname##_quotactl(struct mount *, struct quotactl_args *); \ int fsname##_statvfs(struct mount *, struct statvfs *); \ int fsname##_sync(struct mount *, int, struct kauth_cred *); \ -int fsname##_vget(struct mount *, ino_t, struct vnode **); \ +int fsname##_vget(struct mount *, ino_t, int, struct vnode **); \ int fsname##_loadvnode(struct mount *, struct vnode *, \ const void *, size_t, const void **); \ int fsname##_newvnode(struct mount *, struct vnode *, \ struct vnode *, struct vattr *, kauth_cred_t, void *, \ size_t *, const void **); \ -int fsname##_fhtovp(struct mount *, struct fid *, struct vnode **); \ +int fsname##_fhtovp(struct mount *, struct fid *, int, struct vnode **);\ int fsname##_vptofh(struct vnode *, struct fid *, size_t *); \ void fsname##_init(void); \ void fsname##_reinit(void); \ Index: src/sys/ufs/chfs/chfs_vfsops.c diff -u src/sys/ufs/chfs/chfs_vfsops.c:1.20 src/sys/ufs/chfs/chfs_vfsops.c:1.21 --- src/sys/ufs/chfs/chfs_vfsops.c:1.20 Fri Dec 27 09:25:58 2019 +++ src/sys/ufs/chfs/chfs_vfsops.c Fri Jan 17 20:08:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vfsops.c,v 1.20 2019/12/27 09:25:58 msaitoh Exp $ */ +/* $NetBSD: chfs_vfsops.c,v 1.21 2020/01/17 20:08:10 ad Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -67,11 +67,11 @@ static int chfs_mount(struct mount *, const char *, void *, size_t *); static int chfs_unmount(struct mount *, int); -static int chfs_root(struct mount *, struct vnode **); +static int chfs_root(struct mount *, int, struct vnode **); static int chfs_loadvnode(struct mount *, struct vnode *, const void *, size_t, const void **); -static int chfs_vget(struct mount *, ino_t, struct vnode **); -static int chfs_fhtovp(struct mount *, struct fid *, struct vnode **); +static int chfs_vget(struct mount *, ino_t, int, struct vnode **); +static int chfs_fhtovp(struct mount *, struct fid *, int, struct vnode **); static int chfs_vptofh(struct vnode *, struct fid *, size_t *); static int chfs_start(struct mount *, int); static int chfs_statvfs(struct mount *, struct statvfs *); @@ -338,7 +338,7 @@ chfs_mountfs(struct vnode *devvp, struct ump->um_maxfilesize = 1048512 * 1024; /* Allocate the root vnode. */ - err = VFS_VGET(mp, CHFS_ROOTINO, &vp); + err = VFS_VGET(mp, CHFS_ROOTINO, LK_EXCLUSIVE, &vp); if (err) { dbg("error: %d while allocating root node\n", err); return err; @@ -449,12 +449,12 @@ chfs_unmount(struct mount *mp, int mntfl /* --------------------------------------------------------------------- */ static int -chfs_root(struct mount *mp, struct vnode **vpp) +chfs_root(struct mount *mp, int lktype, struct vnode **vpp) { struct vnode *vp; int error; - if ((error = VFS_VGET(mp, (ino_t)UFS_ROOTINO, &vp)) != 0) + if ((error = VFS_VGET(mp, (ino_t)UFS_ROOTINO, lktype, &vp)) != 0) return error; *vpp = vp; return 0; @@ -656,7 +656,7 @@ chfs_loadvnode(struct mount *mp, struct /* --------------------------------------------------------------------- */ static int -chfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) +chfs_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { int error; @@ -664,7 +664,7 @@ chfs_vget(struct mount *mp, ino_t ino, s if (error) return error; - error = vn_lock(*vpp, LK_EXCLUSIVE); + error = vn_lock(*vpp, lktype); if (error) { vrele(*vpp); *vpp = NULL; @@ -678,7 +678,7 @@ chfs_vget(struct mount *mp, ino_t ino, s static int -chfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) +chfs_fhtovp(struct mount *mp, struct fid *fhp, int lktype, struct vnode **vpp) { return ENODEV; } Index: src/sys/ufs/chfs/chfs_vnode.c diff -u src/sys/ufs/chfs/chfs_vnode.c:1.17 src/sys/ufs/chfs/chfs_vnode.c:1.18 --- src/sys/ufs/chfs/chfs_vnode.c:1.17 Wed Sep 18 18:46:00 2019 +++ src/sys/ufs/chfs/chfs_vnode.c Fri Jan 17 20:08:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vnode.c,v 1.17 2019/09/18 18:46:00 christos Exp $ */ +/* $NetBSD: chfs_vnode.c,v 1.18 2020/01/17 20:08:10 ad Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -210,7 +210,7 @@ chfs_makeinode(int mode, struct vnode *d /* number of vnode will be the new maximum */ vno = ++(chmp->chm_max_vno); - error = VFS_VGET(dvp->v_mount, vno, &vp); + error = VFS_VGET(dvp->v_mount, vno, LK_EXCLUSIVE, &vp); if (error) return (error); Index: src/sys/ufs/chfs/chfs_vnops.c diff -u src/sys/ufs/chfs/chfs_vnops.c:1.34 src/sys/ufs/chfs/chfs_vnops.c:1.35 --- src/sys/ufs/chfs/chfs_vnops.c:1.34 Mon Jun 17 17:14:56 2019 +++ src/sys/ufs/chfs/chfs_vnops.c Fri Jan 17 20:08:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vnops.c,v 1.34 2019/06/17 17:14:56 ryoon Exp $ */ +/* $NetBSD: chfs_vnops.c,v 1.35 2020/01/17 20:08:10 ad Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -106,7 +106,8 @@ chfs_lookup(void *v) if (cnp->cn_flags & ISDOTDOT) { VOP_UNLOCK(dvp); - error = VFS_VGET(dvp->v_mount, ip->chvc->pvno, vpp); + error = VFS_VGET(dvp->v_mount, ip->chvc->pvno, LK_EXCLUSIVE, + vpp); vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY); } else if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') { vref(dvp); @@ -147,7 +148,8 @@ chfs_lookup(void *v) dbg("vno@allocating new vnode: %llu\n", (unsigned long long)fd->vno); - error = VFS_VGET(dvp->v_mount, fd->vno, vpp); + error = VFS_VGET(dvp->v_mount, fd->vno, LK_EXCLUSIVE, + vpp); } } /* Store the result of this lookup in the cache. Avoid this if the @@ -1140,7 +1142,7 @@ chfs_rename(void *v) newparent, tcnp->cn_nameptr, tcnp->cn_namelen); vput(tvp); } - VFS_VGET(tdvp->v_mount, old->ino, &tvp); + VFS_VGET(tdvp->v_mount, old->ino, LK_EXCLUSIVE, &tvp); ip = VTOI(tvp); /* link new */ Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.214 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.215 --- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.214 Thu Jun 20 03:31:30 2019 +++ src/sys/ufs/ext2fs/ext2fs_vfsops.c Fri Jan 17 20:08:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_vfsops.c,v 1.214 2019/06/20 03:31:30 pgoyette Exp $ */ +/* $NetBSD: ext2fs_vfsops.c,v 1.215 2020/01/17 20:08:10 ad Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1994 @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.214 2019/06/20 03:31:30 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.215 2020/01/17 20:08:10 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -1186,7 +1186,7 @@ ext2fs_newvnode(struct mount *mp, struct * - check for an unallocated inode (i_mode == 0) */ int -ext2fs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) +ext2fs_fhtovp(struct mount *mp, struct fid *fhp, int lktype, struct vnode **vpp) { struct inode *ip; struct vnode *nvp; @@ -1203,7 +1203,7 @@ ext2fs_fhtovp(struct mount *mp, struct f ufh.ufid_ino >= fs->e2fs_ncg * fs->e2fs.e2fs_ipg) return ESTALE; - if ((error = VFS_VGET(mp, ufh.ufid_ino, &nvp)) != 0) { + if ((error = VFS_VGET(mp, ufh.ufid_ino, lktype, &nvp)) != 0) { *vpp = NULLVP; return error; } Index: src/sys/ufs/ffs/ffs_quota2.c diff -u src/sys/ufs/ffs/ffs_quota2.c:1.6 src/sys/ufs/ffs/ffs_quota2.c:1.7 --- src/sys/ufs/ffs/ffs_quota2.c:1.6 Thu Jul 7 06:55:44 2016 +++ src/sys/ufs/ffs/ffs_quota2.c Fri Jan 17 20:08:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_quota2.c,v 1.6 2016/07/07 06:55:44 msaitoh Exp $ */ +/* $NetBSD: ffs_quota2.c,v 1.7 2020/01/17 20:08:10 ad Exp $ */ /*- * Copyright (c) 2010 Manuel Bouyer * All rights reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ffs_quota2.c,v 1.6 2016/07/07 06:55:44 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_quota2.c,v 1.7 2020/01/17 20:08:10 ad Exp $"); #include <sys/param.h> #include <sys/kernel.h> @@ -78,7 +78,8 @@ ffs_quota2_mount(struct mount *mp) if (fs->fs_quota_flags & FS_Q2_DO_TYPE(USRQUOTA) && ump->um_quotas[USRQUOTA] == NULLVP) { - error = VFS_VGET(mp, fs->fs_quotafile[USRQUOTA], &vp); + error = VFS_VGET(mp, fs->fs_quotafile[USRQUOTA], + LK_EXCLUSIVE, &vp); if (error) { printf("%s: can't vget() user quota inode: %d\n", mp->mnt_stat.f_mntonname, error); @@ -93,7 +94,8 @@ ffs_quota2_mount(struct mount *mp) } if (fs->fs_quota_flags & FS_Q2_DO_TYPE(GRPQUOTA) && ump->um_quotas[GRPQUOTA] == NULLVP) { - error = VFS_VGET(mp, fs->fs_quotafile[GRPQUOTA], &vp); + error = VFS_VGET(mp, fs->fs_quotafile[GRPQUOTA], + LK_EXCLUSIVE, &vp); if (error) { vn_close(ump->um_quotas[USRQUOTA], FREAD|FWRITE, l->l_cred); Index: src/sys/ufs/ffs/ffs_snapshot.c diff -u src/sys/ufs/ffs/ffs_snapshot.c:1.149 src/sys/ufs/ffs/ffs_snapshot.c:1.150 --- src/sys/ufs/ffs/ffs_snapshot.c:1.149 Thu Jun 1 02:45:15 2017 +++ src/sys/ufs/ffs/ffs_snapshot.c Fri Jan 17 20:08:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_snapshot.c,v 1.149 2017/06/01 02:45:15 chs Exp $ */ +/* $NetBSD: ffs_snapshot.c,v 1.150 2020/01/17 20:08:10 ad Exp $ */ /* * Copyright 2000 Marshall Kirk McKusick. All Rights Reserved. @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.149 2017/06/01 02:45:15 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.150 2020/01/17 20:08:10 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -677,8 +677,8 @@ snapshot_expunge(struct mount *mp, struc */ if ((fs->fs_flags & FS_DOWAPBL) && fs->fs_journal_location == UFS_WAPBL_JOURNALLOC_IN_FILESYSTEM) { - error = VFS_VGET(mp, - fs->fs_journallocs[UFS_WAPBL_INFS_INO], &logvp); + error = VFS_VGET(mp, fs->fs_journallocs[UFS_WAPBL_INFS_INO], + LK_EXCLUSIVE, &logvp); if (error) goto out; } @@ -1766,7 +1766,7 @@ ffs_snapshot_mount(struct mount *mp) if (fs->fs_snapinum[snaploc] == 0) break; if ((error = VFS_VGET(mp, fs->fs_snapinum[snaploc], - &vp)) != 0) { + LK_EXCLUSIVE, &vp)) != 0) { printf("ffs_snapshot_mount: vget failed %d\n", error); continue; } Index: src/sys/ufs/ffs/ffs_vfsops.c diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.362 src/sys/ufs/ffs/ffs_vfsops.c:1.363 --- src/sys/ufs/ffs/ffs_vfsops.c:1.362 Thu Jun 20 03:31:30 2019 +++ src/sys/ufs/ffs/ffs_vfsops.c Fri Jan 17 20:08:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_vfsops.c,v 1.362 2019/06/20 03:31:30 pgoyette Exp $ */ +/* $NetBSD: ffs_vfsops.c,v 1.363 2020/01/17 20:08:10 ad Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.362 2019/06/20 03:31:30 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.363 2020/01/17 20:08:10 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -2218,7 +2218,7 @@ ffs_newvnode(struct mount *mp, struct vn * those rights via. exflagsp and credanonp */ int -ffs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) +ffs_fhtovp(struct mount *mp, struct fid *fhp, int lktype, struct vnode **vpp) { struct ufid ufh; int error; @@ -2230,7 +2230,7 @@ ffs_fhtovp(struct mount *mp, struct fid if ((error = ffs_checkrange(mp, ufh.ufid_ino)) != 0) return error; - return (ufs_fhtovp(mp, &ufh, vpp)); + return (ufs_fhtovp(mp, &ufh, lktype, vpp)); } /* Index: src/sys/ufs/ffs/ffs_wapbl.c diff -u src/sys/ufs/ffs/ffs_wapbl.c:1.44 src/sys/ufs/ffs/ffs_wapbl.c:1.45 --- src/sys/ufs/ffs/ffs_wapbl.c:1.44 Tue Jan 1 10:06:55 2019 +++ src/sys/ufs/ffs/ffs_wapbl.c Fri Jan 17 20:08:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_wapbl.c,v 1.44 2019/01/01 10:06:55 hannken Exp $ */ +/* $NetBSD: ffs_wapbl.c,v 1.45 2020/01/17 20:08:10 ad Exp $ */ /*- * Copyright (c) 2003,2006,2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.44 2019/01/01 10:06:55 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_wapbl.c,v 1.45 2020/01/17 20:08:10 ad Exp $"); #define WAPBL_INTERNAL @@ -124,7 +124,8 @@ ffs_wapbl_replay_finish(struct mount *mp for (i = 0; i < wr->wr_inodescnt; i++) { struct vnode *vp; struct inode *ip; - error = VFS_VGET(mp, wr->wr_inodes[i].wr_inumber, &vp); + error = VFS_VGET(mp, wr->wr_inodes[i].wr_inumber, + LK_EXCLUSIVE, &vp); if (error) { printf("%s: %s: unable to cleanup inode %" PRIu32 "\n", __func__, VFSTOUFS(mp)->um_fs->fs_fsmnt, @@ -254,7 +255,7 @@ wapbl_remove_log(struct mount *mp) /* if no existing log inode, just clear all fields and bail */ if (log_ino == 0) goto done; - error = VFS_VGET(mp, log_ino, &vp); + error = VFS_VGET(mp, log_ino, LK_EXCLUSIVE, &vp); if (error != 0) { printf("%s: %s: vget failed %d\n", __func__, fs->fs_fsmnt, error); @@ -651,7 +652,7 @@ wapbl_create_infs_log(struct mount *mp, struct inode *ip; int error; - if ((error = VFS_ROOT(mp, &rvp)) != 0) + if ((error = VFS_ROOT(mp, LK_EXCLUSIVE, &rvp)) != 0) return error; vattr_null(&va); Index: src/sys/ufs/lfs/lfs_alloc.c diff -u src/sys/ufs/lfs/lfs_alloc.c:1.137 src/sys/ufs/lfs/lfs_alloc.c:1.138 --- src/sys/ufs/lfs/lfs_alloc.c:1.137 Sat Aug 19 11:27:42 2017 +++ src/sys/ufs/lfs/lfs_alloc.c Fri Jan 17 20:08:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_alloc.c,v 1.137 2017/08/19 11:27:42 maya Exp $ */ +/* $NetBSD: lfs_alloc.c,v 1.138 2020/01/17 20:08:10 ad Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.137 2017/08/19 11:27:42 maya Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_alloc.c,v 1.138 2020/01/17 20:08:10 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_quota.h" @@ -758,7 +758,8 @@ lfs_order_freelist(struct lfs *fs) * happens to such files currently. -- dholland 20160806 */ if (lfs_if_getnextfree(fs, ifp) == LFS_ORPHAN_NEXTFREE && - VFS_VGET(fs->lfs_ivnode->v_mount, ino, &vp) == 0) { + VFS_VGET(fs->lfs_ivnode->v_mount, ino, LK_EXCLUSIVE, &vp) + == 0) { unsigned segno; /* get the segment the inode in on disk */ Index: src/sys/ufs/lfs/lfs_rfw.c diff -u src/sys/ufs/lfs/lfs_rfw.c:1.34 src/sys/ufs/lfs/lfs_rfw.c:1.35 --- src/sys/ufs/lfs/lfs_rfw.c:1.34 Tue Jan 1 10:06:55 2019 +++ src/sys/ufs/lfs/lfs_rfw.c Fri Jan 17 20:08:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_rfw.c,v 1.34 2019/01/01 10:06:55 hannken Exp $ */ +/* $NetBSD: lfs_rfw.c,v 1.35 2020/01/17 20:08:10 ad Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: lfs_rfw.c,v 1.34 2019/01/01 10:06:55 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_rfw.c,v 1.35 2020/01/17 20:08:10 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_quota.h" @@ -113,7 +113,7 @@ lfs_rf_valloc(struct lfs *fs, ino_t ino, * we don't have to do anything else. If the version number is wrong, * take appropriate action. */ - error = VFS_VGET(fs->lfs_ivnode->v_mount, ino, &vp); + error = VFS_VGET(fs->lfs_ivnode->v_mount, ino, LK_EXCLUSIVE, &vp); if (error == 0) { DLOG((DLOG_RF, "lfs_rf_valloc[1]: ino %d vp %p\n", ino, vp)); Index: src/sys/ufs/lfs/lfs_vfsops.c diff -u src/sys/ufs/lfs/lfs_vfsops.c:1.368 src/sys/ufs/lfs/lfs_vfsops.c:1.369 --- src/sys/ufs/lfs/lfs_vfsops.c:1.368 Wed Jan 15 17:55:44 2020 +++ src/sys/ufs/lfs/lfs_vfsops.c Fri Jan 17 20:08:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_vfsops.c,v 1.368 2020/01/15 17:55:44 ad Exp $ */ +/* $NetBSD: lfs_vfsops.c,v 1.369 2020/01/17 20:08:10 ad Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007 @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.368 2020/01/15 17:55:44 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.369 2020/01/17 20:08:10 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_lfs.h" @@ -1162,7 +1162,7 @@ lfs_mountfs(struct vnode *devvp, struct * artificially increment the reference count and keep a pointer * to it in the incore copy of the superblock. */ - if ((error = VFS_VGET(mp, LFS_IFILE_INUM, &vp)) != 0) { + if ((error = VFS_VGET(mp, LFS_IFILE_INUM, LK_EXCLUSIVE, &vp)) != 0) { DLOG((DLOG_MOUNT, "lfs_mountfs: ifile vget failed, error=%d\n", error)); goto out; } @@ -1531,14 +1531,14 @@ lfs_sync(struct mount *mp, int waitfor, * Detection and handling of mount points must be done by the calling routine. */ int -lfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) +lfs_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { int error; error = vcache_get(mp, &ino, sizeof(ino), vpp); if (error) return error; - error = vn_lock(*vpp, LK_EXCLUSIVE); + error = vn_lock(*vpp, lktype); if (error) { vrele(*vpp); *vpp = NULL; @@ -1854,7 +1854,7 @@ lfs_newvnode(struct mount *mp, struct vn * File handle to vnode */ int -lfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp) +lfs_fhtovp(struct mount *mp, struct fid *fhp, int lktype, struct vnode **vpp) { struct lfid lfh; struct lfs *fs; @@ -1875,7 +1875,7 @@ lfs_fhtovp(struct mount *mp, struct fid lfs_sb_getcleansz(fs) - lfs_sb_getsegtabsz(fs)) * lfs_sb_getifpb(fs)) return ESTALE; - return (ulfs_fhtovp(mp, &lfh.lfid_ufid, vpp)); + return (ulfs_fhtovp(mp, &lfh.lfid_ufid, lktype, vpp)); } /* Index: src/sys/ufs/lfs/ulfs_extattr.c diff -u src/sys/ufs/lfs/ulfs_extattr.c:1.14 src/sys/ufs/lfs/ulfs_extattr.c:1.15 --- src/sys/ufs/lfs/ulfs_extattr.c:1.14 Wed Nov 9 05:44:42 2016 +++ src/sys/ufs/lfs/ulfs_extattr.c Fri Jan 17 20:08:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ulfs_extattr.c,v 1.14 2016/11/09 05:44:42 dholland Exp $ */ +/* $NetBSD: ulfs_extattr.c,v 1.15 2020/01/17 20:08:10 ad Exp $ */ /* from NetBSD: ulfs_extattr.c,v 1.48 2016/11/09 05:08:35 dholland Exp */ /*- @@ -49,7 +49,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ulfs_extattr.c,v 1.14 2016/11/09 05:44:42 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ulfs_extattr.c,v 1.15 2020/01/17 20:08:10 ad Exp $"); #ifdef _KERNEL_OPT #include "opt_lfs.h" @@ -675,7 +675,7 @@ ulfs_extattr_autostart(struct mount *mp, * Does ULFS_EXTATTR_FSROOTSUBDIR exist off the filesystem root? * If so, automatically start EA's. */ - error = VFS_ROOT(mp, &rvp); + error = VFS_ROOT(mp, LK_EXCLUSIVE, &rvp); if (error) { printf("ulfs_extattr_autostart.VFS_ROOT() returned %d\n", error); Index: src/sys/ufs/lfs/ulfs_extern.h diff -u src/sys/ufs/lfs/ulfs_extern.h:1.24 src/sys/ufs/lfs/ulfs_extern.h:1.25 --- src/sys/ufs/lfs/ulfs_extern.h:1.24 Mon Jun 20 03:36:09 2016 +++ src/sys/ufs/lfs/ulfs_extern.h Fri Jan 17 20:08:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ulfs_extern.h,v 1.24 2016/06/20 03:36:09 dholland Exp $ */ +/* $NetBSD: ulfs_extern.h,v 1.25 2020/01/17 20:08:10 ad Exp $ */ /* from NetBSD: ufs_extern.h,v 1.79 2015/03/27 17:27:56 riastradh Exp */ /*- @@ -147,9 +147,9 @@ void ulfs_init(void); void ulfs_reinit(void); void ulfs_done(void); int ulfs_start(struct mount *, int); -int ulfs_root(struct mount *, struct vnode **); +int ulfs_root(struct mount *, int, struct vnode **); int ulfs_quotactl(struct mount *, struct quotactl_args *); -int ulfs_fhtovp(struct mount *, struct ulfs_ufid *, struct vnode **); +int ulfs_fhtovp(struct mount *, struct ulfs_ufid *, int, struct vnode **); /* ulfs_vnops.c */ void ulfs_vinit(struct mount *, int (**)(void *), Index: src/sys/ufs/lfs/ulfs_quota2.c diff -u src/sys/ufs/lfs/ulfs_quota2.c:1.31 src/sys/ufs/lfs/ulfs_quota2.c:1.32 --- src/sys/ufs/lfs/ulfs_quota2.c:1.31 Sat Jun 10 05:29:36 2017 +++ src/sys/ufs/lfs/ulfs_quota2.c Fri Jan 17 20:08:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ulfs_quota2.c,v 1.31 2017/06/10 05:29:36 maya Exp $ */ +/* $NetBSD: ulfs_quota2.c,v 1.32 2020/01/17 20:08:10 ad Exp $ */ /* from NetBSD: ufs_quota2.c,v 1.40 2015/03/28 19:24:05 maxv Exp Exp */ /* from NetBSD: ffs_quota2.c,v 1.5 2015/02/22 14:12:48 maxv Exp */ @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ulfs_quota2.c,v 1.31 2017/06/10 05:29:36 maya Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ulfs_quota2.c,v 1.32 2020/01/17 20:08:10 ad Exp $"); #include <sys/buf.h> #include <sys/param.h> @@ -1598,7 +1598,8 @@ lfs_quota2_mount(struct mount *mp) if (fs->lfs_quota_flags & FS_Q2_DO_TYPE(ULFS_USRQUOTA) && ump->um_quotas[ULFS_USRQUOTA] == NULLVP) { - error = VFS_VGET(mp, fs->lfs_quotaino[ULFS_USRQUOTA], &vp); + error = VFS_VGET(mp, fs->lfs_quotaino[ULFS_USRQUOTA], + LK_EXCLUSIVE, &vp); if (error) { printf("%s: can't vget() user quota inode: %d\n", mp->mnt_stat.f_mntonname, error); @@ -1613,7 +1614,8 @@ lfs_quota2_mount(struct mount *mp) } if (fs->lfs_quota_flags & FS_Q2_DO_TYPE(ULFS_GRPQUOTA) && ump->um_quotas[ULFS_GRPQUOTA] == NULLVP) { - error = VFS_VGET(mp, fs->lfs_quotaino[ULFS_GRPQUOTA], &vp); + error = VFS_VGET(mp, fs->lfs_quotaino[ULFS_GRPQUOTA], + LK_EXCLUSIVE, &vp); if (error) { vn_close(ump->um_quotas[ULFS_USRQUOTA], FREAD|FWRITE, l->l_cred); Index: src/sys/ufs/lfs/ulfs_vfsops.c diff -u src/sys/ufs/lfs/ulfs_vfsops.c:1.15 src/sys/ufs/lfs/ulfs_vfsops.c:1.16 --- src/sys/ufs/lfs/ulfs_vfsops.c:1.15 Sun Dec 22 19:47:35 2019 +++ src/sys/ufs/lfs/ulfs_vfsops.c Fri Jan 17 20:08:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ulfs_vfsops.c,v 1.15 2019/12/22 19:47:35 ad Exp $ */ +/* $NetBSD: ulfs_vfsops.c,v 1.16 2020/01/17 20:08:10 ad Exp $ */ /* from NetBSD: ufs_vfsops.c,v 1.54 2015/03/17 09:39:29 hannken Exp */ /* @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ulfs_vfsops.c,v 1.15 2019/12/22 19:47:35 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ulfs_vfsops.c,v 1.16 2020/01/17 20:08:10 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_lfs.h" @@ -85,12 +85,12 @@ ulfs_start(struct mount *mp, int flags) * Return the root of a filesystem. */ int -ulfs_root(struct mount *mp, struct vnode **vpp) +ulfs_root(struct mount *mp, int lktype, struct vnode **vpp) { struct vnode *nvp; int error; - if ((error = VFS_VGET(mp, (ino_t)ULFS_ROOTINO, &nvp)) != 0) + if ((error = VFS_VGET(mp, (ino_t)ULFS_ROOTINO, lktype, &nvp)) != 0) return (error); *vpp = nvp; return (0); @@ -212,13 +212,14 @@ ulfs_quotactl(struct mount *mp, struct q * filesystem has validated the file handle. */ int -ulfs_fhtovp(struct mount *mp, struct ulfs_ufid *ufhp, struct vnode **vpp) +ulfs_fhtovp(struct mount *mp, struct ulfs_ufid *ufhp, int lktype, + struct vnode **vpp) { struct vnode *nvp; struct inode *ip; int error; - if ((error = VFS_VGET(mp, ufhp->ufid_ino, &nvp)) != 0) { + if ((error = VFS_VGET(mp, ufhp->ufid_ino, lktype, &nvp)) != 0) { if (error == ENOENT) error = ESTALE; *vpp = NULLVP; Index: src/sys/ufs/ufs/ufs_extattr.c diff -u src/sys/ufs/ufs/ufs_extattr.c:1.50 src/sys/ufs/ufs/ufs_extattr.c:1.51 --- src/sys/ufs/ufs/ufs_extattr.c:1.50 Mon Aug 19 14:09:12 2019 +++ src/sys/ufs/ufs/ufs_extattr.c Fri Jan 17 20:08:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_extattr.c,v 1.50 2019/08/19 14:09:12 christos Exp $ */ +/* $NetBSD: ufs_extattr.c,v 1.51 2020/01/17 20:08:10 ad Exp $ */ /*- * Copyright (c) 1999-2002 Robert N. M. Watson @@ -48,7 +48,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.50 2019/08/19 14:09:12 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_extattr.c,v 1.51 2020/01/17 20:08:10 ad Exp $"); #ifdef _KERNEL_OPT #include "opt_ffs.h" @@ -694,7 +694,7 @@ ufs_extattr_autostart(struct mount *mp, * Does UFS_EXTATTR_FSROOTSUBDIR exist off the filesystem root? * If so, automatically start EA's. */ - error = VFS_ROOT(mp, &rvp); + error = VFS_ROOT(mp, LK_EXCLUSIVE, &rvp); if (error) { printf("%s: VFS_ROOT() (%d)\n", __func__, error); return error; Index: src/sys/ufs/ufs/ufs_extern.h diff -u src/sys/ufs/ufs/ufs_extern.h:1.83 src/sys/ufs/ufs/ufs_extern.h:1.84 --- src/sys/ufs/ufs/ufs_extern.h:1.83 Fri Oct 28 20:38:12 2016 +++ src/sys/ufs/ufs/ufs_extern.h Fri Jan 17 20:08:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_extern.h,v 1.83 2016/10/28 20:38:12 jdolecek Exp $ */ +/* $NetBSD: ufs_extern.h,v 1.84 2020/01/17 20:08:10 ad Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -176,10 +176,10 @@ void ufs_init(void); void ufs_reinit(void); void ufs_done(void); int ufs_start(struct mount *, int); -int ufs_root(struct mount *, struct vnode **); -int ufs_vget(struct mount *, ino_t, struct vnode **); +int ufs_root(struct mount *, int, struct vnode **); +int ufs_vget(struct mount *, ino_t, int, struct vnode **); int ufs_quotactl(struct mount *, struct quotactl_args *); -int ufs_fhtovp(struct mount *, struct ufid *, struct vnode **); +int ufs_fhtovp(struct mount *, struct ufid *, int, struct vnode **); /* ufs_vnops.c */ void ufs_vinit(struct mount *, int (**)(void *), Index: src/sys/ufs/ufs/ufs_vfsops.c diff -u src/sys/ufs/ufs/ufs_vfsops.c:1.58 src/sys/ufs/ufs/ufs_vfsops.c:1.59 --- src/sys/ufs/ufs/ufs_vfsops.c:1.58 Sun Dec 22 19:47:35 2019 +++ src/sys/ufs/ufs/ufs_vfsops.c Fri Jan 17 20:08:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_vfsops.c,v 1.58 2019/12/22 19:47:35 ad Exp $ */ +/* $NetBSD: ufs_vfsops.c,v 1.59 2020/01/17 20:08:10 ad Exp $ */ /* * Copyright (c) 1991, 1993, 1994 @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ufs_vfsops.c,v 1.58 2019/12/22 19:47:35 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_vfsops.c,v 1.59 2020/01/17 20:08:10 ad Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -86,12 +86,12 @@ ufs_start(struct mount *mp, int flags) * Return the root of a filesystem. */ int -ufs_root(struct mount *mp, struct vnode **vpp) +ufs_root(struct mount *mp, int lktype, struct vnode **vpp) { struct vnode *nvp; int error; - if ((error = VFS_VGET(mp, (ino_t)UFS_ROOTINO, &nvp)) != 0) + if ((error = VFS_VGET(mp, (ino_t)UFS_ROOTINO, lktype, &nvp)) != 0) return (error); *vpp = nvp; return (0); @@ -101,14 +101,14 @@ ufs_root(struct mount *mp, struct vnode * Look up and return a vnode/inode pair by inode number. */ int -ufs_vget(struct mount *mp, ino_t ino, struct vnode **vpp) +ufs_vget(struct mount *mp, ino_t ino, int lktype, struct vnode **vpp) { int error; error = vcache_get(mp, &ino, sizeof(ino), vpp); if (error) return error; - error = vn_lock(*vpp, LK_EXCLUSIVE); + error = vn_lock(*vpp, lktype); if (error) { vrele(*vpp); *vpp = NULL; @@ -233,13 +233,13 @@ ufs_quotactl(struct mount *mp, struct qu * filesystem has validated the file handle. */ int -ufs_fhtovp(struct mount *mp, struct ufid *ufhp, struct vnode **vpp) +ufs_fhtovp(struct mount *mp, struct ufid *ufhp, int lktype, struct vnode **vpp) { struct vnode *nvp; struct inode *ip; int error; - if ((error = VFS_VGET(mp, ufhp->ufid_ino, &nvp)) != 0) { + if ((error = VFS_VGET(mp, ufhp->ufid_ino, lktype, &nvp)) != 0) { if (error == ENOENT) error = ESTALE; *vpp = NULLVP;