From 8406a6eeed77aa730d9497b8034c19eb9e9d24f6 Mon Sep 17 00:00:00 2001 From: alfred Date: Mon, 12 Jul 2004 08:14:09 +0000 Subject: [PATCH] Make VFS_ROOT() and vflush() take a thread argument. This is to allow filesystems to decide based on the passed thread which vnode to return. Several filesystems used curthread, they now use the passed thread. --- sys/coda/coda_vfsops.c | 5 +++-- sys/fs/cd9660/cd9660_vfsops.c | 5 +++-- sys/fs/coda/coda_vfsops.c | 5 +++-- sys/fs/devfs/devfs_vfsops.c | 9 ++++----- sys/fs/fdescfs/fdesc.h | 4 ++-- sys/fs/fdescfs/fdesc_vfsops.c | 5 +++-- sys/fs/hpfs/hpfs_vfsops.c | 7 ++++--- sys/fs/msdosfs/msdosfs_vfsops.c | 17 ++++++++++------- sys/fs/ntfs/ntfs_vfsops.c | 9 +++++---- sys/fs/nullfs/null_vfsops.c | 6 +++--- sys/fs/nwfs/nwfs_vfsops.c | 7 +++---- sys/fs/portalfs/portal_vfsops.c | 5 +++-- sys/fs/pseudofs/pseudofs.c | 4 ++-- sys/fs/pseudofs/pseudofs.h | 3 ++- sys/fs/smbfs/smbfs_vfsops.c | 6 +++--- sys/fs/udf/udf_vfsops.c | 4 ++-- sys/fs/umapfs/umap_vfsops.c | 5 +++-- sys/fs/unionfs/union_vfsops.c | 5 +++-- sys/fs/unionfs/union_vnops.c | 2 +- sys/gnu/ext2fs/ext2_vfsops.c | 5 +++-- sys/gnu/fs/ext2fs/ext2_vfsops.c | 5 +++-- sys/isofs/cd9660/cd9660_vfsops.c | 5 +++-- sys/kern/init_main.c | 2 +- sys/kern/vfs_default.c | 3 ++- sys/kern/vfs_export.c | 2 +- sys/kern/vfs_extattr.c | 2 +- sys/kern/vfs_lookup.c | 2 +- sys/kern/vfs_mount.c | 8 ++++---- sys/kern/vfs_subr.c | 8 ++++---- sys/kern/vfs_syscalls.c | 2 +- sys/nfs4client/nfs4_vfsops.c | 6 +++--- sys/nfsclient/nfs_vfsops.c | 4 ++-- sys/sys/mount.h | 4 ++-- sys/sys/vnode.h | 2 +- sys/ufs/ffs/ffs_vfsops.c | 6 +++--- sys/ufs/ufs/ufs_extattr.c | 2 +- sys/ufs/ufs/ufs_vfsops.c | 3 ++- 37 files changed, 100 insertions(+), 84 deletions(-) diff --git a/sys/coda/coda_vfsops.c b/sys/coda/coda_vfsops.c index e7290e770807..09025d57b731 100644 --- a/sys/coda/coda_vfsops.c +++ b/sys/coda/coda_vfsops.c @@ -252,7 +252,7 @@ coda_unmount(vfsp, mntflags, td) active = coda_kill(vfsp, NOT_DOWNCALL); ASSERT_VOP_LOCKED(mi->mi_rootvp, "coda_unmount"); mi->mi_rootvp->v_vflag &= ~VV_ROOT; - error = vflush(mi->mi_vfsp, 0, FORCECLOSE); + error = vflush(mi->mi_vfsp, 0, FORCECLOSE, td); #ifdef CODA_VERBOSE printf("coda_unmount: active = %d, vflush active %d\n", active, error); #endif @@ -280,9 +280,10 @@ coda_unmount(vfsp, mntflags, td) * find root of cfs */ int -coda_root(vfsp, vpp) +coda_root(vfsp, vpp, td) struct mount *vfsp; struct vnode **vpp; + struct thread *td; { struct coda_mntinfo *mi = vftomi(vfsp); struct vnode **result; diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c index e91f4b149e93..10e3bc48c65d 100644 --- a/sys/fs/cd9660/cd9660_vfsops.c +++ b/sys/fs/cd9660/cd9660_vfsops.c @@ -554,7 +554,7 @@ cd9660_unmount(mp, mntflags, td) if (mntinvalbuf(mp)) return EBUSY; #endif - if ((error = vflush(mp, 0, flags))) + if ((error = vflush(mp, 0, flags, td))) return (error); isomp = VFSTOISOFS(mp); @@ -578,9 +578,10 @@ cd9660_unmount(mp, mntflags, td) * Return root of a filesystem */ static int -cd9660_root(mp, vpp) +cd9660_root(mp, vpp, td) struct mount *mp; struct vnode **vpp; + struct thread *td; { struct iso_mnt *imp = VFSTOISOFS(mp); struct iso_directory_record *dp = diff --git a/sys/fs/coda/coda_vfsops.c b/sys/fs/coda/coda_vfsops.c index e7290e770807..09025d57b731 100644 --- a/sys/fs/coda/coda_vfsops.c +++ b/sys/fs/coda/coda_vfsops.c @@ -252,7 +252,7 @@ coda_unmount(vfsp, mntflags, td) active = coda_kill(vfsp, NOT_DOWNCALL); ASSERT_VOP_LOCKED(mi->mi_rootvp, "coda_unmount"); mi->mi_rootvp->v_vflag &= ~VV_ROOT; - error = vflush(mi->mi_vfsp, 0, FORCECLOSE); + error = vflush(mi->mi_vfsp, 0, FORCECLOSE, td); #ifdef CODA_VERBOSE printf("coda_unmount: active = %d, vflush active %d\n", active, error); #endif @@ -280,9 +280,10 @@ coda_unmount(vfsp, mntflags, td) * find root of cfs */ int -coda_root(vfsp, vpp) +coda_root(vfsp, vpp, td) struct mount *vfsp; struct vnode **vpp; + struct thread *td; { struct coda_mntinfo *mi = vftomi(vfsp); struct vnode **result; diff --git a/sys/fs/devfs/devfs_vfsops.c b/sys/fs/devfs/devfs_vfsops.c index a10efa271f8f..f23d6603facc 100644 --- a/sys/fs/devfs/devfs_vfsops.c +++ b/sys/fs/devfs/devfs_vfsops.c @@ -101,7 +101,7 @@ devfs_nmount(mp, ndp, td) fmp->dm_basedir = fmp->dm_rootdir; devfs_rules_newmount(fmp, td); - error = devfs_root(mp, &rvp); + error = devfs_root(mp, &rvp, td); if (error) { lockdestroy(&fmp->dm_lock); FREE(fmp, M_DEVFS); @@ -130,7 +130,7 @@ devfs_unmount(mp, mntflags, td) if (mntflags & MNT_FORCE) flags |= FORCECLOSE; /* There is 1 extra root vnode reference from devfs_mount(). */ - error = vflush(mp, 1, flags); + error = vflush(mp, 1, flags, td); if (error) return (error); devfs_purge(fmp->dm_rootdir); @@ -144,16 +144,15 @@ devfs_unmount(mp, mntflags, td) /* Return locked reference to root. */ static int -devfs_root(mp, vpp) +devfs_root(mp, vpp, td) struct mount *mp; struct vnode **vpp; + struct thread *td; { int error; - struct thread *td; struct vnode *vp; struct devfs_mount *dmp; - td = curthread; /* XXX */ dmp = VFSTODEVFS(mp); error = devfs_allocv(dmp->dm_rootdir, mp, &vp, td); if (error) diff --git a/sys/fs/fdescfs/fdesc.h b/sys/fs/fdescfs/fdesc.h index a6ffb51b35a5..dfe4c6bd1e53 100644 --- a/sys/fs/fdescfs/fdesc.h +++ b/sys/fs/fdescfs/fdesc.h @@ -58,8 +58,8 @@ struct fdescnode { #define VFSTOFDESC(mp) ((struct fdescmount *)((mp)->mnt_data)) #define VTOFDESC(vp) ((struct fdescnode *)(vp)->v_data) -extern int fdesc_init(struct vfsconf *); -extern int fdesc_root(struct mount *, struct vnode **); +extern vfs_init_t fdesc_init; +extern vfs_root_t fdesc_root; extern int fdesc_allocvp(fdntype, int, struct mount *, struct vnode **, struct thread *); #endif /* _KERNEL */ diff --git a/sys/fs/fdescfs/fdesc_vfsops.c b/sys/fs/fdescfs/fdesc_vfsops.c index 18e7ccfcc64d..c6514a9dd0c5 100644 --- a/sys/fs/fdescfs/fdesc_vfsops.c +++ b/sys/fs/fdescfs/fdesc_vfsops.c @@ -117,7 +117,7 @@ fdesc_unmount(mp, mntflags, td) * There is 1 extra root vnode reference corresponding * to f_root. */ - if ((error = vflush(mp, 1, flags)) != 0) + if ((error = vflush(mp, 1, flags, td)) != 0) return (error); /* @@ -130,9 +130,10 @@ fdesc_unmount(mp, mntflags, td) } int -fdesc_root(mp, vpp) +fdesc_root(mp, vpp, td) struct mount *mp; struct vnode **vpp; + struct thread *td; { struct thread *td = curthread; /* XXX */ struct vnode *vp; diff --git a/sys/fs/hpfs/hpfs_vfsops.c b/sys/fs/hpfs/hpfs_vfsops.c index e9059d4e6413..1459ed8b1b71 100644 --- a/sys/fs/hpfs/hpfs_vfsops.c +++ b/sys/fs/hpfs/hpfs_vfsops.c @@ -300,7 +300,7 @@ hpfs_mountfs(devvp, mp, argsp, td) goto failed; } - error = hpfs_root(mp, &vp); + error = hpfs_root(mp, &vp, td); if (error) { hpfs_cpdeinit(hpmp); hpfs_bmdeinit(hpmp); @@ -344,7 +344,7 @@ hpfs_unmount( dprintf(("hpfs_unmount: vflushing...\n")); - error = vflush(mp, 0, flags); + error = vflush(mp, 0, flags, td); if (error) { printf("hpfs_unmount: vflush failed: %d\n",error); return (error); @@ -371,7 +371,8 @@ hpfs_unmount( static int hpfs_root( struct mount *mp, - struct vnode **vpp ) + struct vnode **vpp, + struct thread *td ) { int error = 0; struct hpfsmount *hpmp = VFSTOHPFS(mp); diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c index 013ec7a722e5..ee6c507cebba 100644 --- a/sys/fs/msdosfs/msdosfs_vfsops.c +++ b/sys/fs/msdosfs/msdosfs_vfsops.c @@ -91,7 +91,8 @@ static MALLOC_DEFINE(M_MSDOSFSFAT, "MSDOSFS FAT", "MSDOSFS file allocation table struct iconv_functions *msdosfs_iconv = NULL; -static int update_mp(struct mount *mp, struct msdosfs_args *argp); +static int update_mp(struct mount *mp, struct msdosfs_args *argp, + struct thread *td); static int mountmsdosfs(struct vnode *devvp, struct mount *mp, struct thread *td, struct msdosfs_args *argp); static vfs_fhtovp_t msdosfs_fhtovp; @@ -103,9 +104,10 @@ static vfs_unmount_t msdosfs_unmount; static vfs_vptofh_t msdosfs_vptofh; static int -update_mp(mp, argp) +update_mp(mp, argp, td) struct mount *mp; struct msdosfs_args *argp; + struct thread *td; { struct msdosfsmount *pmp = VFSTOMSDOSFS(mp); int error; @@ -139,7 +141,7 @@ update_mp(mp, argp) if (FAT32(pmp)) pmp->pm_flags |= MSDOSFSMNT_LONGNAME; else { - if ((error = msdosfs_root(mp, &rootvp)) != 0) + if ((error = msdosfs_root(mp, &rootvp, td)) != 0) return error; pmp->pm_flags |= findwin95(VTODE(rootvp)) ? MSDOSFSMNT_LONGNAME @@ -187,7 +189,7 @@ msdosfs_mount(mp, path, data, ndp, td) flags = WRITECLOSE; if (mp->mnt_flag & MNT_FORCE) flags |= FORCECLOSE; - error = vflush(mp, 0, flags); + error = vflush(mp, 0, flags, td); } if (!error && (mp->mnt_flag & MNT_RELOAD)) /* not yet implemented */ @@ -282,7 +284,7 @@ msdosfs_mount(mp, path, data, ndp, td) return (error); } - error = update_mp(mp, &args); + error = update_mp(mp, &args, td); if (error) { msdosfs_unmount(mp, MNT_FORCE, td); return error; @@ -674,7 +676,7 @@ msdosfs_unmount(mp, mntflags, td) flags = 0; if (mntflags & MNT_FORCE) flags |= FORCECLOSE; - error = vflush(mp, 0, flags); + error = vflush(mp, 0, flags, td); if (error) return error; pmp = VFSTOMSDOSFS(mp); @@ -741,9 +743,10 @@ msdosfs_unmount(mp, mntflags, td) } static int -msdosfs_root(mp, vpp) +msdosfs_root(mp, vpp, td) struct mount *mp; struct vnode **vpp; + struct thread *td; { struct msdosfsmount *pmp = VFSTOMSDOSFS(mp); struct denode *ndep; diff --git a/sys/fs/ntfs/ntfs_vfsops.c b/sys/fs/ntfs/ntfs_vfsops.c index 924f06f319da..7db1a13e09d0 100644 --- a/sys/fs/ntfs/ntfs_vfsops.c +++ b/sys/fs/ntfs/ntfs_vfsops.c @@ -457,7 +457,7 @@ ntfs_mountfs(devvp, mp, argsp, td) for(i=0;intm_sysvn[i]) vrele(ntmp->ntm_sysvn[i]); - if (vflush(mp, 0, 0)) + if (vflush(mp, 0, 0, td)) dprintf(("ntfs_mountfs: vflush failed\n")); out: @@ -487,7 +487,7 @@ ntfs_unmount( flags |= FORCECLOSE; dprintf(("ntfs_unmount: vflushing...\n")); - error = vflush(mp, 0, flags | SKIPSYSTEM); + error = vflush(mp, 0, flags | SKIPSYSTEM, td); if (error) { printf("ntfs_unmount: vflush failed: %d\n",error); return (error); @@ -503,7 +503,7 @@ ntfs_unmount( if(ntmp->ntm_sysvn[i]) vrele(ntmp->ntm_sysvn[i]); /* vflush system vnodes */ - error = vflush(mp, 0, flags); + error = vflush(mp, 0, flags, td); if (error) printf("ntfs_unmount: vflush failed(sysnodes): %d\n",error); @@ -538,7 +538,8 @@ ntfs_unmount( static int ntfs_root( struct mount *mp, - struct vnode **vpp ) + struct vnode **vpp, + struct thread *td ) { struct vnode *nvp; int error = 0; diff --git a/sys/fs/nullfs/null_vfsops.c b/sys/fs/nullfs/null_vfsops.c index 0ecfda238185..25c16518cf77 100644 --- a/sys/fs/nullfs/null_vfsops.c +++ b/sys/fs/nullfs/null_vfsops.c @@ -228,7 +228,7 @@ nullfs_unmount(mp, mntflags, td) flags |= FORCECLOSE; /* There is 1 extra root vnode reference (nullm_rootvp). */ - error = vflush(mp, 1, flags); + error = vflush(mp, 1, flags, td); if (error) return (error); @@ -242,11 +242,11 @@ nullfs_unmount(mp, mntflags, td) } static int -nullfs_root(mp, vpp) +nullfs_root(mp, vpp, td) struct mount *mp; struct vnode **vpp; + struct thread *td; { - struct thread *td = curthread; /* XXX */ struct vnode *vp; NULLFSDEBUG("nullfs_root(mp = %p, vp = %p->%p)\n", (void *)mp, diff --git a/sys/fs/nwfs/nwfs_vfsops.c b/sys/fs/nwfs/nwfs_vfsops.c index 3eb0f915d7e8..824ef4eb1ce6 100644 --- a/sys/fs/nwfs/nwfs_vfsops.c +++ b/sys/fs/nwfs/nwfs_vfsops.c @@ -208,7 +208,7 @@ static int nwfs_mount(struct mount *mp, char *path, caddr_t data, /* protect against invalid mount points */ nmp->m.mount_point[sizeof(nmp->m.mount_point)-1] = '\0'; vfs_getnewfsid(mp); - error = nwfs_root(mp, &vp); + error = nwfs_root(mp, &vp, td); if (error) goto bad; /* @@ -238,7 +238,7 @@ nwfs_unmount(struct mount *mp, int mntflags, struct thread *td) if (mntflags & MNT_FORCE) flags |= FORCECLOSE; /* There is 1 extra root vnode reference from nwfs_mount(). */ - error = vflush(mp, 1, flags); + error = vflush(mp, 1, flags, td); if (error) return (error); conn = NWFSTOCONN(nmp); @@ -257,13 +257,12 @@ nwfs_unmount(struct mount *mp, int mntflags, struct thread *td) /* Return locked vnode to root of a filesystem */ static int -nwfs_root(struct mount *mp, struct vnode **vpp) { +nwfs_root(struct mount *mp, struct vnode **vpp, struct thread *td) { struct vnode *vp; struct nwmount *nmp; struct nwnode *np; struct ncp_conn *conn; struct nw_entry_info fattr; - struct thread *td = curthread; struct ucred *cred = td->td_ucred; int error, nsf, opt; u_char vol; diff --git a/sys/fs/portalfs/portal_vfsops.c b/sys/fs/portalfs/portal_vfsops.c index 497b65ae8387..5354f8d08e43 100644 --- a/sys/fs/portalfs/portal_vfsops.c +++ b/sys/fs/portalfs/portal_vfsops.c @@ -170,7 +170,7 @@ portal_unmount(mp, mntflags, td) return (EBUSY); #endif /* There is 1 extra root vnode reference (pm_root). */ - error = vflush(mp, 1, flags); + error = vflush(mp, 1, flags, td); if (error) return (error); @@ -194,9 +194,10 @@ portal_unmount(mp, mntflags, td) } static int -portal_root(mp, vpp) +portal_root(mp, vpp, td) struct mount *mp; struct vnode **vpp; + struct thread *td; { struct thread *td = curthread; /* XXX */ struct vnode *vp; diff --git a/sys/fs/pseudofs/pseudofs.c b/sys/fs/pseudofs/pseudofs.c index 4db02b46a5f2..872bd8d10671 100644 --- a/sys/fs/pseudofs/pseudofs.c +++ b/sys/fs/pseudofs/pseudofs.c @@ -295,7 +295,7 @@ pfs_unmount(struct mount *mp, int mntflags, struct thread *td) /* XXX do stuff with pi... */ - error = vflush(mp, 0, (mntflags & MNT_FORCE) ? FORCECLOSE : 0); + error = vflush(mp, 0, (mntflags & MNT_FORCE) ? FORCECLOSE : 0, td); return (error); } @@ -303,7 +303,7 @@ pfs_unmount(struct mount *mp, int mntflags, struct thread *td) * Return a root vnode */ int -pfs_root(struct mount *mp, struct vnode **vpp) +pfs_root(struct mount *mp, struct vnode **vpp, struct thread *td) { struct pfs_info *pi; diff --git a/sys/fs/pseudofs/pseudofs.h b/sys/fs/pseudofs/pseudofs.h index 2d448111f550..1bac49ca6831 100644 --- a/sys/fs/pseudofs/pseudofs.h +++ b/sys/fs/pseudofs/pseudofs.h @@ -201,7 +201,8 @@ int pfs_mount (struct pfs_info *pi, struct mount *mp, struct nameidata *ndp, struct thread *td); int pfs_unmount (struct mount *mp, int mntflags, struct thread *td); -int pfs_root (struct mount *mp, struct vnode **vpp); +int pfs_root (struct mount *mp, struct vnode **vpp, + struct thread *td); int pfs_statfs (struct mount *mp, struct statfs *sbp, struct thread *td); int pfs_init (struct pfs_info *pi, struct vfsconf *vfc); diff --git a/sys/fs/smbfs/smbfs_vfsops.c b/sys/fs/smbfs/smbfs_vfsops.c index e4575ec8f731..200409799da1 100644 --- a/sys/fs/smbfs/smbfs_vfsops.c +++ b/sys/fs/smbfs/smbfs_vfsops.c @@ -189,7 +189,7 @@ smbfs_mount(struct mount *mp, char *path, caddr_t data, /* protect against invalid mount points */ smp->sm_args.mount_point[sizeof(smp->sm_args.mount_point) - 1] = '\0'; vfs_getnewfsid(mp); - error = smbfs_root(mp, &vp); + error = smbfs_root(mp, &vp, td); if (error) goto bad; VOP_UNLOCK(vp, 0, td); @@ -238,7 +238,7 @@ smbfs_unmount(struct mount *mp, int mntflags, struct thread *td) do { smp->sm_didrele = 0; /* There is 1 extra root vnode reference from smbfs_mount(). */ - error = vflush(mp, 1, flags); + error = vflush(mp, 1, flags, td); } while (error == EBUSY && smp->sm_didrele != 0); if (error) return error; @@ -262,7 +262,7 @@ smbfs_unmount(struct mount *mp, int mntflags, struct thread *td) * Return locked root vnode of a filesystem */ static int -smbfs_root(struct mount *mp, struct vnode **vpp) +smbfs_root(struct mount *mp, struct vnode **vpp, struct thread *td) { struct smbmount *smp = VFSTOSMBFS(mp); struct vnode *vp; diff --git a/sys/fs/udf/udf_vfsops.c b/sys/fs/udf/udf_vfsops.c index d520c0899f67..2b2501a8b377 100644 --- a/sys/fs/udf/udf_vfsops.c +++ b/sys/fs/udf/udf_vfsops.c @@ -501,7 +501,7 @@ udf_unmount(struct mount *mp, int mntflags, struct thread *td) if (mntflags & MNT_FORCE) flags |= FORCECLOSE; - if ((error = vflush(mp, 0, flags))) + if ((error = vflush(mp, 0, flags, td))) return (error); if (udfmp->im_flags & UDFMNT_KICONV && udf_iconv) { @@ -532,7 +532,7 @@ udf_unmount(struct mount *mp, int mntflags, struct thread *td) } static int -udf_root(struct mount *mp, struct vnode **vpp) +udf_root(struct mount *mp, struct vnode **vpp, struct thread *td) { struct udf_mnt *udfmp; struct vnode *vp; diff --git a/sys/fs/umapfs/umap_vfsops.c b/sys/fs/umapfs/umap_vfsops.c index 1d7d0e5e8edc..c6f0e5799a02 100644 --- a/sys/fs/umapfs/umap_vfsops.c +++ b/sys/fs/umapfs/umap_vfsops.c @@ -279,7 +279,7 @@ umapfs_unmount(mp, mntflags, td) return (EBUSY); #endif /* There is 1 extra root vnode reference (umapm_rootvp). */ - error = vflush(mp, 1, flags); + error = vflush(mp, 1, flags, td); if (error) return (error); @@ -292,9 +292,10 @@ umapfs_unmount(mp, mntflags, td) } static int -umapfs_root(mp, vpp) +umapfs_root(mp, vpp, td) struct mount *mp; struct vnode **vpp; + struct thread *td; { struct thread *td = curthread; /* XXX */ struct vnode *vp; diff --git a/sys/fs/unionfs/union_vfsops.c b/sys/fs/unionfs/union_vfsops.c index 61632574ab8a..e756e18ca978 100644 --- a/sys/fs/unionfs/union_vfsops.c +++ b/sys/fs/unionfs/union_vfsops.c @@ -342,7 +342,7 @@ union_unmount(mp, mntflags, td) * (d) times, where (d) is the maximum tree depth * in the filesystem. */ - for (freeing = 0; (error = vflush(mp, 0, flags)) != 0;) { + for (freeing = 0; (error = vflush(mp, 0, flags, td)) != 0;) { int n; /* count #vnodes held on mount list */ @@ -378,9 +378,10 @@ union_unmount(mp, mntflags, td) } static int -union_root(mp, vpp) +union_root(mp, vpp, td) struct mount *mp; struct vnode **vpp; + struct thread *td; { struct union_mount *um = MOUNTTOUNIONMOUNT(mp); int error; diff --git a/sys/fs/unionfs/union_vnops.c b/sys/fs/unionfs/union_vnops.c index 1934d5d151e4..c8240e9973a5 100644 --- a/sys/fs/unionfs/union_vnops.c +++ b/sys/fs/unionfs/union_vnops.c @@ -268,7 +268,7 @@ union_lookup1(udvp, pdvp, vpp, cnp) relock_pdvp = 1; vput(dvp); dvp = NULL; - error = VFS_ROOT(mp, &dvp); + error = VFS_ROOT(mp, &dvp, td); vfs_unbusy(mp, td); diff --git a/sys/gnu/ext2fs/ext2_vfsops.c b/sys/gnu/ext2fs/ext2_vfsops.c index 9f7dcda176c0..b68823686471 100644 --- a/sys/gnu/ext2fs/ext2_vfsops.c +++ b/sys/gnu/ext2fs/ext2_vfsops.c @@ -829,7 +829,7 @@ ext2_flushfiles(mp, flags, td) { int error; - error = vflush(mp, 0, flags); + error = vflush(mp, 0, flags, td); return (error); } @@ -1215,9 +1215,10 @@ printf("\nupdating superblock, waitfor=%s\n", waitfor == MNT_WAIT ? "yes":"no"); * Return the root of a filesystem. */ static int -ext2_root(mp, vpp) +ext2_root(mp, vpp, td) struct mount *mp; struct vnode **vpp; + struct thread *td; { struct vnode *nvp; int error; diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c index 9f7dcda176c0..b68823686471 100644 --- a/sys/gnu/fs/ext2fs/ext2_vfsops.c +++ b/sys/gnu/fs/ext2fs/ext2_vfsops.c @@ -829,7 +829,7 @@ ext2_flushfiles(mp, flags, td) { int error; - error = vflush(mp, 0, flags); + error = vflush(mp, 0, flags, td); return (error); } @@ -1215,9 +1215,10 @@ printf("\nupdating superblock, waitfor=%s\n", waitfor == MNT_WAIT ? "yes":"no"); * Return the root of a filesystem. */ static int -ext2_root(mp, vpp) +ext2_root(mp, vpp, td) struct mount *mp; struct vnode **vpp; + struct thread *td; { struct vnode *nvp; int error; diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c index e91f4b149e93..10e3bc48c65d 100644 --- a/sys/isofs/cd9660/cd9660_vfsops.c +++ b/sys/isofs/cd9660/cd9660_vfsops.c @@ -554,7 +554,7 @@ cd9660_unmount(mp, mntflags, td) if (mntinvalbuf(mp)) return EBUSY; #endif - if ((error = vflush(mp, 0, flags))) + if ((error = vflush(mp, 0, flags, td))) return (error); isomp = VFSTOISOFS(mp); @@ -578,9 +578,10 @@ cd9660_unmount(mp, mntflags, td) * Return root of a filesystem */ static int -cd9660_root(mp, vpp) +cd9660_root(mp, vpp, td) struct mount *mp; struct vnode **vpp; + struct thread *td; { struct iso_mnt *imp = VFSTOISOFS(mp); struct iso_directory_record *dp = diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 757f8aeddf3d..575f227aa733 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -553,7 +553,7 @@ start_init(void *dummy) vfs_mountroot(); /* Get the vnode for '/'. Set p->p_fd->fd_cdir to reference it. */ - if (VFS_ROOT(TAILQ_FIRST(&mountlist), &rootvnode)) + if (VFS_ROOT(TAILQ_FIRST(&mountlist), &rootvnode, td)) panic("cannot find root vnode"); FILEDESC_LOCK(p->p_fd); p->p_fd->fd_cdir = rootvnode; diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index c497b604fe6c..5812a03578fb 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -655,9 +655,10 @@ vop_stdputpages(ap) * used to fill the vfs function table to get reasonable default return values. */ int -vfs_stdroot (mp, vpp) +vfs_stdroot (mp, vpp, td) struct mount *mp; struct vnode **vpp; + struct thread *td; { return (EOPNOTSUPP); diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c index a90d6f860f16..dd217822b2b5 100644 --- a/sys/kern/vfs_export.c +++ b/sys/kern/vfs_export.c @@ -296,7 +296,7 @@ vfs_setpublicfs(mp, nep, argp) bzero(&nfs_pub.np_handle, sizeof(nfs_pub.np_handle)); nfs_pub.np_handle.fh_fsid = mp->mnt_stat.f_fsid; - if ((error = VFS_ROOT(mp, &rvp))) + if ((error = VFS_ROOT(mp, &rvp, curthread /* XXX */))) return (error); if ((error = VFS_VPTOFH(rvp, &nfs_pub.np_handle.fh_fid))) diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index 2fffe6350d30..c22b194d2469 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -690,7 +690,7 @@ fchdir(td, uap) while (!error && (mp = vp->v_mountedhere) != NULL) { if (vfs_busy(mp, 0, 0, td)) continue; - error = VFS_ROOT(mp, &tdp); + error = VFS_ROOT(mp, &tdp, td); vfs_unbusy(mp, td); if (error) break; diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index b93110257622..10b49aa5d068 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -555,7 +555,7 @@ lookup(ndp) if (vfs_busy(mp, 0, 0, td)) continue; VOP_UNLOCK(dp, 0, td); - error = VFS_ROOT(mp, &tdp); + error = VFS_ROOT(mp, &tdp, td); vfs_unbusy(mp, td); if (error) { dpunlocked = 1; diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 5252b3bc7cb3..d697499a80a7 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -913,7 +913,7 @@ vfs_domount( TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list); mtx_unlock(&mountlist_mtx); vfs_event_signal(NULL, VQ_MOUNT, 0); - if (VFS_ROOT(mp, &newdp)) + if (VFS_ROOT(mp, &newdp, td)) panic("mount: lost mount"); checkdirs(vp, newdp); vput(newdp); @@ -1114,7 +1114,7 @@ dounmount(mp, flags, td) * vnode to the covered vnode. For non-forced unmounts we want * such references to cause an EBUSY error. */ - if ((flags & MNT_FORCE) && VFS_ROOT(mp, &fsrootvp) == 0) { + if ((flags & MNT_FORCE) && VFS_ROOT(mp, &fsrootvp, td) == 0) { if (mp->mnt_vnodecovered != NULL) checkdirs(fsrootvp, mp->mnt_vnodecovered); if (fsrootvp == rootvnode) { @@ -1131,7 +1131,7 @@ dounmount(mp, flags, td) vn_finished_write(mp); if (error) { /* Undo cdir/rdir and rootvnode changes made above. */ - if ((flags & MNT_FORCE) && VFS_ROOT(mp, &fsrootvp) == 0) { + if ((flags & MNT_FORCE) && VFS_ROOT(mp, &fsrootvp, td) == 0) { if (mp->mnt_vnodecovered != NULL) checkdirs(mp->mnt_vnodecovered, fsrootvp); if (rootvnode == NULL) { @@ -1465,7 +1465,7 @@ getdiskbyname(char *name) if (error) break; VFS_START(mp, 0, td); - VFS_ROOT(mp, &vroot); + VFS_ROOT(mp, &vroot, td); VOP_UNLOCK(vroot, 0, td); NDINIT(&nid, LOOKUP, NOCACHE|FOLLOW, diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index c0dff887c49e..53403db95735 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -2258,7 +2258,7 @@ vdropl(vp) * * `rootrefs' specifies the base reference count for the root vnode * of this filesystem. The root vnode is considered busy if its - * v_usecount exceeds this value. On a successful return, vflush() + * v_usecount exceeds this value. On a successful return, vflush(, td) * will call vrele() on the root vnode exactly rootrefs times. * If the SKIPSYSTEM or WRITECLOSE flags are specified, rootrefs must * be zero. @@ -2269,12 +2269,12 @@ SYSCTL_INT(_debug, OID_AUTO, busyprt, CTLFLAG_RW, &busyprt, 0, ""); #endif int -vflush(mp, rootrefs, flags) +vflush(mp, rootrefs, flags, td) struct mount *mp; int rootrefs; int flags; + struct thread *td; { - struct thread *td = curthread; /* XXX */ struct vnode *vp, *nvp, *rootvp = NULL; struct vattr vattr; int busy = 0, error; @@ -2286,7 +2286,7 @@ vflush(mp, rootrefs, flags) * Get the filesystem root vnode. We can vput() it * immediately, since with rootrefs > 0, it won't go away. */ - if ((error = VFS_ROOT(mp, &rootvp)) != 0) + if ((error = VFS_ROOT(mp, &rootvp, td)) != 0) return (error); vput(rootvp); diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 2fffe6350d30..c22b194d2469 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -690,7 +690,7 @@ fchdir(td, uap) while (!error && (mp = vp->v_mountedhere) != NULL) { if (vfs_busy(mp, 0, 0, td)) continue; - error = VFS_ROOT(mp, &tdp); + error = VFS_ROOT(mp, &tdp, td); vfs_unbusy(mp, td); if (error) break; diff --git a/sys/nfs4client/nfs4_vfsops.c b/sys/nfs4client/nfs4_vfsops.c index e20d176a0538..cf730adecf25 100644 --- a/sys/nfs4client/nfs4_vfsops.c +++ b/sys/nfs4client/nfs4_vfsops.c @@ -656,7 +656,7 @@ nfs_unmount(struct mount *mp, int mntflags, struct thread *td) nmp = VFSTONFS(mp); /* * Goes something like this.. - * - Call vflush() to clear out vnodes for this filesystem + * - Call vflush(, td) to clear out vnodes for this filesystem * - Close the socket * - Free up the data structures */ @@ -668,7 +668,7 @@ nfs_unmount(struct mount *mp, int mntflags, struct thread *td) nfs4dev_purge(); } - error = vflush(mp, 0, flags); + error = vflush(mp, 0, flags, td); if (error) return (error); @@ -689,7 +689,7 @@ nfs_unmount(struct mount *mp, int mntflags, struct thread *td) * Return root of a filesystem */ static int -nfs_root(struct mount *mp, struct vnode **vpp) +nfs_root(struct mount *mp, struct vnode **vpp, struct thread *td) { struct vnode *vp; struct nfsmount *nmp; diff --git a/sys/nfsclient/nfs_vfsops.c b/sys/nfsclient/nfs_vfsops.c index 96746286aa18..738234394ace 100644 --- a/sys/nfsclient/nfs_vfsops.c +++ b/sys/nfsclient/nfs_vfsops.c @@ -894,7 +894,7 @@ nfs_unmount(struct mount *mp, int mntflags, struct thread *td) return (error); } /* We hold 1 extra ref on the root vnode; see comment in mountnfs(). */ - error = vflush(mp, 1, flags); + error = vflush(mp, 1, flags, td); if (error) return (error); @@ -912,7 +912,7 @@ nfs_unmount(struct mount *mp, int mntflags, struct thread *td) * Return root of a filesystem */ static int -nfs_root(struct mount *mp, struct vnode **vpp) +nfs_root(struct mount *mp, struct vnode **vpp, struct thread *td) { struct vnode *vp; struct nfsmount *nmp; diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 1d1e7aa160c8..e0893c9b4e27 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -464,7 +464,7 @@ typedef int vfs_mount_t(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp, struct thread *td); typedef int vfs_start_t(struct mount *mp, int flags, struct thread *td); typedef int vfs_unmount_t(struct mount *mp, int mntflags, struct thread *td); -typedef int vfs_root_t(struct mount *mp, struct vnode **vpp); +typedef int vfs_root_t(struct mount *mp, struct vnode **vpp, struct thread *td); typedef int vfs_quotactl_t(struct mount *mp, int cmds, uid_t uid, caddr_t arg, struct thread *td); typedef int vfs_statfs_t(struct mount *mp, struct statfs *sbp, @@ -512,7 +512,7 @@ struct vfsops { (*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, P) #define VFS_START(MP, FLAGS, P) (*(MP)->mnt_op->vfs_start)(MP, FLAGS, P) #define VFS_UNMOUNT(MP, FORCE, P) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, P) -#define VFS_ROOT(MP, VPP) (*(MP)->mnt_op->vfs_root)(MP, VPP) +#define VFS_ROOT(MP, VPP, P) (*(MP)->mnt_op->vfs_root)(MP, VPP, P) #define VFS_QUOTACTL(MP,C,U,A,P) (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, P) #define VFS_STATFS(MP, SBP, P) (*(MP)->mnt_op->vfs_statfs)(MP, SBP, P) #define VFS_SYNC(MP, WAIT, C, P) (*(MP)->mnt_op->vfs_sync)(MP, WAIT, C, P) diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 723e1b0e9847..b78e0482b4c0 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -629,7 +629,7 @@ void vdropl(struct vnode *); int vfinddev(struct cdev *dev, struct vnode **vpp); void vfs_add_vnodeops(const void *); void vfs_rm_vnodeops(const void *); -int vflush(struct mount *mp, int rootrefs, int flags); +int vflush(struct mount *mp, int rootrefs, int flags, struct thread *td); int vget(struct vnode *vp, int lockflag, struct thread *td); void vgone(struct vnode *vp); void vgonel(struct vnode *vp, struct thread *td); diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index af3ca976b047..2ed939d4ca51 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -1003,7 +1003,7 @@ ffs_flushfiles(mp, flags, td) #ifdef QUOTA if (mp->mnt_flag & MNT_QUOTA) { int i; - error = vflush(mp, 0, SKIPSYSTEM|flags); + error = vflush(mp, 0, SKIPSYSTEM|flags, td); if (error) return (error); for (i = 0; i < MAXQUOTAS; i++) { @@ -1019,7 +1019,7 @@ ffs_flushfiles(mp, flags, td) #endif ASSERT_VOP_LOCKED(ump->um_devvp, "ffs_flushfiles"); if (ump->um_devvp->v_vflag & VV_COPYONWRITE) { - if ((error = vflush(mp, 0, SKIPSYSTEM | flags)) != 0) + if ((error = vflush(mp, 0, SKIPSYSTEM | flags, td)) != 0) return (error); ffs_snapshot_unmount(mp); /* @@ -1030,7 +1030,7 @@ ffs_flushfiles(mp, flags, td) /* * Flush all the files. */ - if ((error = vflush(mp, 0, flags)) != 0) + if ((error = vflush(mp, 0, flags, td)) != 0) return (error); /* * Flush filesystem metadata. diff --git a/sys/ufs/ufs/ufs_extattr.c b/sys/ufs/ufs/ufs_extattr.c index f31d927d5ddb..e78ea938e934 100644 --- a/sys/ufs/ufs/ufs_extattr.c +++ b/sys/ufs/ufs/ufs_extattr.c @@ -472,7 +472,7 @@ ufs_extattr_autostart(struct mount *mp, struct thread *td) * Does UFS_EXTATTR_FSROOTSUBDIR exist off the filesystem root? * If so, automatically start EA's. */ - error = VFS_ROOT(mp, &rvp); + error = VFS_ROOT(mp, &rvp, td); if (error) { printf("ufs_extattr_autostart.VFS_ROOT() returned %d\n", error); diff --git a/sys/ufs/ufs/ufs_vfsops.c b/sys/ufs/ufs/ufs_vfsops.c index 64666771906b..8876e5105dff 100644 --- a/sys/ufs/ufs/ufs_vfsops.c +++ b/sys/ufs/ufs/ufs_vfsops.c @@ -80,9 +80,10 @@ ufs_start(mp, flags, td) * Return the root of a filesystem. */ int -ufs_root(mp, vpp) +ufs_root(mp, vpp, td) struct mount *mp; struct vnode **vpp; + struct thread *td; { struct vnode *nvp; int error;