summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/vfs_lookup.c4
-rw-r--r--sys/kern/vfs_mount.c28
-rw-r--r--sys/kern/vfs_subr.c26
-rw-r--r--sys/kern/vfs_syscalls.c20
4 files changed, 36 insertions, 42 deletions
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c
index 1b295fc..8adb68e 100644
--- a/sys/kern/vfs_lookup.c
+++ b/sys/kern/vfs_lookup.c
@@ -688,7 +688,7 @@ unionlookup:
*/
while (dp->v_type == VDIR && (mp = dp->v_mountedhere) &&
(cnp->cn_flags & NOCROSSMOUNT) == 0) {
- if (vfs_busy(mp, 0, 0, td))
+ if (vfs_busy(mp, 0, 0))
continue;
vput(dp);
VFS_UNLOCK_GIANT(vfslocked);
@@ -702,7 +702,7 @@ unionlookup:
vref(vp_crossmp);
ndp->ni_dvp = vp_crossmp;
error = VFS_ROOT(mp, compute_cn_lkflags(mp, cnp->cn_lkflags), &tdp, td);
- vfs_unbusy(mp, td);
+ vfs_unbusy(mp);
if (vn_lock(vp_crossmp, LK_SHARED | LK_NOWAIT))
panic("vp_crossmp exclusively locked or reclaimed");
if (error) {
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index b25ba3b..8b2df8e 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -472,8 +472,8 @@ mount_fini(void *mem, int size)
* Allocate and initialize the mount point struct.
*/
struct mount *
-vfs_mount_alloc(struct vnode *vp, struct vfsconf *vfsp,
- const char *fspath, struct thread *td)
+vfs_mount_alloc(struct vnode *vp, struct vfsconf *vfsp, const char *fspath,
+ struct ucred *cred)
{
struct mount *mp;
@@ -483,7 +483,7 @@ vfs_mount_alloc(struct vnode *vp, struct vfsconf *vfsp,
TAILQ_INIT(&mp->mnt_nvnodelist);
mp->mnt_nvnodelistsize = 0;
mp->mnt_ref = 0;
- (void) vfs_busy(mp, LK_NOWAIT, 0, td);
+ (void) vfs_busy(mp, LK_NOWAIT, 0);
mp->mnt_op = vfsp->vfc_vfsops;
mp->mnt_vfc = vfsp;
vfsp->vfc_refcount++; /* XXX Unlocked */
@@ -491,13 +491,13 @@ vfs_mount_alloc(struct vnode *vp, struct vfsconf *vfsp,
mp->mnt_gen++;
strlcpy(mp->mnt_stat.f_fstypename, vfsp->vfc_name, MFSNAMELEN);
mp->mnt_vnodecovered = vp;
- mp->mnt_cred = crdup(td->td_ucred);
- mp->mnt_stat.f_owner = td->td_ucred->cr_uid;
+ mp->mnt_cred = crdup(cred);
+ mp->mnt_stat.f_owner = cred->cr_uid;
strlcpy(mp->mnt_stat.f_mntonname, fspath, MNAMELEN);
mp->mnt_iosize_max = DFLTPHYS;
#ifdef MAC
mac_mount_init(mp);
- mac_mount_create(td->td_ucred, mp);
+ mac_mount_create(cred, mp);
#endif
arc4rand(&mp->mnt_hashseed, sizeof mp->mnt_hashseed, 0);
return (mp);
@@ -932,7 +932,7 @@ vfs_domount(
vput(vp);
return (error);
}
- if (vfs_busy(mp, LK_NOWAIT, 0, td)) {
+ if (vfs_busy(mp, LK_NOWAIT, 0)) {
vput(vp);
return (EBUSY);
}
@@ -940,7 +940,7 @@ vfs_domount(
if ((vp->v_iflag & VI_MOUNT) != 0 ||
vp->v_mountedhere != NULL) {
VI_UNLOCK(vp);
- vfs_unbusy(mp, td);
+ vfs_unbusy(mp);
vput(vp);
return (EBUSY);
}
@@ -993,7 +993,7 @@ vfs_domount(
/*
* Allocate and initialize the filesystem.
*/
- mp = vfs_mount_alloc(vp, vfsp, fspath, td);
+ mp = vfs_mount_alloc(vp, vfsp, fspath, td->td_ucred);
VOP_UNLOCK(vp, 0);
/* XXXMAC: pass to vfs_mount_alloc? */
@@ -1059,7 +1059,7 @@ vfs_domount(
vrele(mp->mnt_syncer);
mp->mnt_syncer = NULL;
}
- vfs_unbusy(mp, td);
+ vfs_unbusy(mp);
VI_LOCK(vp);
vp->v_iflag &= ~VI_MOUNT;
VI_UNLOCK(vp);
@@ -1095,14 +1095,14 @@ vfs_domount(
VOP_UNLOCK(vp, 0);
if ((mp->mnt_flag & MNT_RDONLY) == 0)
error = vfs_allocate_syncvnode(mp);
- vfs_unbusy(mp, td);
+ vfs_unbusy(mp);
if (error)
vrele(vp);
} else {
VI_LOCK(vp);
vp->v_iflag &= ~VI_MOUNT;
VI_UNLOCK(vp);
- vfs_unbusy(mp, td);
+ vfs_unbusy(mp);
vfs_mount_destroy(mp);
vput(vp);
}
@@ -1514,7 +1514,7 @@ devfs_first(void)
if (vfsp == NULL)
return;
- mp = vfs_mount_alloc(NULLVP, vfsp, "/dev", td);
+ mp = vfs_mount_alloc(NULLVP, vfsp, "/dev", td->td_ucred);
error = VFS_MOUNT(mp, td);
KASSERT(error == 0, ("VFS_MOUNT(devfs) failed %d", error));
@@ -1589,7 +1589,7 @@ devfs_fixup(struct thread *td)
mtx_unlock(&mountlist_mtx);
VOP_UNLOCK(vp, 0);
vput(dvp);
- vfs_unbusy(mp, td);
+ vfs_unbusy(mp);
/* Unlink the no longer needed /dev/dev -> / symlink */
kern_unlink(td, "/dev/dev", UIO_SYSSPACE);
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index d097d13..ce404ff 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -338,8 +338,7 @@ SYSINIT(vfs, SI_SUB_VFS, SI_ORDER_FIRST, vntblinit, NULL);
* unmounting. Interlock is not released on failure.
*/
int
-vfs_busy(struct mount *mp, int flags, struct mtx *interlkp,
- struct thread *td)
+vfs_busy(struct mount *mp, int flags, struct mtx *interlkp)
{
int lkflags;
@@ -379,7 +378,7 @@ vfs_busy(struct mount *mp, int flags, struct mtx *interlkp,
* Free a busy filesystem.
*/
void
-vfs_unbusy(struct mount *mp, struct thread *td)
+vfs_unbusy(struct mount *mp)
{
lockmgr(&mp->mnt_lock, LK_RELEASE, NULL);
@@ -573,7 +572,6 @@ vattr_null(struct vattr *vap)
static int
vlrureclaim(struct mount *mp)
{
- struct thread *td;
struct vnode *vp;
int done;
int trigger;
@@ -592,7 +590,6 @@ vlrureclaim(struct mount *mp)
usevnodes = 1;
trigger = cnt.v_page_count * 2 / usevnodes;
done = 0;
- td = curthread;
vn_start_write(NULL, &mp, V_WAIT);
MNT_ILOCK(mp);
count = mp->mnt_nvnodelistsize / 10 + 1;
@@ -727,7 +724,6 @@ vnlru_proc(void)
struct mount *mp, *nmp;
int done;
struct proc *p = vnlruproc;
- struct thread *td = curthread;
EVENTHANDLER_REGISTER(shutdown_pre_sync, kproc_shutdown, p,
SHUTDOWN_PRI_FIRST);
@@ -751,7 +747,7 @@ vnlru_proc(void)
mtx_lock(&mountlist_mtx);
for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
int vfsunlocked;
- if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, td)) {
+ if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx)) {
nmp = TAILQ_NEXT(mp, mnt_list);
continue;
}
@@ -765,7 +761,7 @@ vnlru_proc(void)
mtx_lock(&Giant);
mtx_lock(&mountlist_mtx);
nmp = TAILQ_NEXT(mp, mnt_list);
- vfs_unbusy(mp, td);
+ vfs_unbusy(mp);
}
mtx_unlock(&mountlist_mtx);
if (done == 0) {
@@ -2988,7 +2984,6 @@ static int
sysctl_vnode(SYSCTL_HANDLER_ARGS)
{
struct xvnode *xvn;
- struct thread *td = req->td;
struct mount *mp;
struct vnode *vp;
int error, len, n;
@@ -3009,7 +3004,7 @@ sysctl_vnode(SYSCTL_HANDLER_ARGS)
n = 0;
mtx_lock(&mountlist_mtx);
TAILQ_FOREACH(mp, &mountlist, mnt_list) {
- if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, td))
+ if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx))
continue;
MNT_ILOCK(mp);
TAILQ_FOREACH(vp, &mp->mnt_nvnodelist, v_nmntvnodes) {
@@ -3060,7 +3055,7 @@ sysctl_vnode(SYSCTL_HANDLER_ARGS)
}
MNT_IUNLOCK(mp);
mtx_lock(&mountlist_mtx);
- vfs_unbusy(mp, td);
+ vfs_unbusy(mp);
if (n == len)
break;
}
@@ -3337,7 +3332,6 @@ sync_fsync(struct vop_fsync_args *ap)
{
struct vnode *syncvp = ap->a_vp;
struct mount *mp = syncvp->v_mount;
- struct thread *td = ap->a_td;
int error;
struct bufobj *bo;
@@ -3360,12 +3354,12 @@ sync_fsync(struct vop_fsync_args *ap)
* not already on the sync list.
*/
mtx_lock(&mountlist_mtx);
- if (vfs_busy(mp, LK_EXCLUSIVE | LK_NOWAIT, &mountlist_mtx, td) != 0) {
+ if (vfs_busy(mp, LK_EXCLUSIVE | LK_NOWAIT, &mountlist_mtx) != 0) {
mtx_unlock(&mountlist_mtx);
return (0);
}
if (vn_start_write(NULL, &mp, V_NOWAIT) != 0) {
- vfs_unbusy(mp, td);
+ vfs_unbusy(mp);
return (0);
}
MNT_ILOCK(mp);
@@ -3373,14 +3367,14 @@ sync_fsync(struct vop_fsync_args *ap)
mp->mnt_kern_flag &= ~MNTK_ASYNC;
MNT_IUNLOCK(mp);
vfs_msync(mp, MNT_NOWAIT);
- error = VFS_SYNC(mp, MNT_LAZY, td);
+ error = VFS_SYNC(mp, MNT_LAZY, ap->a_td);
MNT_ILOCK(mp);
mp->mnt_noasync--;
if ((mp->mnt_flag & MNT_ASYNC) != 0 && mp->mnt_noasync == 0)
mp->mnt_kern_flag |= MNTK_ASYNC;
MNT_IUNLOCK(mp);
vn_finished_write(mp);
- vfs_unbusy(mp, td);
+ vfs_unbusy(mp);
return (error);
}
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index ee66315..5a3ba14 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -124,7 +124,7 @@ sync(td, uap)
mtx_lock(&mountlist_mtx);
for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
- if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, td)) {
+ if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx)) {
nmp = TAILQ_NEXT(mp, mnt_list);
continue;
}
@@ -148,7 +148,7 @@ sync(td, uap)
VFS_UNLOCK_GIANT(vfslocked);
mtx_lock(&mountlist_mtx);
nmp = TAILQ_NEXT(mp, mnt_list);
- vfs_unbusy(mp, td);
+ vfs_unbusy(mp);
}
mtx_unlock(&mountlist_mtx);
return (0);
@@ -197,14 +197,14 @@ quotactl(td, uap)
vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
mp = nd.ni_vp->v_mount;
- if ((error = vfs_busy(mp, 0, NULL, td))) {
+ if ((error = vfs_busy(mp, 0, NULL))) {
vrele(nd.ni_vp);
VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
vrele(nd.ni_vp);
error = VFS_QUOTACTL(mp, uap->cmd, uap->uid, uap->arg, td);
- vfs_unbusy(mp, td);
+ vfs_unbusy(mp);
VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -479,7 +479,7 @@ kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize,
continue;
}
#endif
- if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx, td)) {
+ if (vfs_busy(mp, LK_NOWAIT, &mountlist_mtx)) {
nmp = TAILQ_NEXT(mp, mnt_list);
continue;
}
@@ -504,7 +504,7 @@ kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize,
VFS_UNLOCK_GIANT(vfslocked);
mtx_lock(&mountlist_mtx);
nmp = TAILQ_NEXT(mp, mnt_list);
- vfs_unbusy(mp, td);
+ vfs_unbusy(mp);
continue;
}
if (priv_check(td, PRIV_VFS_GENERATION)) {
@@ -518,7 +518,7 @@ kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize,
else /* if (bufseg == UIO_USERSPACE) */ {
error = copyout(sp, sfsp, sizeof(*sp));
if (error) {
- vfs_unbusy(mp, td);
+ vfs_unbusy(mp);
VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -529,7 +529,7 @@ kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize,
count++;
mtx_lock(&mountlist_mtx);
nmp = TAILQ_NEXT(mp, mnt_list);
- vfs_unbusy(mp, td);
+ vfs_unbusy(mp);
}
mtx_unlock(&mountlist_mtx);
if (sfsp && count > maxcount)
@@ -741,11 +741,11 @@ fchdir(td, uap)
error = change_dir(vp, td);
while (!error && (mp = vp->v_mountedhere) != NULL) {
int tvfslocked;
- if (vfs_busy(mp, 0, 0, td))
+ if (vfs_busy(mp, 0, 0))
continue;
tvfslocked = VFS_LOCK_GIANT(mp);
error = VFS_ROOT(mp, LK_EXCLUSIVE, &tdp, td);
- vfs_unbusy(mp, td);
+ vfs_unbusy(mp);
if (error) {
VFS_UNLOCK_GIANT(tvfslocked);
break;
OpenPOWER on IntegriCloud