aboutsummaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2012-10-22 17:50:54 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2012-10-22 17:50:54 +0000
commit5050aa86cff105784877fb886a7b1d25bca5813b (patch)
tree6e9ef0a47c5e91d26227820c50c9767e84550821 /sys/kern
parentbf3d1021334f4d19cf4fa95bd409db11c4dcfb9e (diff)
downloadsrc-5050aa86cff105784877fb886a7b1d25bca5813b.tar.gz
src-5050aa86cff105784877fb886a7b1d25bca5813b.zip
Notes
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/imgact_elf.c8
-rw-r--r--sys/kern/kern_acct.c27
-rw-r--r--sys/kern/kern_alq.c8
-rw-r--r--sys/kern/kern_ctf.c5
-rw-r--r--sys/kern/kern_descrip.c61
-rw-r--r--sys/kern/kern_exec.c25
-rw-r--r--sys/kern/kern_exit.c3
-rw-r--r--sys/kern/kern_gzio.c6
-rw-r--r--sys/kern/kern_jail.c27
-rw-r--r--sys/kern/kern_ktrace.c35
-rw-r--r--sys/kern/kern_linker.c12
-rw-r--r--sys/kern/kern_proc.c11
-rw-r--r--sys/kern/kern_sig.c11
-rw-r--r--sys/kern/link_elf.c5
-rw-r--r--sys/kern/link_elf_obj.c5
-rw-r--r--sys/kern/sys_process.c4
-rw-r--r--sys/kern/uipc_syscalls.c10
-rw-r--r--sys/kern/uipc_usrreq.c29
-rw-r--r--sys/kern/vfs_acl.c64
-rw-r--r--sys/kern/vfs_aio.c3
-rw-r--r--sys/kern/vfs_bio.c29
-rw-r--r--sys/kern/vfs_cache.c43
-rw-r--r--sys/kern/vfs_default.c5
-rw-r--r--sys/kern/vfs_extattr.c87
-rw-r--r--sys/kern/vfs_init.c2
-rw-r--r--sys/kern/vfs_lookup.c61
-rw-r--r--sys/kern/vfs_mount.c27
-rw-r--r--sys/kern/vfs_mountroot.c7
-rw-r--r--sys/kern/vfs_subr.c62
-rw-r--r--sys/kern/vfs_syscalls.c277
-rw-r--r--sys/kern/vfs_vnops.c64
31 files changed, 181 insertions, 842 deletions
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index 1fcd995ef2a7..4c1cb5b0e033 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -595,7 +595,7 @@ __elfN(load_file)(struct proc *p, const char *file, u_long *addr,
vm_prot_t prot;
u_long rbase;
u_long base_addr = 0;
- int vfslocked, error, i, numsegs;
+ int error, i, numsegs;
#ifdef CAPABILITY_MODE
/*
@@ -621,14 +621,11 @@ __elfN(load_file)(struct proc *p, const char *file, u_long *addr,
imgp->object = NULL;
imgp->execlabel = NULL;
- NDINIT(nd, LOOKUP, MPSAFE|LOCKLEAF|FOLLOW, UIO_SYSSPACE, file,
- curthread);
- vfslocked = 0;
+ NDINIT(nd, LOOKUP, LOCKLEAF | FOLLOW, UIO_SYSSPACE, file, curthread);
if ((error = namei(nd)) != 0) {
nd->ni_vp = NULL;
goto fail;
}
- vfslocked = NDHASGIANT(nd);
NDFREE(nd, NDF_ONLY_PNBUF);
imgp->vp = nd->ni_vp;
@@ -706,7 +703,6 @@ fail:
if (nd->ni_vp)
vput(nd->ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
free(tempdata, M_TEMP);
return (error);
diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c
index fda217a045ce..336211268408 100644
--- a/sys/kern/kern_acct.c
+++ b/sys/kern/kern_acct.c
@@ -196,7 +196,7 @@ int
sys_acct(struct thread *td, struct acct_args *uap)
{
struct nameidata nd;
- int error, flags, vfslocked, replacing;
+ int error, flags, replacing;
error = priv_check(td, PRIV_ACCT);
if (error)
@@ -207,30 +207,26 @@ sys_acct(struct thread *td, struct acct_args *uap)
* appending and make sure it's a 'normal'.
*/
if (uap->path != NULL) {
- NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE | AUDITVNODE1,
+ NDINIT(&nd, LOOKUP, NOFOLLOW | AUDITVNODE1,
UIO_USERSPACE, uap->path, td);
flags = FWRITE | O_APPEND;
error = vn_open(&nd, &flags, 0, NULL);
if (error)
return (error);
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
#ifdef MAC
error = mac_system_check_acct(td->td_ucred, nd.ni_vp);
if (error) {
VOP_UNLOCK(nd.ni_vp, 0);
vn_close(nd.ni_vp, flags, td->td_ucred, td);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
#endif
VOP_UNLOCK(nd.ni_vp, 0);
if (nd.ni_vp->v_type != VREG) {
vn_close(nd.ni_vp, flags, td->td_ucred, td);
- VFS_UNLOCK_GIANT(vfslocked);
return (EACCES);
}
- VFS_UNLOCK_GIANT(vfslocked);
#ifdef MAC
} else {
error = mac_system_check_acct(td->td_ucred, NULL);
@@ -259,11 +255,8 @@ sys_acct(struct thread *td, struct acct_args *uap)
* enabled.
*/
acct_suspended = 0;
- if (acct_vp != NULL) {
- vfslocked = VFS_LOCK_GIANT(acct_vp->v_mount);
+ if (acct_vp != NULL)
error = acct_disable(td, !replacing);
- VFS_UNLOCK_GIANT(vfslocked);
- }
if (uap->path == NULL) {
if (acct_state & ACCT_RUNNING) {
acct_state |= ACCT_EXITREQ;
@@ -291,9 +284,7 @@ sys_acct(struct thread *td, struct acct_args *uap)
error = kproc_create(acct_thread, NULL, NULL, 0, 0,
"accounting");
if (error) {
- vfslocked = VFS_LOCK_GIANT(acct_vp->v_mount);
(void) vn_close(acct_vp, acct_flags, acct_cred, td);
- VFS_UNLOCK_GIANT(vfslocked);
crfree(acct_cred);
acct_configured = 0;
acct_vp = NULL;
@@ -346,7 +337,7 @@ acct_process(struct thread *td)
struct plimit *newlim, *oldlim;
struct proc *p;
struct rusage ru;
- int t, ret, vfslocked;
+ int t, ret;
/*
* Lockless check of accounting condition before doing the hard
@@ -442,11 +433,9 @@ acct_process(struct thread *td)
/*
* Write the accounting information to the file.
*/
- vfslocked = VFS_LOCK_GIANT(acct_vp->v_mount);
ret = vn_rdwr(UIO_WRITE, acct_vp, (caddr_t)&acct, sizeof (acct),
(off_t)0, UIO_SYSSPACE, IO_APPEND|IO_UNIT, acct_cred, NOCRED,
NULL, td);
- VFS_UNLOCK_GIANT(vfslocked);
sx_sunlock(&acct_sx);
return (ret);
}
@@ -563,7 +552,6 @@ static void
acctwatch(void)
{
struct statfs sb;
- int vfslocked;
sx_assert(&acct_sx, SX_XLOCKED);
@@ -581,10 +569,8 @@ acctwatch(void)
* If our vnode is no longer valid, tear it down and signal the
* accounting thread to die.
*/
- vfslocked = VFS_LOCK_GIANT(acct_vp->v_mount);
if (acct_vp->v_type == VBAD) {
(void) acct_disable(NULL, 1);
- VFS_UNLOCK_GIANT(vfslocked);
acct_state |= ACCT_EXITREQ;
return;
}
@@ -593,11 +579,8 @@ acctwatch(void)
* Stopping here is better than continuing, maybe it will be VBAD
* next time around.
*/
- if (VFS_STATFS(acct_vp->v_mount, &sb) < 0) {
- VFS_UNLOCK_GIANT(vfslocked);
+ if (VFS_STATFS(acct_vp->v_mount, &sb) < 0)
return;
- }
- VFS_UNLOCK_GIANT(vfslocked);
if (acct_suspended) {
if (sb.f_bavail > (int64_t)(acctresume * sb.f_blocks /
100)) {
diff --git a/sys/kern/kern_alq.c b/sys/kern/kern_alq.c
index 98e6de885cfb..893d2f83ee30 100644
--- a/sys/kern/kern_alq.c
+++ b/sys/kern/kern_alq.c
@@ -313,7 +313,6 @@ alq_doio(struct alq *alq)
struct iovec aiov[2];
int totlen;
int iov;
- int vfslocked;
int wrapearly;
KASSERT((HAS_PENDING_DATA(alq)), ("%s: queue empty!", __func__));
@@ -365,7 +364,6 @@ alq_doio(struct alq *alq)
/*
* Do all of the junk required to write now.
*/
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vn_start_write(vp, &mp, V_WAIT);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
/*
@@ -377,7 +375,6 @@ alq_doio(struct alq *alq)
VOP_WRITE(vp, &auio, IO_UNIT | IO_APPEND, alq->aq_cred);
VOP_UNLOCK(vp, 0);
vn_finished_write(mp);
- VFS_UNLOCK_GIANT(vfslocked);
ALQ_LOCK(alq);
alq->aq_flags &= ~AQ_FLUSHING;
@@ -438,25 +435,22 @@ alq_open_flags(struct alq **alqp, const char *file, struct ucred *cred, int cmod
struct alq *alq;
int oflags;
int error;
- int vfslocked;
KASSERT((size > 0), ("%s: size <= 0", __func__));
*alqp = NULL;
td = curthread;
- NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_SYSSPACE, file, td);
+ NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, file, td);
oflags = FWRITE | O_NOFOLLOW | O_CREAT;
error = vn_open_cred(&nd, &oflags, cmode, 0, cred, NULL);
if (error)
return (error);
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
/* We just unlock so we hold a reference */
VOP_UNLOCK(nd.ni_vp, 0);
- VFS_UNLOCK_GIANT(vfslocked);
alq = malloc(sizeof(*alq), M_ALD, M_WAITOK|M_ZERO);
alq->aq_vp = nd.ni_vp;
diff --git a/sys/kern/kern_ctf.c b/sys/kern/kern_ctf.c
index 5ded1bee92c7..319414c70699 100644
--- a/sys/kern/kern_ctf.c
+++ b/sys/kern/kern_ctf.c
@@ -69,7 +69,6 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc)
int i;
int nbytes;
ssize_t resid;
- int vfslocked;
size_t sz;
struct nameidata nd;
struct thread *td = curthread;
@@ -114,12 +113,11 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc)
*/
ef->ctfcnt = -1;
- NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, lf->pathname, td);
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, lf->pathname, td);
flags = FREAD;
error = vn_open(&nd, &flags, 0, NULL);
if (error)
return (error);
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
/* Allocate memory for the FLF header. */
@@ -323,7 +321,6 @@ link_elf_ctf_get(linker_file_t lf, linker_ctf_t *lc)
out:
VOP_UNLOCK(nd.ni_vp, 0);
vn_close(nd.ni_vp, FREAD, td->td_ucred, td);
- VFS_UNLOCK_GIANT(vfslocked);
if (hdr != NULL)
free(hdr, M_LINKER);
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index 9ed63697c417..1eb18f1f37b8 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -463,12 +463,10 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
char *pop;
struct vnode *vp;
int error, flg, tmp;
- int vfslocked;
u_int old, new;
uint64_t bsize;
off_t foffset;
- vfslocked = 0;
error = 0;
flg = F_POSIX;
p = td->td_proc;
@@ -637,7 +635,6 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
fhold(fp);
FILEDESC_SUNLOCK(fdp);
vp = fp->f_vnode;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
switch (flp->l_type) {
case F_RDLCK:
if ((fp->f_flag & FREAD) == 0) {
@@ -681,8 +678,6 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
error = EINVAL;
break;
}
- VFS_UNLOCK_GIANT(vfslocked);
- vfslocked = 0;
if (error != 0 || flp->l_type == F_UNLCK ||
flp->l_type == F_UNLCKSYS) {
fdrop(fp, td);
@@ -712,11 +707,8 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
flp->l_start = 0;
flp->l_len = 0;
flp->l_type = F_UNLCK;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
(void) VOP_ADVLOCK(vp, (caddr_t)p->p_leader,
F_UNLCK, flp, F_POSIX);
- VFS_UNLOCK_GIANT(vfslocked);
- vfslocked = 0;
} else
FILEDESC_SUNLOCK(fdp);
fdrop(fp, td);
@@ -759,11 +751,8 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
fhold(fp);
FILEDESC_SUNLOCK(fdp);
vp = fp->f_vnode;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
error = VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_GETLK, flp,
F_POSIX);
- VFS_UNLOCK_GIANT(vfslocked);
- vfslocked = 0;
fdrop(fp, td);
break;
@@ -786,7 +775,6 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
FILEDESC_SUNLOCK(fdp);
if (arg != 0) {
vp = fp->f_vnode;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
error = vn_lock(vp, LK_SHARED);
if (error != 0)
goto readahead_vnlock_fail;
@@ -797,9 +785,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
new = old = fp->f_flag;
new |= FRDAHEAD;
} while (!atomic_cmpset_rel_int(&fp->f_flag, old, new));
-readahead_vnlock_fail:
- VFS_UNLOCK_GIANT(vfslocked);
- vfslocked = 0;
+ readahead_vnlock_fail:;
} else {
do {
new = old = fp->f_flag;
@@ -813,7 +799,6 @@ readahead_vnlock_fail:
error = EINVAL;
break;
}
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -1404,13 +1389,9 @@ sys_fpathconf(struct thread *td, struct fpathconf_args *uap)
}
vp = fp->f_vnode;
if (vp != NULL) {
- int vfslocked;
-
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vn_lock(vp, LK_SHARED | LK_RETRY);
error = VOP_PATHCONF(vp, uap->name, td->td_retval);
VOP_UNLOCK(vp, 0);
- VFS_UNLOCK_GIANT(vfslocked);
} else if (fp->f_type == DTYPE_PIPE || fp->f_type == DTYPE_SOCKET) {
if (uap->name != _PC_PIPE_BUF) {
error = EINVAL;
@@ -1831,7 +1812,7 @@ void
fdfree(struct thread *td)
{
struct filedesc *fdp;
- int i, locked;
+ int i;
struct filedesc_to_leader *fdtol;
struct file *fp;
struct vnode *cdir, *jdir, *rdir, *vp;
@@ -1868,11 +1849,9 @@ fdfree(struct thread *td)
lf.l_len = 0;
lf.l_type = F_UNLCK;
vp = fp->f_vnode;
- locked = VFS_LOCK_GIANT(vp->v_mount);
(void) VOP_ADVLOCK(vp,
(caddr_t)td->td_proc->p_leader, F_UNLCK,
&lf, F_POSIX);
- VFS_UNLOCK_GIANT(locked);
FILEDESC_XLOCK(fdp);
fdrop(fp, td);
}
@@ -1950,21 +1929,12 @@ fdfree(struct thread *td)
fdp->fd_jdir = NULL;
FILEDESC_XUNLOCK(fdp);
- if (cdir) {
- locked = VFS_LOCK_GIANT(cdir->v_mount);
+ if (cdir)
vrele(cdir);
- VFS_UNLOCK_GIANT(locked);
- }
- if (rdir) {
- locked = VFS_LOCK_GIANT(rdir->v_mount);
+ if (rdir)
vrele(rdir);
- VFS_UNLOCK_GIANT(locked);
- }
- if (jdir) {
- locked = VFS_LOCK_GIANT(jdir->v_mount);
+ if (jdir)
vrele(jdir);
- VFS_UNLOCK_GIANT(locked);
- }
fddrop(fdp);
}
@@ -2163,10 +2133,7 @@ closef(struct file *fp, struct thread *td)
*/
(void)cap_funwrap(fp, 0, &fp_object);
if (fp_object->f_type == DTYPE_VNODE && td != NULL) {
- int vfslocked;
-
vp = fp_object->f_vnode;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
if ((td->td_proc->p_leader->p_flag & P_ADVLOCK) != 0) {
lf.l_whence = SEEK_SET;
lf.l_start = 0;
@@ -2209,7 +2176,6 @@ closef(struct file *fp, struct thread *td)
}
FILEDESC_XUNLOCK(fdp);
}
- VFS_UNLOCK_GIANT(vfslocked);
}
return (fdrop(fp, td));
}
@@ -2593,7 +2559,6 @@ sys_flock(struct thread *td, struct flock_args *uap)
struct file *fp;
struct vnode *vp;
struct flock lf;
- int vfslocked;
int error;
if ((error = fget(td, uap->fd, CAP_FLOCK, &fp)) != 0)
@@ -2604,7 +2569,6 @@ sys_flock(struct thread *td, struct flock_args *uap)
}
vp = fp->f_vnode;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
lf.l_whence = SEEK_SET;
lf.l_start = 0;
lf.l_len = 0;
@@ -2627,7 +2591,6 @@ sys_flock(struct thread *td, struct flock_args *uap)
(uap->how & LOCK_NB) ? F_FLOCK : F_FLOCK | F_WAIT);
done2:
fdrop(fp, td);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
/*
@@ -2883,7 +2846,6 @@ export_vnode_for_osysctl(struct vnode *vp, int type,
{
int error;
char *fullpath, *freepath;
- int vfslocked;
bzero(kif, sizeof(*kif));
kif->kf_structsize = sizeof(*kif);
@@ -2909,9 +2871,7 @@ export_vnode_for_osysctl(struct vnode *vp, int type,
fullpath = "-";
FILEDESC_SUNLOCK(fdp);
vn_fullpath(curthread, vp, &fullpath, &freepath);
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
strlcpy(kif->kf_path, fullpath, sizeof(kif->kf_path));
if (freepath != NULL)
free(freepath, M_TEMP);
@@ -2936,7 +2896,6 @@ sysctl_kern_proc_ofiledesc(SYSCTL_HANDLER_ARGS)
struct file *fp;
struct proc *p;
struct tty *tp;
- int vfslocked;
name = (int *)arg1;
if ((p = pfind((pid_t)name[0])) == NULL)
@@ -3103,9 +3062,7 @@ sysctl_kern_proc_ofiledesc(SYSCTL_HANDLER_ARGS)
fullpath = "-";
FILEDESC_SUNLOCK(fdp);
vn_fullpath(curthread, vp, &fullpath, &freepath);
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
strlcpy(kif->kf_path, fullpath,
sizeof(kif->kf_path));
if (freepath != NULL)
@@ -3181,7 +3138,7 @@ export_fd_for_sysctl(void *data, int type, int fd, int fflags, int refcnt,
};
#define NFFLAGS (sizeof(fflags_table) / sizeof(*fflags_table))
struct vnode *vp;
- int error, vfslocked;
+ int error;
unsigned int i;
bzero(kif, sizeof(*kif));
@@ -3190,9 +3147,7 @@ export_fd_for_sysctl(void *data, int type, int fd, int fflags, int refcnt,
case KF_TYPE_VNODE:
vp = (struct vnode *)data;
error = fill_vnode_info(vp, kif);
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
break;
case KF_TYPE_SOCKET:
error = fill_socket_info((struct socket *)data, kif);
@@ -3477,7 +3432,7 @@ fill_vnode_info(struct vnode *vp, struct kinfo_file *kif)
{
struct vattr va;
char *fullpath, *freepath;
- int error, vfslocked;
+ int error;
if (vp == NULL)
return (1);
@@ -3496,11 +3451,9 @@ fill_vnode_info(struct vnode *vp, struct kinfo_file *kif)
*/
va.va_fsid = VNOVAL;
va.va_rdev = NODEV;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vn_lock(vp, LK_SHARED | LK_RETRY);
error = VOP_GETATTR(vp, &va, curthread->td_ucred);
VOP_UNLOCK(vp, 0);
- VFS_UNLOCK_GIANT(vfslocked);
if (error != 0)
return (error);
if (va.va_fsid != VNOVAL)
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 22c53a5b0dac..0970562601e5 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -341,7 +341,6 @@ do_execve(td, args, mac_p)
#endif
struct vnode *textvp = NULL, *binvp = NULL;
int credential_changing;
- int vfslocked;
int textset;
#ifdef MAC
struct label *interpvplabel = NULL;
@@ -352,7 +351,6 @@ do_execve(td, args, mac_p)
#endif
static const char fexecv_proc_title[] = "(fexecv)";
- vfslocked = 0;
imgp = &image_params;
/*
@@ -412,7 +410,7 @@ do_execve(td, args, mac_p)
*/
if (args->fname != NULL) {
NDINIT(&nd, LOOKUP, ISOPEN | LOCKLEAF | FOLLOW | SAVENAME
- | MPSAFE | AUDITVNODE1, UIO_SYSSPACE, args->fname, td);
+ | AUDITVNODE1, UIO_SYSSPACE, args->fname, td);
}
SDT_PROBE(proc, kernel, , exec, args->fname, 0, 0, 0, 0 );
@@ -435,7 +433,6 @@ interpret:
if (error)
goto exec_fail;
- vfslocked = NDHASGIANT(&nd);
binvp = nd.ni_vp;
imgp->vp = binvp;
} else {
@@ -449,7 +446,6 @@ interpret:
error = fgetvp_exec(td, args->fd, CAP_FEXECVE, &binvp);
if (error)
goto exec_fail;
- vfslocked = VFS_LOCK_GIANT(binvp->v_mount);
vn_lock(binvp, LK_EXCLUSIVE | LK_RETRY);
AUDIT_ARG_VNODE1(binvp);
imgp->vp = binvp;
@@ -538,10 +534,8 @@ interpret:
vput(binvp);
vm_object_deallocate(imgp->object);
imgp->object = NULL;
- VFS_UNLOCK_GIANT(vfslocked);
- vfslocked = 0;
/* set new name to that of the interpreter */
- NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME | MPSAFE,
+ NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME,
UIO_SYSSPACE, imgp->interpreter_name, td);
args->fname = imgp->interpreter_name;
goto interpret;
@@ -844,23 +838,13 @@ done1:
/*
* Handle deferred decrement of ref counts.
*/
- if (textvp != NULL) {
- int tvfslocked;
-
- tvfslocked = VFS_LOCK_GIANT(textvp->v_mount);
+ if (textvp != NULL)
vrele(textvp);
- VFS_UNLOCK_GIANT(tvfslocked);
- }
if (binvp && error != 0)
vrele(binvp);
#ifdef KTRACE
- if (tracevp != NULL) {
- int tvfslocked;
-
- tvfslocked = VFS_LOCK_GIANT(tracevp->v_mount);
+ if (tracevp != NULL)
vrele(tracevp);
- VFS_UNLOCK_GIANT(tvfslocked);
- }
if (tracecred != NULL)
crfree(tracecred);
#endif
@@ -917,7 +901,6 @@ done2:
mac_execve_exit(imgp);
mac_execve_interpreter_exit(interpvplabel);
#endif
- VFS_UNLOCK_GIANT(vfslocked);
exec_free_args(args);
if (error && imgp->vmspace_destroyed) {
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 59f31f5901d8..c04b992d848a 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -135,7 +135,6 @@ exit1(struct thread *td, int rv)
struct vnode *vtmp;
struct vnode *ttyvp = NULL;
struct plimit *plim;
- int locked;
mtx_assert(&Giant, MA_NOTOWNED);
@@ -383,9 +382,7 @@ exit1(struct thread *td, int rv)
*/
if ((vtmp = p->p_textvp) != NULL) {
p->p_textvp = NULL;
- locked = VFS_LOCK_GIANT(vtmp->v_mount);
vrele(vtmp);
- VFS_UNLOCK_GIANT(locked);
}
/*
diff --git a/sys/kern/kern_gzio.c b/sys/kern/kern_gzio.c
index f10998e87cd9..15dc3015ca25 100644
--- a/sys/kern/kern_gzio.c
+++ b/sys/kern/kern_gzio.c
@@ -219,7 +219,6 @@ int ZEXPORT gzwrite (file, buf, len)
off_t curoff;
size_t resid;
int error;
- int vfslocked;
if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
@@ -232,11 +231,9 @@ int ZEXPORT gzwrite (file, buf, len)
if (s->stream.avail_out == 0) {
s->stream.next_out = s->outbuf;
- vfslocked = VFS_LOCK_GIANT(s->file->v_mount);
error = vn_rdwr_inchunks(UIO_WRITE, s->file, s->outbuf, Z_BUFSIZE,
curoff, UIO_SYSSPACE, IO_UNIT,
curproc->p_ucred, NOCRED, &resid, curthread);
- VFS_UNLOCK_GIANT(vfslocked);
if (error) {
log(LOG_ERR, "gzwrite: vn_rdwr return %d\n", error);
curoff += Z_BUFSIZE - resid;
@@ -274,7 +271,6 @@ local int do_flush (file, flush)
gz_stream *s = (gz_stream*)file;
off_t curoff = s->outoff;
size_t resid;
- int vfslocked = 0;
int error;
if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
@@ -289,11 +285,9 @@ local int do_flush (file, flush)
len = Z_BUFSIZE - s->stream.avail_out;
if (len != 0) {
- vfslocked = VFS_LOCK_GIANT(s->file->v_mount);
error = vn_rdwr_inchunks(UIO_WRITE, s->file, s->outbuf, len, curoff,
UIO_SYSSPACE, IO_UNIT, curproc->p_ucred,
NOCRED, &resid, curthread);
- VFS_UNLOCK_GIANT(vfslocked);
if (error) {
s->z_err = Z_ERRNO;
s->outoff = curoff + len - resid;
diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c
index 4639e3c64f71..2ff64d5820d9 100644
--- a/sys/kern/kern_jail.c
+++ b/sys/kern/kern_jail.c
@@ -543,7 +543,7 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags)
int created, cuflags, descend, enforce, error, errmsg_len, errmsg_pos;
int gotchildmax, gotenforce, gothid, gotrsnum, gotslevel;
int fi, jid, jsys, len, level;
- int childmax, rsnum, slevel, vfslocked;
+ int childmax, rsnum, slevel;
int fullpath_disabled;
#if defined(INET) || defined(INET6)
int ii, ij;
@@ -921,12 +921,11 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags)
error = EINVAL;
goto done_free;
}
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | MPSAFE, UIO_SYSSPACE,
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE,
path, td);
error = namei(&nd);
if (error)
goto done_free;
- vfslocked = NDHASGIANT(&nd);
root = nd.ni_vp;
NDFREE(&nd, NDF_ONLY_PNBUF);
g_path = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
@@ -941,17 +940,14 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags)
path = NULL;
} else {
/* exit on other errors */
- VFS_UNLOCK_GIANT(vfslocked);
goto done_free;
}
if (root->v_type != VDIR) {
error = ENOTDIR;
vput(root);
- VFS_UNLOCK_GIANT(vfslocked);
goto done_free;
}
VOP_UNLOCK(root, 0);
- VFS_UNLOCK_GIANT(vfslocked);
if (fullpath_disabled) {
/* Leave room for a real-root full pathname. */
if (len + (path[0] == '/' && strcmp(mypr->pr_path, "/")
@@ -1852,11 +1848,8 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags)
done_unlock_list:
sx_xunlock(&allprison_lock);
done_releroot:
- if (root != NULL) {
- vfslocked = VFS_LOCK_GIANT(root->v_mount);
+ if (root != NULL)
vrele(root);
- VFS_UNLOCK_GIANT(vfslocked);
- }
done_errmsg:
if (error) {
vfs_getopt(opts, "errmsg", (void **)&errmsg, &errmsg_len);
@@ -2337,7 +2330,7 @@ do_jail_attach(struct thread *td, struct prison *pr)
struct prison *ppr;
struct proc *p;
struct ucred *newcred, *oldcred;
- int vfslocked, error;
+ int error;
/*
* XXX: Note that there is a slight race here if two threads
@@ -2368,7 +2361,6 @@ do_jail_attach(struct thread *td, struct prison *pr)
if (error)
goto e_revert_osd;
- vfslocked = VFS_LOCK_GIANT(pr->pr_root->v_mount);
vn_lock(pr->pr_root, LK_EXCLUSIVE | LK_RETRY);
if ((error = change_dir(pr->pr_root, td)) != 0)
goto e_unlock;
@@ -2378,8 +2370,7 @@ do_jail_attach(struct thread *td, struct prison *pr)
#endif
VOP_UNLOCK(pr->pr_root, 0);
if ((error = change_root(pr->pr_root, td)))
- goto e_unlock_giant;
- VFS_UNLOCK_GIANT(vfslocked);
+ goto e_revert_osd;
newcred = crget();
PROC_LOCK(p);
@@ -2397,8 +2388,6 @@ do_jail_attach(struct thread *td, struct prison *pr)
return (0);
e_unlock:
VOP_UNLOCK(pr->pr_root, 0);
- e_unlock_giant:
- VFS_UNLOCK_GIANT(vfslocked);
e_revert_osd:
/* Tell modules this thread is still in its old jail after all. */
(void)osd_jail_call(ppr, PR_METHOD_ATTACH, td);
@@ -2547,7 +2536,6 @@ static void
prison_deref(struct prison *pr, int flags)
{
struct prison *ppr, *tpr;
- int vfslocked;
if (!(flags & PD_LOCKED))
mtx_lock(&pr->pr_mtx);
@@ -2588,11 +2576,8 @@ prison_deref(struct prison *pr, int flags)
if (pr->pr_vnet != ppr->pr_vnet)
vnet_destroy(pr->pr_vnet);
#endif
- if (pr->pr_root != NULL) {
- vfslocked = VFS_LOCK_GIANT(pr->pr_root->v_mount);
+ if (pr->pr_root != NULL)
vrele(pr->pr_root);
- VFS_UNLOCK_GIANT(vfslocked);
- }
mtx_destroy(&pr->pr_mtx);
#ifdef INET
free(pr->pr_ip4, M_PRISON);
diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c
index d40fe51f6543..e512a33b2c9c 100644
--- a/sys/kern/kern_ktrace.c
+++ b/sys/kern/kern_ktrace.c
@@ -512,7 +512,6 @@ ktrprocexit(struct thread *td)
struct proc *p;
struct ucred *cred;
struct vnode *vp;
- int vfslocked;
p = td->td_proc;
if (p->p_traceflag == 0)
@@ -530,11 +529,8 @@ ktrprocexit(struct thread *td)
ktr_freeproc(p, &cred, &vp);
mtx_unlock(&ktrace_mtx);
PROC_UNLOCK(p);
- if (vp != NULL) {
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
+ if (vp != NULL)
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
- }
if (cred != NULL)
crfree(cred);
ktrace_exit(td);
@@ -862,7 +858,7 @@ sys_ktrace(td, uap)
int ops = KTROP(uap->ops);
int descend = uap->ops & KTRFLAG_DESCEND;
int nfound, ret = 0;
- int flags, error = 0, vfslocked;
+ int flags, error = 0;
struct nameidata nd;
struct ucred *cred;
@@ -877,25 +873,21 @@ sys_ktrace(td, uap)
/*
* an operation which requires a file argument.
*/
- NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_USERSPACE,
- uap->fname, td);
+ NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->fname, td);
flags = FREAD | FWRITE | O_NOFOLLOW;
error = vn_open(&nd, &flags, 0, NULL);
if (error) {
ktrace_exit(td);
return (error);
}
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
vp = nd.ni_vp;
VOP_UNLOCK(vp, 0);
if (vp->v_type != VREG) {
(void) vn_close(vp, FREAD|FWRITE, td->td_ucred, td);
- VFS_UNLOCK_GIANT(vfslocked);
ktrace_exit(td);
return (EACCES);
}
- VFS_UNLOCK_GIANT(vfslocked);
}
/*
* Clear all uses of the tracefile.
@@ -921,10 +913,8 @@ sys_ktrace(td, uap)
}
sx_sunlock(&allproc_lock);
if (vrele_count > 0) {
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
while (vrele_count-- > 0)
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
}
goto done;
}
@@ -990,11 +980,8 @@ sys_ktrace(td, uap)
if (!ret)
error = EPERM;
done:
- if (vp != NULL) {
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
+ if (vp != NULL)
(void) vn_close(vp, FWRITE, td->td_ucred, td);
- VFS_UNLOCK_GIANT(vfslocked);
- }
ktrace_exit(td);
return (error);
#else /* !KTRACE */
@@ -1086,13 +1073,8 @@ ktrops(td, p, ops, facs, vp)
if ((p->p_traceflag & KTRFAC_MASK) != 0)
ktrprocctor_entered(td, p);
PROC_UNLOCK(p);
- if (tracevp != NULL) {
- int vfslocked;
-
- vfslocked = VFS_LOCK_GIANT(tracevp->v_mount);
+ if (tracevp != NULL)
vrele(tracevp);
- VFS_UNLOCK_GIANT(vfslocked);
- }
if (tracecred != NULL)
crfree(tracecred);
@@ -1146,7 +1128,7 @@ ktr_writerequest(struct thread *td, struct ktr_request *req)
struct iovec aiov[3];
struct mount *mp;
int datalen, buflen, vrele_count;
- int error, vfslocked;
+ int error;
/*
* We hold the vnode and credential for use in I/O in case ktrace is
@@ -1204,7 +1186,6 @@ ktr_writerequest(struct thread *td, struct ktr_request *req)
auio.uio_iovcnt++;
}
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vn_start_write(vp, &mp, V_WAIT);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
#ifdef MAC
@@ -1217,10 +1198,8 @@ ktr_writerequest(struct thread *td, struct ktr_request *req)
crfree(cred);
if (!error) {
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
return;
}
- VFS_UNLOCK_GIANT(vfslocked);
/*
* If error encountered, give up tracing on this vnode. We defer
@@ -1259,10 +1238,8 @@ ktr_writerequest(struct thread *td, struct ktr_request *req)
}
sx_sunlock(&allproc_lock);
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
while (vrele_count-- > 0)
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
}
/*
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c
index ef7ee3940040..b3ab4df35a27 100644
--- a/sys/kern/kern_linker.c
+++ b/sys/kern/kern_linker.c
@@ -1705,7 +1705,7 @@ linker_lookup_file(const char *path, int pathlen, const char *name,
struct nameidata nd;
struct thread *td = curthread; /* XXX */
char *result, **cpp, *sep;
- int error, len, extlen, reclen, flags, vfslocked;
+ int error, len, extlen, reclen, flags;
enum vtype type;
extlen = 0;
@@ -1726,18 +1726,16 @@ linker_lookup_file(const char *path, int pathlen, const char *name,
* Attempt to open the file, and return the path if
* we succeed and it's a regular file.
*/
- NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, result, td);
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, result, td);
flags = FREAD;
error = vn_open(&nd, &flags, 0, NULL);
if (error == 0) {
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
type = nd.ni_vp->v_type;
if (vap)
VOP_GETATTR(nd.ni_vp, vap, td->td_ucred);
VOP_UNLOCK(nd.ni_vp, 0);
vn_close(nd.ni_vp, FREAD, td->td_ucred, td);
- VFS_UNLOCK_GIANT(vfslocked);
if (type == VREG)
return (result);
}
@@ -1766,7 +1764,6 @@ linker_hints_lookup(const char *path, int pathlen, const char *modname,
u_char *cp, *recptr, *bufend, *result, *best, *pathbuf, *sep;
int error, ival, bestver, *intp, found, flags, clen, blen;
ssize_t reclen;
- int vfslocked = 0;
result = NULL;
bestver = found = 0;
@@ -1778,12 +1775,11 @@ linker_hints_lookup(const char *path, int pathlen, const char *modname,
snprintf(pathbuf, reclen, "%.*s%s%s", pathlen, path, sep,
linker_hintfile);
- NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_SYSSPACE, pathbuf, td);
+ NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, pathbuf, td);
flags = FREAD;
error = vn_open(&nd, &flags, 0, NULL);
if (error)
goto bad;
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
if (nd.ni_vp->v_type != VREG)
goto bad;
@@ -1807,7 +1803,6 @@ linker_hints_lookup(const char *path, int pathlen, const char *modname,
goto bad;
VOP_UNLOCK(nd.ni_vp, 0);
vn_close(nd.ni_vp, FREAD, cred, td);
- VFS_UNLOCK_GIANT(vfslocked);
nd.ni_vp = NULL;
if (reclen != 0) {
printf("can't read %zd\n", reclen);
@@ -1876,7 +1871,6 @@ bad:
if (nd.ni_vp != NULL) {
VOP_UNLOCK(nd.ni_vp, 0);
vn_close(nd.ni_vp, FREAD, cred, td);
- VFS_UNLOCK_GIANT(vfslocked);
}
/*
* If nothing found or hints is absent - fallback to the old
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index e54331e6ca0c..8ee043e15c55 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -1873,7 +1873,7 @@ sysctl_kern_proc_pathname(SYSCTL_HANDLER_ARGS)
struct proc *p;
struct vnode *vp;
char *retbuf, *freebuf;
- int error, vfslocked;
+ int error;
if (arglen != 1)
return (EINVAL);
@@ -1895,9 +1895,7 @@ sysctl_kern_proc_pathname(SYSCTL_HANDLER_ARGS)
if (*pidp != -1)
PROC_UNLOCK(p);
error = vn_fullpath(req->td, vp, &retbuf, &freebuf);
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
if (error)
return (error);
error = SYSCTL_OUT(req, retbuf, strlen(retbuf) + 1);
@@ -1964,7 +1962,6 @@ sysctl_kern_proc_ovmmap(SYSCTL_HANDLER_ARGS)
entry = entry->next) {
vm_object_t obj, tobj, lobj;
vm_offset_t addr;
- int vfslocked;
if (entry->eflags & MAP_ENTRY_IS_SUB_MAP)
continue;
@@ -2061,14 +2058,12 @@ sysctl_kern_proc_ovmmap(SYSCTL_HANDLER_ARGS)
vn_fullpath(curthread, vp, &fullpath,
&freepath);
cred = curthread->td_ucred;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vn_lock(vp, LK_SHARED | LK_RETRY);
if (VOP_GETATTR(vp, &va, cred) == 0) {
kve->kve_fileid = va.va_fileid;
kve->kve_fsid = va.va_fsid;
}
vput(vp);
- VFS_UNLOCK_GIANT(vfslocked);
}
} else {
kve->kve_type = KVME_TYPE_NONE;
@@ -2134,7 +2129,7 @@ sysctl_kern_proc_vmmap(SYSCTL_HANDLER_ARGS)
vm_object_t obj, tobj, lobj;
vm_offset_t addr;
vm_paddr_t locked_pa;
- int vfslocked, mincoreinfo;
+ int mincoreinfo;
if (entry->eflags & MAP_ENTRY_IS_SUB_MAP)
continue;
@@ -2239,7 +2234,6 @@ sysctl_kern_proc_vmmap(SYSCTL_HANDLER_ARGS)
&freepath);
kve->kve_vn_type = vntype_to_kinfo(vp->v_type);
cred = curthread->td_ucred;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vn_lock(vp, LK_SHARED | LK_RETRY);
if (VOP_GETATTR(vp, &va, cred) == 0) {
kve->kve_vn_fileid = va.va_fileid;
@@ -2251,7 +2245,6 @@ sysctl_kern_proc_vmmap(SYSCTL_HANDLER_ARGS)
kve->kve_status = KF_ATTR_VALID;
}
vput(vp);
- VFS_UNLOCK_GIANT(vfslocked);
}
} else {
kve->kve_type = KVME_TYPE_NONE;
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index deb20981a381..4749a859fb82 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -3123,11 +3123,10 @@ nomem:
int error, n;
int flags = O_CREAT | O_EXCL | FWRITE | O_NOFOLLOW;
int cmode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
- int vfslocked;
for (n = 0; n < num_cores; n++) {
temp[indexpos] = '0' + n;
- NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_SYSSPACE,
+ NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE,
temp, td);
error = vn_open(&nd, &flags, cmode, NULL);
if (error) {
@@ -3141,11 +3140,9 @@ nomem:
free(temp, M_TEMP);
return (NULL);
}
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
VOP_UNLOCK(nd.ni_vp, 0);
error = vn_close(nd.ni_vp, FWRITE, td->td_ucred, td);
- VFS_UNLOCK_GIANT(vfslocked);
if (error) {
log(LOG_ERR,
"pid %d (%s), uid (%u): Path `%s' failed "
@@ -3182,7 +3179,6 @@ coredump(struct thread *td)
struct mount *mp;
char *name; /* name of corefile */
off_t limit;
- int vfslocked;
int compress;
#ifdef COMPRESS_USER_CORES
@@ -3232,7 +3228,7 @@ coredump(struct thread *td)
PROC_UNLOCK(p);
restart:
- NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_SYSSPACE, name, td);
+ NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, td);
flags = O_CREAT | FWRITE | O_NOFOLLOW;
error = vn_open_cred(&nd, &flags, S_IRUSR | S_IWUSR, VN_OPEN_NOAUDIT,
cred, NULL);
@@ -3243,7 +3239,6 @@ restart:
free(name, M_TEMP);
return (error);
}
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
vp = nd.ni_vp;
@@ -3270,7 +3265,6 @@ restart:
goto out;
if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0)
goto out;
- VFS_UNLOCK_GIANT(vfslocked);
goto restart;
}
@@ -3303,7 +3297,6 @@ out:
audit_proc_coredump(td, name, error);
#endif
free(name, M_TEMP);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c
index c37525d80027..647ae0b0956c 100644
--- a/sys/kern/link_elf.c
+++ b/sys/kern/link_elf.c
@@ -750,17 +750,15 @@ link_elf_load_file(linker_class_t cls, const char* filename,
int symstrindex;
int symcnt;
int strcnt;
- int vfslocked;
shdr = NULL;
lf = NULL;
- NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, filename, td);
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, filename, td);
flags = FREAD;
error = vn_open(&nd, &flags, 0, NULL);
if (error != 0)
return (error);
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
if (nd.ni_vp->v_type != VREG) {
error = ENOEXEC;
@@ -1047,7 +1045,6 @@ nosyms:
out:
VOP_UNLOCK(nd.ni_vp, 0);
vn_close(nd.ni_vp, FREAD, td->td_ucred, td);
- VFS_UNLOCK_GIANT(vfslocked);
if (error != 0 && lf != NULL)
linker_file_unload(lf, LINKER_UNLOAD_FORCE);
if (shdr != NULL)
diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c
index 52d2b2e0a6dc..a9208df3a659 100644
--- a/sys/kern/link_elf_obj.c
+++ b/sys/kern/link_elf_obj.c
@@ -450,19 +450,17 @@ link_elf_load_file(linker_class_t cls, const char *filename,
int nsym;
int pb, rl, ra;
int alignmask;
- int vfslocked;
shdr = NULL;
lf = NULL;
mapsize = 0;
hdr = NULL;
- NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, filename, td);
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, filename, td);
flags = FREAD;
error = vn_open(&nd, &flags, 0, NULL);
if (error)
return error;
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
if (nd.ni_vp->v_type != VREG) {
error = ENOEXEC;
@@ -866,7 +864,6 @@ link_elf_load_file(linker_class_t cls, const char *filename,
out:
VOP_UNLOCK(nd.ni_vp, 0);
vn_close(nd.ni_vp, FREAD, td->td_ucred, td);
- VFS_UNLOCK_GIANT(vfslocked);
if (error && lf)
linker_file_unload(lf, LINKER_UNLOAD_FORCE);
if (hdr)
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c
index 3883fe4b3256..b1f81451eaff 100644
--- a/sys/kern/sys_process.c
+++ b/sys/kern/sys_process.c
@@ -335,7 +335,7 @@ ptrace_vm_entry(struct thread *td, struct proc *p, struct ptrace_vm_entry *pve)
struct vnode *vp;
char *freepath, *fullpath;
u_int pathlen;
- int error, index, vfslocked;
+ int error, index;
error = 0;
obj = NULL;
@@ -412,14 +412,12 @@ ptrace_vm_entry(struct thread *td, struct proc *p, struct ptrace_vm_entry *pve)
freepath = NULL;
fullpath = NULL;
vn_fullpath(td, vp, &fullpath, &freepath);
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vn_lock(vp, LK_SHARED | LK_RETRY);
if (VOP_GETATTR(vp, &vattr, td->td_ucred) == 0) {
pve->pve_fileid = vattr.va_fileid;
pve->pve_fsid = vattr.va_fsid;
}
vput(vp);
- VFS_UNLOCK_GIANT(vfslocked);
if (fullpath != NULL) {
pve->pve_pathlen = strlen(fullpath) + 1;
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 94dd1270b00d..8ecaa02ea251 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1834,7 +1834,6 @@ kern_sendfile(struct thread *td, struct sendfile_args *uap,
struct vm_page *pg;
off_t off, xfsize, fsbytes = 0, sbytes = 0, rem = 0;
int error, hdrlen = 0, mnw = 0;
- int vfslocked;
struct sendfile_sync *sfs = NULL;
/*
@@ -1846,7 +1845,6 @@ kern_sendfile(struct thread *td, struct sendfile_args *uap,
AUDIT_ARG_FD(uap->fd);
if ((error = fgetvp_read(td, uap->fd, CAP_READ, &vp)) != 0)
goto out;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vn_lock(vp, LK_SHARED | LK_RETRY);
if (vp->v_type == VREG) {
obj = vp->v_object;
@@ -1868,7 +1866,6 @@ kern_sendfile(struct thread *td, struct sendfile_args *uap,
}
}
VOP_UNLOCK(vp, 0);
- VFS_UNLOCK_GIANT(vfslocked);
if (obj == NULL) {
error = EINVAL;
goto out;
@@ -2098,7 +2095,6 @@ retry_space:
/*
* Get the page from backing store.
*/
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
error = vn_lock(vp, LK_SHARED);
if (error != 0)
goto after_read;
@@ -2116,7 +2112,6 @@ retry_space:
td->td_ucred, NOCRED, &resid, td);
VOP_UNLOCK(vp, 0);
after_read:
- VFS_UNLOCK_GIANT(vfslocked);
VM_OBJECT_LOCK(obj);
vm_page_io_finish(pg);
if (!error)
@@ -2270,11 +2265,8 @@ out:
}
if (obj != NULL)
vm_object_deallocate(obj);
- if (vp != NULL) {
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
+ if (vp != NULL)
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
- }
if (so)
fdrop(sock_fp, td);
if (m)
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index cefa808b53c3..cc5360f5c21d 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -454,7 +454,7 @@ uipc_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
{
struct sockaddr_un *soun = (struct sockaddr_un *)nam;
struct vattr vattr;
- int error, namelen, vfslocked;
+ int error, namelen;
struct nameidata nd;
struct unpcb *unp;
struct vnode *vp;
@@ -496,15 +496,13 @@ uipc_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
buf[namelen] = 0;
restart:
- vfslocked = 0;
- NDINIT(&nd, CREATE, MPSAFE | NOFOLLOW | LOCKPARENT | SAVENAME,
+ NDINIT(&nd, CREATE, NOFOLLOW | LOCKPARENT | SAVENAME,
UIO_SYSSPACE, buf, td);
/* SHOULD BE ABLE TO ADOPT EXISTING AND wakeup() ALA FIFO's */
error = namei(&nd);
if (error)
goto error;
vp = nd.ni_vp;
- vfslocked = NDHASGIANT(&nd);
if (vp != NULL || vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) {
NDFREE(&nd, NDF_ONLY_PNBUF);
if (nd.ni_dvp == vp)
@@ -519,7 +517,6 @@ restart:
error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH);
if (error)
goto error;
- VFS_UNLOCK_GIANT(vfslocked);
goto restart;
}
VATTR_NULL(&vattr);
@@ -551,12 +548,10 @@ restart:
UNP_LINK_WUNLOCK();
VOP_UNLOCK(vp, 0);
vn_finished_write(mp);
- VFS_UNLOCK_GIANT(vfslocked);
free(buf, M_TEMP);
return (0);
error:
- VFS_UNLOCK_GIANT(vfslocked);
UNP_PCB_LOCK(unp);
unp->unp_flags &= ~UNP_BINDING;
UNP_PCB_UNLOCK(unp);
@@ -674,13 +669,8 @@ uipc_detach(struct socket *so)
uma_zfree(unp_zone, unp);
} else
UNP_PCB_UNLOCK(unp);
- if (vp) {
- int vfslocked;
-
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
+ if (vp)
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
- }
if (local_unp_rights)
taskqueue_enqueue(taskqueue_thread, &unp_gc_task);
}
@@ -1246,7 +1236,7 @@ unp_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
struct vnode *vp;
struct socket *so2, *so3;
struct unpcb *unp, *unp2, *unp3;
- int error, len, vfslocked;
+ int error, len;
struct nameidata nd;
char buf[SOCK_MAXADDRLEN];
struct sockaddr *sa;
@@ -1274,7 +1264,7 @@ unp_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
UNP_PCB_UNLOCK(unp);
sa = malloc(sizeof(struct sockaddr_un), M_SONAME, M_WAITOK);
- NDINIT(&nd, LOOKUP, MPSAFE | FOLLOW | LOCKSHARED | LOCKLEAF,
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF,
UIO_SYSSPACE, buf, td);
error = namei(&nd);
if (error)
@@ -1282,7 +1272,6 @@ unp_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
else
vp = nd.ni_vp;
ASSERT_VOP_LOCKED(vp, "unp_connect");
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
if (error)
goto bad;
@@ -1299,7 +1288,6 @@ unp_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
error = VOP_ACCESS(vp, VWRITE, td->td_ucred, td);
if (error)
goto bad;
- VFS_UNLOCK_GIANT(vfslocked);
unp = sotounpcb(so);
KASSERT(unp != NULL, ("unp_connect: unp == NULL"));
@@ -1382,16 +1370,9 @@ unp_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
UNP_PCB_UNLOCK(unp);
bad2:
UNP_LINK_WUNLOCK();
- if (vfslocked)
- /*
- * Giant has been previously acquired. This means filesystem
- * isn't MPSAFE. Do it once again.
- */
- mtx_lock(&Giant);
bad:
if (vp != NULL)
vput(vp);
- VFS_UNLOCK_GIANT(vfslocked);
free(sa, M_SONAME);
UNP_LINK_WLOCK();
UNP_PCB_LOCK(unp);
diff --git a/sys/kern/vfs_acl.c b/sys/kern/vfs_acl.c
index 2516d5cf8a3b..6d04b0462940 100644
--- a/sys/kern/vfs_acl.c
+++ b/sys/kern/vfs_acl.c
@@ -327,16 +327,14 @@ int
sys___acl_get_file(struct thread *td, struct __acl_get_file_args *uap)
{
struct nameidata nd;
- int vfslocked, error;
+ int error;
- NDINIT(&nd, LOOKUP, MPSAFE|FOLLOW, UIO_USERSPACE, uap->path, td);
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, td);
error = namei(&nd);
- vfslocked = NDHASGIANT(&nd);
if (error == 0) {
error = vacl_get_acl(td, nd.ni_vp, uap->type, uap->aclp);
NDFREE(&nd, 0);
}
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -347,16 +345,14 @@ int
sys___acl_get_link(struct thread *td, struct __acl_get_link_args *uap)
{
struct nameidata nd;
- int vfslocked, error;
+ int error;
- NDINIT(&nd, LOOKUP, MPSAFE|NOFOLLOW, UIO_USERSPACE, uap->path, td);
+ NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, td);
error = namei(&nd);
- vfslocked = NDHASGIANT(&nd);
if (error == 0) {
error = vacl_get_acl(td, nd.ni_vp, uap->type, uap->aclp);
NDFREE(&nd, 0);
}
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -367,16 +363,14 @@ int
sys___acl_set_file(struct thread *td, struct __acl_set_file_args *uap)
{
struct nameidata nd;
- int vfslocked, error;
+ int error;
- NDINIT(&nd, LOOKUP, MPSAFE|FOLLOW, UIO_USERSPACE, uap->path, td);
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, td);
error = namei(&nd);
- vfslocked = NDHASGIANT(&nd);
if (error == 0) {
error = vacl_set_acl(td, nd.ni_vp, uap->type, uap->aclp);
NDFREE(&nd, 0);
}
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -387,16 +381,14 @@ int
sys___acl_set_link(struct thread *td, struct __acl_set_link_args *uap)
{
struct nameidata nd;
- int vfslocked, error;
+ int error;
- NDINIT(&nd, LOOKUP, MPSAFE|NOFOLLOW, UIO_USERSPACE, uap->path, td);
+ NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, td);
error = namei(&nd);
- vfslocked = NDHASGIANT(&nd);
if (error == 0) {
error = vacl_set_acl(td, nd.ni_vp, uap->type, uap->aclp);
NDFREE(&nd, 0);
}
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -407,14 +399,12 @@ int
sys___acl_get_fd(struct thread *td, struct __acl_get_fd_args *uap)
{
struct file *fp;
- int vfslocked, error;
+ int error;
error = getvnode(td->td_proc->p_fd, uap->filedes, CAP_ACL_GET, &fp);
if (error == 0) {
- vfslocked = VFS_LOCK_GIANT(fp->f_vnode->v_mount);
error = vacl_get_acl(td, fp->f_vnode, uap->type, uap->aclp);
fdrop(fp, td);
- VFS_UNLOCK_GIANT(vfslocked);
}
return (error);
}
@@ -426,14 +416,12 @@ int
sys___acl_set_fd(struct thread *td, struct __acl_set_fd_args *uap)
{
struct file *fp;
- int vfslocked, error;
+ int error;
error = getvnode(td->td_proc->p_fd, uap->filedes, CAP_ACL_SET, &fp);
if (error == 0) {
- vfslocked = VFS_LOCK_GIANT(fp->f_vnode->v_mount);
error = vacl_set_acl(td, fp->f_vnode, uap->type, uap->aclp);
fdrop(fp, td);
- VFS_UNLOCK_GIANT(vfslocked);
}
return (error);
}
@@ -445,16 +433,14 @@ int
sys___acl_delete_file(struct thread *td, struct __acl_delete_file_args *uap)
{
struct nameidata nd;
- int vfslocked, error;
+ int error;
- NDINIT(&nd, LOOKUP, MPSAFE|FOLLOW, UIO_USERSPACE, uap->path, td);
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, td);
error = namei(&nd);
- vfslocked = NDHASGIANT(&nd);
if (error == 0) {
error = vacl_delete(td, nd.ni_vp, uap->type);
NDFREE(&nd, 0);
}
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -465,16 +451,14 @@ int
sys___acl_delete_link(struct thread *td, struct __acl_delete_link_args *uap)
{
struct nameidata nd;
- int vfslocked, error;
+ int error;
- NDINIT(&nd, LOOKUP, MPSAFE|NOFOLLOW, UIO_USERSPACE, uap->path, td);
+ NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, td);
error = namei(&nd);
- vfslocked = NDHASGIANT(&nd);
if (error == 0) {
error = vacl_delete(td, nd.ni_vp, uap->type);
NDFREE(&nd, 0);
}
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -485,15 +469,13 @@ int
sys___acl_delete_fd(struct thread *td, struct __acl_delete_fd_args *uap)
{
struct file *fp;
- int vfslocked, error;
+ int error;
error = getvnode(td->td_proc->p_fd, uap->filedes, CAP_ACL_DELETE,
&fp);
if (error == 0) {
- vfslocked = VFS_LOCK_GIANT(fp->f_vnode->v_mount);
error = vacl_delete(td, fp->f_vnode, uap->type);
fdrop(fp, td);
- VFS_UNLOCK_GIANT(vfslocked);
}
return (error);
}
@@ -505,16 +487,14 @@ int
sys___acl_aclcheck_file(struct thread *td, struct __acl_aclcheck_file_args *uap)
{
struct nameidata nd;
- int vfslocked, error;
+ int error;
- NDINIT(&nd, LOOKUP, MPSAFE|FOLLOW, UIO_USERSPACE, uap->path, td);
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, td);
error = namei(&nd);
- vfslocked = NDHASGIANT(&nd);
if (error == 0) {
error = vacl_aclcheck(td, nd.ni_vp, uap->type, uap->aclp);
NDFREE(&nd, 0);
}
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -525,16 +505,14 @@ int
sys___acl_aclcheck_link(struct thread *td, struct __acl_aclcheck_link_args *uap)
{
struct nameidata nd;
- int vfslocked, error;
+ int error;
- NDINIT(&nd, LOOKUP, MPSAFE|NOFOLLOW, UIO_USERSPACE, uap->path, td);
+ NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, td);
error = namei(&nd);
- vfslocked = NDHASGIANT(&nd);
if (error == 0) {
error = vacl_aclcheck(td, nd.ni_vp, uap->type, uap->aclp);
NDFREE(&nd, 0);
}
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -545,15 +523,13 @@ int
sys___acl_aclcheck_fd(struct thread *td, struct __acl_aclcheck_fd_args *uap)
{
struct file *fp;
- int vfslocked, error;
+ int error;
error = getvnode(td->td_proc->p_fd, uap->filedes, CAP_ACL_CHECK,
&fp);
if (error == 0) {
- vfslocked = VFS_LOCK_GIANT(fp->f_vnode->v_mount);
error = vacl_aclcheck(td, fp->f_vnode, uap->type, uap->aclp);
fdrop(fp, td);
- VFS_UNLOCK_GIANT(vfslocked);
}
return (error);
}
diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c
index 76f8da6f663d..99b0197445a8 100644
--- a/sys/kern/vfs_aio.c
+++ b/sys/kern/vfs_aio.c
@@ -835,10 +835,8 @@ static int
aio_fsync_vnode(struct thread *td, struct vnode *vp)
{
struct mount *mp;
- int vfslocked;
int error;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0)
goto drop;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
@@ -852,7 +850,6 @@ aio_fsync_vnode(struct thread *td, struct vnode *vp)
VOP_UNLOCK(vp, 0);
vn_finished_write(mp);
drop:
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 626847c6fd3f..0480bd453d38 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -266,14 +266,13 @@ static struct mtx nblock;
/*
* Definitions for the buffer free lists.
*/
-#define BUFFER_QUEUES 6 /* number of free buffer queues */
+#define BUFFER_QUEUES 5 /* number of free buffer queues */
#define QUEUE_NONE 0 /* on no queue */
#define QUEUE_CLEAN 1 /* non-B_DELWRI buffers */
#define QUEUE_DIRTY 2 /* B_DELWRI buffers */
-#define QUEUE_DIRTY_GIANT 3 /* B_DELWRI buffers that need giant */
-#define QUEUE_EMPTYKVA 4 /* empty buffer headers w/KVA assignment */
-#define QUEUE_EMPTY 5 /* empty buffer headers */
+#define QUEUE_EMPTYKVA 3 /* empty buffer headers w/KVA assignment */
+#define QUEUE_EMPTY 4 /* empty buffer headers */
#define QUEUE_SENTINEL 1024 /* not an queue index, but mark for sentinel */
/* Queues for free buffers with various properties */
@@ -1461,10 +1460,7 @@ brelse(struct buf *bp)
TAILQ_INSERT_HEAD(&bufqueues[QUEUE_CLEAN], bp, b_freelist);
/* remaining buffers */
} else {
- if ((bp->b_flags & (B_DELWRI|B_NEEDSGIANT)) ==
- (B_DELWRI|B_NEEDSGIANT))
- bp->b_qindex = QUEUE_DIRTY_GIANT;
- else if (bp->b_flags & B_DELWRI)
+ if (bp->b_flags & B_DELWRI)
bp->b_qindex = QUEUE_DIRTY;
else
bp->b_qindex = QUEUE_CLEAN;
@@ -1561,10 +1557,7 @@ bqrelse(struct buf *bp)
panic("bqrelse: free buffer onto another queue???");
/* buffers with stale but valid contents */
if (bp->b_flags & B_DELWRI) {
- if (bp->b_flags & B_NEEDSGIANT)
- bp->b_qindex = QUEUE_DIRTY_GIANT;
- else
- bp->b_qindex = QUEUE_DIRTY;
+ bp->b_qindex = QUEUE_DIRTY;
TAILQ_INSERT_TAIL(&bufqueues[bp->b_qindex], bp, b_freelist);
} else {
/*
@@ -2170,12 +2163,6 @@ buf_do_flush(struct vnode *vp)
int flushed;
flushed = flushbufqueues(vp, QUEUE_DIRTY, 0);
- /* The list empty check here is slightly racy */
- if (!TAILQ_EMPTY(&bufqueues[QUEUE_DIRTY_GIANT])) {
- mtx_lock(&Giant);
- flushed += flushbufqueues(vp, QUEUE_DIRTY_GIANT, 0);
- mtx_unlock(&Giant);
- }
if (flushed == 0) {
/*
* Could not find any buffers without rollback
@@ -2183,12 +2170,6 @@ buf_do_flush(struct vnode *vp)
* in the hopes of eventually making progress.
*/
flushbufqueues(vp, QUEUE_DIRTY, 1);
- if (!TAILQ_EMPTY(
- &bufqueues[QUEUE_DIRTY_GIANT])) {
- mtx_lock(&Giant);
- flushbufqueues(vp, QUEUE_DIRTY_GIANT, 1);
- mtx_unlock(&Giant);
- }
}
return (flushed);
}
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index ea481f4c73d5..aea71af52107 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -1069,7 +1069,7 @@ kern___getcwd(struct thread *td, u_char *buf, enum uio_seg bufseg, u_int buflen)
char *bp, *tmpbuf;
struct filedesc *fdp;
struct vnode *cdir, *rdir;
- int error, vfslocked;
+ int error;
if (disablecwd)
return (ENODEV);
@@ -1087,12 +1087,8 @@ kern___getcwd(struct thread *td, u_char *buf, enum uio_seg bufseg, u_int buflen)
VREF(rdir);
FILEDESC_SUNLOCK(fdp);
error = vn_fullpath1(td, cdir, rdir, tmpbuf, &bp, buflen);
- vfslocked = VFS_LOCK_GIANT(rdir->v_mount);
vrele(rdir);
- VFS_UNLOCK_GIANT(vfslocked);
- vfslocked = VFS_LOCK_GIANT(cdir->v_mount);
vrele(cdir);
- VFS_UNLOCK_GIANT(vfslocked);
if (!error) {
if (bufseg == UIO_SYSSPACE)
@@ -1139,7 +1135,7 @@ vn_fullpath(struct thread *td, struct vnode *vn, char **retbuf, char **freebuf)
char *buf;
struct filedesc *fdp;
struct vnode *rdir;
- int error, vfslocked;
+ int error;
if (disablefullpath)
return (ENODEV);
@@ -1153,9 +1149,7 @@ vn_fullpath(struct thread *td, struct vnode *vn, char **retbuf, char **freebuf)
VREF(rdir);
FILEDESC_SUNLOCK(fdp);
error = vn_fullpath1(td, vn, rdir, buf, retbuf, MAXPATHLEN);
- vfslocked = VFS_LOCK_GIANT(rdir->v_mount);
vrele(rdir);
- VFS_UNLOCK_GIANT(vfslocked);
if (!error)
*freebuf = buf;
@@ -1208,7 +1202,7 @@ vn_vptocnp_locked(struct vnode **vp, struct ucred *cred, char *buf,
{
struct vnode *dvp;
struct namecache *ncp;
- int error, vfslocked;
+ int error;
TAILQ_FOREACH(ncp, &((*vp)->v_cache_dst), nc_dst) {
if ((ncp->nc_flag & NCF_ISDOTDOT) == 0)
@@ -1217,9 +1211,7 @@ vn_vptocnp_locked(struct vnode **vp, struct ucred *cred, char *buf,
if (ncp != NULL) {
if (*buflen < ncp->nc_nlen) {
CACHE_RUNLOCK();
- vfslocked = VFS_LOCK_GIANT((*vp)->v_mount);
vrele(*vp);
- VFS_UNLOCK_GIANT(vfslocked);
numfullpathfail4++;
error = ENOMEM;
SDT_PROBE(vfs, namecache, fullpath, return, error,
@@ -1234,20 +1226,16 @@ vn_vptocnp_locked(struct vnode **vp, struct ucred *cred, char *buf,
*vp = ncp->nc_dvp;
vref(*vp);
CACHE_RUNLOCK();
- vfslocked = VFS_LOCK_GIANT(dvp->v_mount);
vrele(dvp);
- VFS_UNLOCK_GIANT(vfslocked);
CACHE_RLOCK();
return (0);
}
SDT_PROBE(vfs, namecache, fullpath, miss, vp, 0, 0, 0, 0);
CACHE_RUNLOCK();
- vfslocked = VFS_LOCK_GIANT((*vp)->v_mount);
vn_lock(*vp, LK_SHARED | LK_RETRY);
error = VOP_VPTOCNP(*vp, &dvp, cred, buf, buflen);
vput(*vp);
- VFS_UNLOCK_GIANT(vfslocked);
if (error) {
numfullpathfail2++;
SDT_PROBE(vfs, namecache, fullpath, return, error, vp,
@@ -1260,9 +1248,7 @@ vn_vptocnp_locked(struct vnode **vp, struct ucred *cred, char *buf,
if (dvp->v_iflag & VI_DOOMED) {
/* forced unmount */
CACHE_RUNLOCK();
- vfslocked = VFS_LOCK_GIANT(dvp->v_mount);
vrele(dvp);
- VFS_UNLOCK_GIANT(vfslocked);
error = ENOENT;
SDT_PROBE(vfs, namecache, fullpath, return, error, vp,
NULL, 0, 0);
@@ -1282,7 +1268,7 @@ static int
vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode *rdir,
char *buf, char **retbuf, u_int buflen)
{
- int error, slash_prefixed, vfslocked;
+ int error, slash_prefixed;
#ifdef KDTRACE_HOOKS
struct vnode *startvp = vp;
#endif
@@ -1303,9 +1289,7 @@ vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode *rdir,
return (error);
if (buflen == 0) {
CACHE_RUNLOCK();
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (ENOMEM);
}
buf[--buflen] = '/';
@@ -1315,9 +1299,7 @@ vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode *rdir,
if (vp->v_vflag & VV_ROOT) {
if (vp->v_iflag & VI_DOOMED) { /* forced unmount */
CACHE_RUNLOCK();
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
error = ENOENT;
SDT_PROBE(vfs, namecache, fullpath, return,
error, vp, NULL, 0, 0);
@@ -1326,18 +1308,14 @@ vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode *rdir,
vp1 = vp->v_mount->mnt_vnodecovered;
vref(vp1);
CACHE_RUNLOCK();
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
vp = vp1;
CACHE_RLOCK();
continue;
}
if (vp->v_type != VDIR) {
CACHE_RUNLOCK();
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
numfullpathfail1++;
error = ENOTDIR;
SDT_PROBE(vfs, namecache, fullpath, return,
@@ -1349,9 +1327,7 @@ vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode *rdir,
break;
if (buflen == 0) {
CACHE_RUNLOCK();
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
error = ENOMEM;
SDT_PROBE(vfs, namecache, fullpath, return, error,
startvp, NULL, 0, 0);
@@ -1365,9 +1341,7 @@ vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode *rdir,
if (!slash_prefixed) {
if (buflen == 0) {
CACHE_RUNLOCK();
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
numfullpathfail4++;
SDT_PROBE(vfs, namecache, fullpath, return, ENOMEM,
startvp, NULL, 0, 0);
@@ -1377,9 +1351,7 @@ vn_fullpath1(struct thread *td, struct vnode *vp, struct vnode *rdir,
}
numfullpathfound++;
CACHE_RUNLOCK();
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
SDT_PROBE(vfs, namecache, fullpath, return, 0, startvp, buf + buflen,
0, 0);
@@ -1441,9 +1413,8 @@ vn_path_to_global_path(struct thread *td, struct vnode *vp, char *path,
struct nameidata nd;
struct vnode *vp1;
char *rpath, *fbuf;
- int error, vfslocked;
+ int error;
- VFS_ASSERT_GIANT(vp->v_mount);
ASSERT_VOP_ELOCKED(vp, __func__);
/* Return ENODEV if sysctl debug.disablefullpath==1 */
@@ -1470,14 +1441,13 @@ vn_path_to_global_path(struct thread *td, struct vnode *vp, char *path,
* As a side effect, the vnode is relocked.
* If vnode was renamed, return ENOENT.
*/
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1,
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1,
UIO_SYSSPACE, path, td);
error = namei(&nd);
if (error != 0) {
vrele(vp);
goto out;
}
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
vp1 = nd.ni_vp;
vrele(vp);
@@ -1487,7 +1457,6 @@ vn_path_to_global_path(struct thread *td, struct vnode *vp, char *path,
vput(vp1);
error = ENOENT;
}
- VFS_UNLOCK_GIANT(vfslocked);
out:
free(fbuf, M_TEMP);
diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c
index 31a650c48986..0112dcbaaa5d 100644
--- a/sys/kern/vfs_default.c
+++ b/sys/kern/vfs_default.c
@@ -1009,7 +1009,7 @@ vop_stdadvise(struct vop_advise_args *ap)
{
struct vnode *vp;
off_t start, end;
- int error, vfslocked;
+ int error;
vp = ap->a_vp;
switch (ap->a_advice) {
@@ -1030,11 +1030,9 @@ vop_stdadvise(struct vop_advise_args *ap)
* requested range.
*/
error = 0;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
if (vp->v_iflag & VI_DOOMED) {
VOP_UNLOCK(vp, 0);
- VFS_UNLOCK_GIANT(vfslocked);
break;
}
vinvalbuf(vp, V_CLEANONLY, 0, 0);
@@ -1047,7 +1045,6 @@ vop_stdadvise(struct vop_advise_args *ap)
VM_OBJECT_UNLOCK(vp->v_object);
}
VOP_UNLOCK(vp, 0);
- VFS_UNLOCK_GIANT(vfslocked);
break;
default:
error = EINVAL;
diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c
index a6355d926bfe..85fc839aaae7 100644
--- a/sys/kern/vfs_extattr.c
+++ b/sys/kern/vfs_extattr.c
@@ -69,7 +69,7 @@ sys_extattrctl(td, uap)
struct nameidata nd;
struct mount *mp, *mp_writable;
char attrname[EXTATTR_MAXNAMELEN];
- int vfslocked, fnvfslocked, error;
+ int error;
AUDIT_ARG_CMD(uap->cmd);
AUDIT_ARG_VALUE(uap->attrnamespace);
@@ -85,27 +85,24 @@ sys_extattrctl(td, uap)
}
AUDIT_ARG_TEXT(attrname);
- vfslocked = fnvfslocked = 0;
mp = NULL;
filename_vp = NULL;
if (uap->filename != NULL) {
- NDINIT(&nd, LOOKUP, MPSAFE | FOLLOW | AUDITVNODE2,
+ NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE2,
UIO_USERSPACE, uap->filename, td);
error = namei(&nd);
if (error)
return (error);
- fnvfslocked = NDHASGIANT(&nd);
filename_vp = nd.ni_vp;
NDFREE(&nd, NDF_NO_VP_RELE);
}
/* uap->path is always defined. */
- NDINIT(&nd, LOOKUP, MPSAFE | FOLLOW | LOCKLEAF | AUDITVNODE1,
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1,
UIO_USERSPACE, uap->path, td);
error = namei(&nd);
if (error)
goto out;
- vfslocked = NDHASGIANT(&nd);
mp = nd.ni_vp->v_mount;
error = vfs_busy(mp, 0);
if (error) {
@@ -145,8 +142,6 @@ out:
*/
if (filename_vp != NULL)
vrele(filename_vp);
- VFS_UNLOCK_GIANT(fnvfslocked);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -170,7 +165,6 @@ extattr_set_vp(struct vnode *vp, int attrnamespace, const char *attrname,
ssize_t cnt;
int error;
- VFS_ASSERT_GIANT(vp->v_mount);
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
if (error)
return (error);
@@ -222,7 +216,7 @@ sys_extattr_set_fd(td, uap)
{
struct file *fp;
char attrname[EXTATTR_MAXNAMELEN];
- int vfslocked, error;
+ int error;
AUDIT_ARG_FD(uap->fd);
AUDIT_ARG_VALUE(uap->attrnamespace);
@@ -235,11 +229,9 @@ sys_extattr_set_fd(td, uap)
if (error)
return (error);
- vfslocked = VFS_LOCK_GIANT(fp->f_vnode->v_mount);
error = extattr_set_vp(fp->f_vnode, uap->attrnamespace,
attrname, uap->data, uap->nbytes, td);
fdrop(fp, td);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -257,7 +249,7 @@ sys_extattr_set_file(td, uap)
{
struct nameidata nd;
char attrname[EXTATTR_MAXNAMELEN];
- int vfslocked, error;
+ int error;
AUDIT_ARG_VALUE(uap->attrnamespace);
error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL);
@@ -265,19 +257,17 @@ sys_extattr_set_file(td, uap)
return (error);
AUDIT_ARG_TEXT(attrname);
- NDINIT(&nd, LOOKUP, MPSAFE | FOLLOW | AUDITVNODE1, UIO_USERSPACE,
+ NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, UIO_USERSPACE,
uap->path, td);
error = namei(&nd);
if (error)
return (error);
NDFREE(&nd, NDF_ONLY_PNBUF);
- vfslocked = NDHASGIANT(&nd);
error = extattr_set_vp(nd.ni_vp, uap->attrnamespace, attrname,
uap->data, uap->nbytes, td);
vrele(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -294,7 +284,7 @@ sys_extattr_set_link(td, uap)
{
struct nameidata nd;
char attrname[EXTATTR_MAXNAMELEN];
- int vfslocked, error;
+ int error;
AUDIT_ARG_VALUE(uap->attrnamespace);
error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL);
@@ -302,19 +292,17 @@ sys_extattr_set_link(td, uap)
return (error);
AUDIT_ARG_TEXT(attrname);
- NDINIT(&nd, LOOKUP, MPSAFE | NOFOLLOW | AUDITVNODE1, UIO_USERSPACE,
+ NDINIT(&nd, LOOKUP, NOFOLLOW | AUDITVNODE1, UIO_USERSPACE,
uap->path, td);
error = namei(&nd);
if (error)
return (error);
NDFREE(&nd, NDF_ONLY_PNBUF);
- vfslocked = NDHASGIANT(&nd);
error = extattr_set_vp(nd.ni_vp, uap->attrnamespace, attrname,
uap->data, uap->nbytes, td);
vrele(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -338,7 +326,6 @@ extattr_get_vp(struct vnode *vp, int attrnamespace, const char *attrname,
size_t size, *sizep;
int error;
- VFS_ASSERT_GIANT(vp->v_mount);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
/*
@@ -402,7 +389,7 @@ sys_extattr_get_fd(td, uap)
{
struct file *fp;
char attrname[EXTATTR_MAXNAMELEN];
- int vfslocked, error;
+ int error;
AUDIT_ARG_FD(uap->fd);
AUDIT_ARG_VALUE(uap->attrnamespace);
@@ -415,12 +402,10 @@ sys_extattr_get_fd(td, uap)
if (error)
return (error);
- vfslocked = VFS_LOCK_GIANT(fp->f_vnode->v_mount);
error = extattr_get_vp(fp->f_vnode, uap->attrnamespace,
attrname, uap->data, uap->nbytes, td);
fdrop(fp, td);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -437,7 +422,7 @@ sys_extattr_get_file(td, uap)
{
struct nameidata nd;
char attrname[EXTATTR_MAXNAMELEN];
- int vfslocked, error;
+ int error;
AUDIT_ARG_VALUE(uap->attrnamespace);
error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL);
@@ -445,19 +430,16 @@ sys_extattr_get_file(td, uap)
return (error);
AUDIT_ARG_TEXT(attrname);
- NDINIT(&nd, LOOKUP, MPSAFE | FOLLOW | AUDITVNODE1, UIO_USERSPACE,
- uap->path, td);
+ NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->path, td);
error = namei(&nd);
if (error)
return (error);
NDFREE(&nd, NDF_ONLY_PNBUF);
- vfslocked = NDHASGIANT(&nd);
error = extattr_get_vp(nd.ni_vp, uap->attrnamespace, attrname,
uap->data, uap->nbytes, td);
vrele(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -474,7 +456,7 @@ sys_extattr_get_link(td, uap)
{
struct nameidata nd;
char attrname[EXTATTR_MAXNAMELEN];
- int vfslocked, error;
+ int error;
AUDIT_ARG_VALUE(uap->attrnamespace);
error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL);
@@ -482,19 +464,17 @@ sys_extattr_get_link(td, uap)
return (error);
AUDIT_ARG_TEXT(attrname);
- NDINIT(&nd, LOOKUP, MPSAFE | NOFOLLOW | AUDITVNODE1, UIO_USERSPACE,
- uap->path, td);
+ NDINIT(&nd, LOOKUP, NOFOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->path,
+ td);
error = namei(&nd);
if (error)
return (error);
NDFREE(&nd, NDF_ONLY_PNBUF);
- vfslocked = NDHASGIANT(&nd);
error = extattr_get_vp(nd.ni_vp, uap->attrnamespace, attrname,
uap->data, uap->nbytes, td);
vrele(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -515,7 +495,6 @@ extattr_delete_vp(struct vnode *vp, int attrnamespace, const char *attrname,
struct mount *mp;
int error;
- VFS_ASSERT_GIANT(vp->v_mount);
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
if (error)
return (error);
@@ -552,7 +531,7 @@ sys_extattr_delete_fd(td, uap)
{
struct file *fp;
char attrname[EXTATTR_MAXNAMELEN];
- int vfslocked, error;
+ int error;
AUDIT_ARG_FD(uap->fd);
AUDIT_ARG_VALUE(uap->attrnamespace);
@@ -566,11 +545,9 @@ sys_extattr_delete_fd(td, uap)
if (error)
return (error);
- vfslocked = VFS_LOCK_GIANT(fp->f_vnode->v_mount);
error = extattr_delete_vp(fp->f_vnode, uap->attrnamespace,
attrname, td);
fdrop(fp, td);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -585,7 +562,7 @@ sys_extattr_delete_file(td, uap)
{
struct nameidata nd;
char attrname[EXTATTR_MAXNAMELEN];
- int vfslocked, error;
+ int error;
AUDIT_ARG_VALUE(uap->attrnamespace);
error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL);
@@ -593,17 +570,14 @@ sys_extattr_delete_file(td, uap)
return(error);
AUDIT_ARG_TEXT(attrname);
- NDINIT(&nd, LOOKUP, MPSAFE | FOLLOW | AUDITVNODE1, UIO_USERSPACE,
- uap->path, td);
+ NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->path, td);
error = namei(&nd);
if (error)
return(error);
NDFREE(&nd, NDF_ONLY_PNBUF);
- vfslocked = NDHASGIANT(&nd);
error = extattr_delete_vp(nd.ni_vp, uap->attrnamespace, attrname, td);
vrele(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
return(error);
}
@@ -618,7 +592,7 @@ sys_extattr_delete_link(td, uap)
{
struct nameidata nd;
char attrname[EXTATTR_MAXNAMELEN];
- int vfslocked, error;
+ int error;
AUDIT_ARG_VALUE(uap->attrnamespace);
error = copyinstr(uap->attrname, attrname, EXTATTR_MAXNAMELEN, NULL);
@@ -626,17 +600,14 @@ sys_extattr_delete_link(td, uap)
return(error);
AUDIT_ARG_TEXT(attrname);
- NDINIT(&nd, LOOKUP, MPSAFE | NOFOLLOW | AUDITVNODE1, UIO_USERSPACE,
- uap->path, td);
+ NDINIT(&nd, LOOKUP, NOFOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->path, td);
error = namei(&nd);
if (error)
return(error);
NDFREE(&nd, NDF_ONLY_PNBUF);
- vfslocked = NDHASGIANT(&nd);
error = extattr_delete_vp(nd.ni_vp, uap->attrnamespace, attrname, td);
vrele(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
return(error);
}
@@ -660,7 +631,6 @@ extattr_list_vp(struct vnode *vp, int attrnamespace, void *data,
ssize_t cnt;
int error;
- VFS_ASSERT_GIANT(vp->v_mount);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
auiop = NULL;
@@ -717,7 +687,7 @@ sys_extattr_list_fd(td, uap)
} */ *uap;
{
struct file *fp;
- int vfslocked, error;
+ int error;
AUDIT_ARG_FD(uap->fd);
AUDIT_ARG_VALUE(uap->attrnamespace);
@@ -725,12 +695,10 @@ sys_extattr_list_fd(td, uap)
if (error)
return (error);
- vfslocked = VFS_LOCK_GIANT(fp->f_vnode->v_mount);
error = extattr_list_vp(fp->f_vnode, uap->attrnamespace, uap->data,
uap->nbytes, td);
fdrop(fp, td);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -745,22 +713,19 @@ sys_extattr_list_file(td, uap)
} */ *uap;
{
struct nameidata nd;
- int vfslocked, error;
+ int error;
AUDIT_ARG_VALUE(uap->attrnamespace);
- NDINIT(&nd, LOOKUP, MPSAFE | FOLLOW | AUDITVNODE1, UIO_USERSPACE,
- uap->path, td);
+ NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->path, td);
error = namei(&nd);
if (error)
return (error);
NDFREE(&nd, NDF_ONLY_PNBUF);
- vfslocked = NDHASGIANT(&nd);
error = extattr_list_vp(nd.ni_vp, uap->attrnamespace, uap->data,
uap->nbytes, td);
vrele(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -775,21 +740,19 @@ sys_extattr_list_link(td, uap)
} */ *uap;
{
struct nameidata nd;
- int vfslocked, error;
+ int error;
AUDIT_ARG_VALUE(uap->attrnamespace);
- NDINIT(&nd, LOOKUP, MPSAFE | NOFOLLOW | AUDITVNODE1, UIO_USERSPACE,
- uap->path, td);
+ NDINIT(&nd, LOOKUP, NOFOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->path,
+ td);
error = namei(&nd);
if (error)
return (error);
NDFREE(&nd, NDF_ONLY_PNBUF);
- vfslocked = NDHASGIANT(&nd);
error = extattr_list_vp(nd.ni_vp, uap->attrnamespace, uap->data,
uap->nbytes, td);
vrele(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
diff --git a/sys/kern/vfs_init.c b/sys/kern/vfs_init.c
index 0165b38c3cd5..8172f18ed2bc 100644
--- a/sys/kern/vfs_init.c
+++ b/sys/kern/vfs_init.c
@@ -166,7 +166,7 @@ vfs_register(struct vfsconf *vfc)
return (EINVAL);
}
if (vfs_byname(vfc->vfc_name) != NULL)
- return EEXIST;
+ return (EEXIST);
if (vfs_typenumhash != 0) {
/*
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c
index d53dbd0bb84c..cbb1855a9aa4 100644
--- a/sys/kern/vfs_lookup.c
+++ b/sys/kern/vfs_lookup.c
@@ -133,10 +133,7 @@ namei(struct nameidata *ndp)
struct componentname *cnp = &ndp->ni_cnd;
struct thread *td = cnp->cn_thread;
struct proc *p = td->td_proc;
- int vfslocked;
- KASSERT((cnp->cn_flags & MPSAFE) != 0 || mtx_owned(&Giant) != 0,
- ("NOT MPSAFE and Giant not held"));
ndp->ni_cnd.cn_cred = ndp->ni_cnd.cn_thread->td_ucred;
KASSERT(cnp->cn_cred && p, ("namei: bad cred/proc"));
KASSERT((cnp->cn_nameiop & (~OPMASK)) == 0,
@@ -249,9 +246,7 @@ namei(struct nameidata *ndp)
if (error != 0 || dp != NULL) {
FILEDESC_SUNLOCK(fdp);
if (error == 0 && dp->v_type != VDIR) {
- vfslocked = VFS_LOCK_GIANT(dp->v_mount);
vrele(dp);
- VFS_UNLOCK_GIANT(vfslocked);
error = ENOTDIR;
}
}
@@ -268,15 +263,11 @@ namei(struct nameidata *ndp)
dp = fdp->fd_cdir;
VREF(dp);
FILEDESC_SUNLOCK(fdp);
- if (ndp->ni_startdir != NULL) {
- vfslocked = VFS_LOCK_GIANT(ndp->ni_startdir->v_mount);
+ if (ndp->ni_startdir != NULL)
vrele(ndp->ni_startdir);
- VFS_UNLOCK_GIANT(vfslocked);
- }
}
SDT_PROBE(vfs, namei, lookup, entry, dp, cnp->cn_pnbuf,
cnp->cn_flags, 0, 0);
- vfslocked = VFS_LOCK_GIANT(dp->v_mount);
for (;;) {
/*
* Check if root directory should replace current directory.
@@ -285,7 +276,6 @@ namei(struct nameidata *ndp)
cnp->cn_nameptr = cnp->cn_pnbuf;
if (*(cnp->cn_nameptr) == '/') {
vrele(dp);
- VFS_UNLOCK_GIANT(vfslocked);
if (ndp->ni_strictrelative != 0) {
#ifdef KTRACE
if (KTRPOINT(curthread, KTR_CAPFAIL))
@@ -298,11 +288,8 @@ namei(struct nameidata *ndp)
ndp->ni_pathlen--;
}
dp = ndp->ni_rootdir;
- vfslocked = VFS_LOCK_GIANT(dp->v_mount);
VREF(dp);
}
- if (vfslocked)
- ndp->ni_cnd.cn_flags |= GIANTHELD;
ndp->ni_startdir = dp;
error = lookup(ndp);
if (error) {
@@ -315,8 +302,6 @@ namei(struct nameidata *ndp)
0, 0);
return (error);
}
- vfslocked = (ndp->ni_cnd.cn_flags & GIANTHELD) != 0;
- ndp->ni_cnd.cn_flags &= ~GIANTHELD;
/*
* If not a symbolic link, we're done.
*/
@@ -330,10 +315,6 @@ namei(struct nameidata *ndp)
} else
cnp->cn_flags |= HASBUF;
- if ((cnp->cn_flags & MPSAFE) == 0) {
- VFS_UNLOCK_GIANT(vfslocked);
- } else if (vfslocked)
- ndp->ni_cnd.cn_flags |= GIANTHELD;
SDT_PROBE(vfs, namei, lookup, return, 0, ndp->ni_vp,
0, 0, 0);
return (0);
@@ -400,7 +381,6 @@ namei(struct nameidata *ndp)
vput(ndp->ni_vp);
ndp->ni_vp = NULL;
vrele(ndp->ni_dvp);
- VFS_UNLOCK_GIANT(vfslocked);
SDT_PROBE(vfs, namei, lookup, return, error, NULL, 0, 0, 0);
return (error);
}
@@ -506,19 +486,13 @@ lookup(struct nameidata *ndp)
int error = 0;
int dpunlocked = 0; /* dp has already been unlocked */
struct componentname *cnp = &ndp->ni_cnd;
- int vfslocked; /* VFS Giant state for child */
- int dvfslocked; /* VFS Giant state for parent */
- int tvfslocked;
int lkflags_save;
int ni_dvp_unlocked;
/*
* Setup: break out flag bits into variables.
*/
- dvfslocked = (ndp->ni_cnd.cn_flags & GIANTHELD) != 0;
- vfslocked = 0;
ni_dvp_unlocked = 0;
- ndp->ni_cnd.cn_flags &= ~GIANTHELD;
wantparent = cnp->cn_flags & (LOCKPARENT | WANTPARENT);
KASSERT(cnp->cn_nameiop == LOOKUP || wantparent,
("CREATE, DELETE, RENAME require LOCKPARENT or WANTPARENT."));
@@ -684,7 +658,6 @@ dirloop:
(cnp->cn_flags & NOCROSSMOUNT) != 0)) {
ndp->ni_dvp = dp;
ndp->ni_vp = dp;
- vfslocked = VFS_LOCK_GIANT(dp->v_mount);
VREF(dp);
goto nextname;
}
@@ -696,11 +669,8 @@ dirloop:
}
tdp = dp;
dp = dp->v_mount->mnt_vnodecovered;
- tvfslocked = dvfslocked;
- dvfslocked = VFS_LOCK_GIANT(dp->v_mount);
VREF(dp);
vput(tdp);
- VFS_UNLOCK_GIANT(tvfslocked);
vn_lock(dp,
compute_cn_lkflags(dp->v_mount, cnp->cn_lkflags |
LK_RETRY, ISDOTDOT));
@@ -722,7 +692,6 @@ unionlookup:
ndp->ni_dvp = dp;
ndp->ni_vp = NULL;
ASSERT_VOP_LOCKED(dp, "lookup");
- VNASSERT(vfslocked == 0, dp, ("lookup: vfslocked %d", vfslocked));
/*
* If we have a shared lock we may need to upgrade the lock for the
* last operation.
@@ -754,11 +723,8 @@ unionlookup:
(dp->v_mount->mnt_flag & MNT_UNION)) {
tdp = dp;
dp = dp->v_mount->mnt_vnodecovered;
- tvfslocked = dvfslocked;
- dvfslocked = VFS_LOCK_GIANT(dp->v_mount);
VREF(dp);
vput(tdp);
- VFS_UNLOCK_GIANT(tvfslocked);
vn_lock(dp,
compute_cn_lkflags(dp->v_mount, cnp->cn_lkflags |
LK_RETRY, cnp->cn_flags));
@@ -812,7 +778,6 @@ unionlookup:
}
dp = ndp->ni_vp;
- vfslocked = VFS_LOCK_GIANT(dp->v_mount);
/*
* Check to see if the vnode has been mounted on;
@@ -823,14 +788,10 @@ unionlookup:
if (vfs_busy(mp, 0))
continue;
vput(dp);
- VFS_UNLOCK_GIANT(vfslocked);
- vfslocked = VFS_LOCK_GIANT(mp);
if (dp != ndp->ni_dvp)
vput(ndp->ni_dvp);
else
vrele(ndp->ni_dvp);
- VFS_UNLOCK_GIANT(dvfslocked);
- dvfslocked = 0;
vref(vp_crossmp);
ndp->ni_dvp = vp_crossmp;
error = VFS_ROOT(mp, compute_cn_lkflags(mp, cnp->cn_lkflags,
@@ -891,9 +852,6 @@ nextname:
vput(ndp->ni_dvp);
else
vrele(ndp->ni_dvp);
- VFS_UNLOCK_GIANT(dvfslocked);
- dvfslocked = vfslocked; /* dp becomes dvp in dirloop */
- vfslocked = 0;
goto dirloop;
}
/*
@@ -922,8 +880,6 @@ nextname:
vput(ndp->ni_dvp);
else
vrele(ndp->ni_dvp);
- VFS_UNLOCK_GIANT(dvfslocked);
- dvfslocked = 0;
} else if ((cnp->cn_flags & LOCKPARENT) == 0 && ndp->ni_dvp != dp) {
VOP_UNLOCK(ndp->ni_dvp, 0);
ni_dvp_unlocked = 1;
@@ -949,10 +905,6 @@ success:
goto bad2;
}
}
- if (vfslocked && dvfslocked)
- VFS_UNLOCK_GIANT(dvfslocked); /* Only need one */
- if (vfslocked || dvfslocked)
- ndp->ni_cnd.cn_flags |= GIANTHELD;
return (0);
bad2:
@@ -965,9 +917,6 @@ bad2:
bad:
if (!dpunlocked)
vput(dp);
- VFS_UNLOCK_GIANT(vfslocked);
- VFS_UNLOCK_GIANT(dvfslocked);
- ndp->ni_cnd.cn_flags &= ~GIANTHELD;
ndp->ni_vp = NULL;
return (error);
}
@@ -1230,13 +1179,13 @@ kern_alternate_path(struct thread *td, const char *prefix, const char *path,
for (cp = &ptr[len] - 1; *cp != '/'; cp--);
*cp = '\0';
- NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, buf, td);
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, td);
error = namei(&nd);
*cp = '/';
if (error != 0)
goto keeporig;
} else {
- NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, buf, td);
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, td);
error = namei(&nd);
if (error != 0)
@@ -1250,7 +1199,7 @@ kern_alternate_path(struct thread *td, const char *prefix, const char *path,
* root directory and never finding it, because "/" resolves
* to the emulation root directory. This is expensive :-(
*/
- NDINIT(&ndroot, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, prefix,
+ NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE, prefix,
td);
/* We shouldn't ever get an error from this namei(). */
@@ -1261,13 +1210,11 @@ kern_alternate_path(struct thread *td, const char *prefix, const char *path,
NDFREE(&ndroot, NDF_ONLY_PNBUF);
vrele(ndroot.ni_vp);
- VFS_UNLOCK_GIANT(NDHASGIANT(&ndroot));
}
}
NDFREE(&nd, NDF_ONLY_PNBUF);
vrele(nd.ni_vp);
- VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
keeporig:
/* If there was an error, use the original path name. */
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index f39784269060..f5ff8ac3ab99 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -37,8 +37,6 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "opt_vfs_allow_nonmpsafe.h"
-
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/fcntl.h>
@@ -821,14 +819,6 @@ vfs_domount_first(
* get. No freeing of cn_pnbuf.
*/
error = VFS_MOUNT(mp);
-#ifndef VFS_ALLOW_NONMPSAFE
- if (error == 0 && VFS_NEEDSGIANT(mp)) {
- (void)VFS_UNMOUNT(mp, fsflags);
- error = ENXIO;
- printf("%s: Mounting non-MPSAFE fs (%s) is disabled\n",
- __func__, mp->mnt_vfc->vfc_name);
- }
-#endif
if (error != 0) {
vfs_unbusy(mp);
vfs_mount_destroy(mp);
@@ -838,11 +828,6 @@ vfs_domount_first(
vrele(vp);
return (error);
}
-#ifdef VFS_ALLOW_NONMPSAFE
- if (VFS_NEEDSGIANT(mp))
- printf("%s: Mounting non-MPSAFE fs (%s) is deprecated\n",
- __func__, mp->mnt_vfc->vfc_name);
-#endif
if (mp->mnt_opt != NULL)
vfs_freeopts(mp->mnt_opt);
@@ -1100,13 +1085,12 @@ vfs_domount(
/*
* Get vnode to be covered or mount point's vnode in case of MNT_UPDATE.
*/
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1,
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1,
UIO_SYSSPACE, fspath, td);
error = namei(&nd);
if (error != 0)
return (error);
- if (!NDHASGIANT(&nd))
- mtx_lock(&Giant);
+ mtx_lock(&Giant);
NDFREE(&nd, NDF_ONLY_PNBUF);
vp = nd.ni_vp;
if ((fsflags & MNT_UPDATE) == 0) {
@@ -1153,7 +1137,7 @@ sys_unmount(td, uap)
struct nameidata nd;
struct mount *mp;
char *pathbuf;
- int error, id0, id1, vfslocked;
+ int error, id0, id1;
AUDIT_ARG_VALUE(uap->flags);
if (jailed(td->td_ucred) || usermount == 0) {
@@ -1190,17 +1174,14 @@ sys_unmount(td, uap)
/*
* Try to find global path for path argument.
*/
- NDINIT(&nd, LOOKUP,
- FOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1,
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1,
UIO_SYSSPACE, pathbuf, td);
if (namei(&nd) == 0) {
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
error = vn_path_to_global_path(td, nd.ni_vp, pathbuf,
MNAMELEN);
if (error == 0 || error == ENODEV)
vput(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
}
mtx_lock(&mountlist_mtx);
TAILQ_FOREACH_REVERSE(mp, &mountlist, mntlist, mnt_list) {
diff --git a/sys/kern/vfs_mountroot.c b/sys/kern/vfs_mountroot.c
index 62a49ae0ddf4..83948f24e669 100644
--- a/sys/kern/vfs_mountroot.c
+++ b/sys/kern/vfs_mountroot.c
@@ -872,16 +872,14 @@ vfs_mountroot_readconf(struct thread *td, struct sbuf *sb)
struct nameidata nd;
off_t ofs;
ssize_t resid;
- int error, flags, len, vfslocked;
+ int error, flags, len;
- NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE,
- "/.mount.conf", td);
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, "/.mount.conf", td);
flags = FREAD;
error = vn_open(&nd, &flags, 0, NULL);
if (error)
return (error);
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
ofs = 0;
len = sizeof(buf) - 1;
@@ -900,7 +898,6 @@ vfs_mountroot_readconf(struct thread *td, struct sbuf *sb)
VOP_UNLOCK(nd.ni_vp, 0);
vn_close(nd.ni_vp, FREAD, td->td_ucred, td);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index eace207b9f79..e45a1f622d2a 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -93,9 +93,6 @@ __FBSDID("$FreeBSD$");
#include <ddb/ddb.h>
#endif
-#define WI_MPSAFEQ 0
-#define WI_GIANTQ 1
-
static void delmntque(struct vnode *vp);
static int flushbuflist(struct bufv *bufv, int flags, struct bufobj *bo,
int slpflag, int slptimeo);
@@ -217,7 +214,7 @@ static uma_zone_t vnodepoll_zone;
static int syncer_delayno;
static long syncer_mask;
LIST_HEAD(synclist, bufobj);
-static struct synclist *syncer_workitem_pending[2];
+static struct synclist *syncer_workitem_pending;
/*
* The sync_mtx protects:
* bo->bo_synclist
@@ -329,9 +326,7 @@ vntblinit(void *dummy __unused)
/*
* Initialize the filesystem syncer.
*/
- syncer_workitem_pending[WI_MPSAFEQ] = hashinit(syncer_maxdelay, M_VNODE,
- &syncer_mask);
- syncer_workitem_pending[WI_GIANTQ] = hashinit(syncer_maxdelay, M_VNODE,
+ syncer_workitem_pending = hashinit(syncer_maxdelay, M_VNODE,
&syncer_mask);
syncer_maxdelay = syncer_mask + 1;
mtx_init(&sync_mtx, "Syncer mtx", NULL, MTX_DEF);
@@ -761,7 +756,6 @@ static void
vnlru_free(int count)
{
struct vnode *vp;
- int vfslocked;
mtx_assert(&vnode_free_list_mtx, MA_OWNED);
for (; count > 0; count--) {
@@ -793,9 +787,7 @@ vnlru_free(int count)
vholdl(vp);
mtx_unlock(&vnode_free_list_mtx);
VI_UNLOCK(vp);
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vtryrecycle(vp);
- VFS_UNLOCK_GIANT(vfslocked);
/*
* If the recycled succeeded this vdrop will actually free
* the vnode. If not it will simply place it back on
@@ -817,7 +809,7 @@ static void
vnlru_proc(void)
{
struct mount *mp, *nmp;
- int done, vfslocked;
+ int done;
struct proc *p = vnlruproc;
EVENTHANDLER_REGISTER(shutdown_pre_sync, kproc_shutdown, p,
@@ -843,9 +835,7 @@ vnlru_proc(void)
nmp = TAILQ_NEXT(mp, mnt_list);
continue;
}
- vfslocked = VFS_LOCK_GIANT(mp);
done += vlrureclaim(mp);
- VFS_UNLOCK_GIANT(vfslocked);
mtx_lock(&mountlist_mtx);
nmp = TAILQ_NEXT(mp, mnt_list);
vfs_unbusy(mp);
@@ -1141,11 +1131,8 @@ insmntque1(struct vnode *vp, struct mount *mp,
KASSERT(vp->v_mount == NULL,
("insmntque: vnode already on per mount vnode list"));
VNASSERT(mp != NULL, vp, ("Don't call insmntque(foo, NULL)"));
-#ifdef DEBUG_VFS_LOCKS
- if (!VFS_NEEDSGIANT(mp))
- ASSERT_VOP_ELOCKED(vp,
- "insmntque: mp-safe fs and non-locked vp");
-#endif
+ ASSERT_VOP_ELOCKED(vp, "insmntque: non-locked vp");
+
/*
* We acquire the vnode interlock early to ensure that the
* vnode cannot be recycled by another process releasing a
@@ -1679,8 +1666,6 @@ bgetvp(struct vnode *vp, struct buf *bp)
("bgetvp: bp already attached! %p", bp));
vhold(vp);
- if (VFS_NEEDSGIANT(vp->v_mount) || bo->bo_flag & BO_NEEDSGIANT)
- bp->b_flags |= B_NEEDSGIANT;
bp->b_vp = vp;
bp->b_bufobj = bo;
/*
@@ -1718,7 +1703,6 @@ brelvp(struct buf *bp)
syncer_worklist_len--;
mtx_unlock(&sync_mtx);
}
- bp->b_flags &= ~B_NEEDSGIANT;
bp->b_vp = NULL;
bp->b_bufobj = NULL;
BO_UNLOCK(bo);
@@ -1731,7 +1715,7 @@ brelvp(struct buf *bp)
static void
vn_syncer_add_to_worklist(struct bufobj *bo, int delay)
{
- int queue, slot;
+ int slot;
ASSERT_BO_LOCKED(bo);
@@ -1747,10 +1731,7 @@ vn_syncer_add_to_worklist(struct bufobj *bo, int delay)
delay = syncer_maxdelay - 2;
slot = (syncer_delayno + delay) & syncer_mask;
- queue = VFS_NEEDSGIANT(bo->__bo_vnode->v_mount) ? WI_GIANTQ :
- WI_MPSAFEQ;
- LIST_INSERT_HEAD(&syncer_workitem_pending[queue][slot], bo,
- bo_synclist);
+ LIST_INSERT_HEAD(&syncer_workitem_pending[slot], bo, bo_synclist);
mtx_unlock(&sync_mtx);
}
@@ -1830,8 +1811,7 @@ sync_vnode(struct synclist *slp, struct bufobj **bo, struct thread *td)
static void
sched_sync(void)
{
- struct synclist *gnext, *next;
- struct synclist *gslp, *slp;
+ struct synclist *next, *slp;
struct bufobj *bo;
long starttime;
struct thread *td = curthread;
@@ -1877,13 +1857,11 @@ sched_sync(void)
* Skip over empty worklist slots when shutting down.
*/
do {
- slp = &syncer_workitem_pending[WI_MPSAFEQ][syncer_delayno];
- gslp = &syncer_workitem_pending[WI_GIANTQ][syncer_delayno];
+ slp = &syncer_workitem_pending[syncer_delayno];
syncer_delayno += 1;
if (syncer_delayno == syncer_maxdelay)
syncer_delayno = 0;
- next = &syncer_workitem_pending[WI_MPSAFEQ][syncer_delayno];
- gnext = &syncer_workitem_pending[WI_GIANTQ][syncer_delayno];
+ next = &syncer_workitem_pending[syncer_delayno];
/*
* If the worklist has wrapped since the
* it was emptied of all but syncer vnodes,
@@ -1897,7 +1875,7 @@ sched_sync(void)
syncer_final_iter = SYNCER_SHUTDOWN_SPEEDUP;
}
} while (syncer_state != SYNCER_RUNNING && LIST_EMPTY(slp) &&
- LIST_EMPTY(gslp) && syncer_worklist_len > 0);
+ syncer_worklist_len > 0);
/*
* Keep track of the last time there was anything
@@ -1921,21 +1899,6 @@ sched_sync(void)
wdog_kern_pat(WD_LASTVAL);
}
- if (!LIST_EMPTY(gslp)) {
- mtx_unlock(&sync_mtx);
- mtx_lock(&Giant);
- mtx_lock(&sync_mtx);
- while (!LIST_EMPTY(gslp)) {
- error = sync_vnode(gslp, &bo, td);
- if (error == 1) {
- LIST_REMOVE(bo, bo_synclist);
- LIST_INSERT_HEAD(gnext, bo,
- bo_synclist);
- continue;
- }
- }
- mtx_unlock(&Giant);
- }
if (syncer_state == SYNCER_FINAL_DELAY && syncer_final_iter > 0)
syncer_final_iter--;
/*
@@ -2196,7 +2159,6 @@ vget(struct vnode *vp, int flags, struct thread *td)
int error;
error = 0;
- VFS_ASSERT_GIANT(vp->v_mount);
VNASSERT((flags & LK_TYPE_MASK) != 0, vp,
("vget: invalid lock operation"));
CTR3(KTR_VFS, "%s: vp %p with flags %d", __func__, vp, flags);
@@ -2281,7 +2243,6 @@ vputx(struct vnode *vp, int func)
ASSERT_VOP_LOCKED(vp, "vput");
else
KASSERT(func == VPUTX_VRELE, ("vputx: wrong func"));
- VFS_ASSERT_GIANT(vp->v_mount);
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
VI_LOCK(vp);
@@ -4631,7 +4592,6 @@ vfs_mark_atime(struct vnode *vp, struct ucred *cred)
struct mount *mp;
mp = vp->v_mount;
- VFS_ASSERT_GIANT(mp);
ASSERT_VOP_LOCKED(vp, "vfs_mark_atime");
if (mp != NULL && (mp->mnt_flag & (MNT_NOATIME | MNT_RDONLY)) == 0)
(void)VOP_MARKATIME(vp);
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index a1b26ce83808..4abd503f9e2c 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -134,7 +134,7 @@ sys_sync(td, uap)
struct sync_args *uap;
{
struct mount *mp, *nmp;
- int save, vfslocked;
+ int save;
mtx_lock(&mountlist_mtx);
for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
@@ -142,7 +142,6 @@ sys_sync(td, uap)
nmp = TAILQ_NEXT(mp, mnt_list);
continue;
}
- vfslocked = VFS_LOCK_GIANT(mp);
if ((mp->mnt_flag & MNT_RDONLY) == 0 &&
vn_start_write(NULL, &mp, V_NOWAIT) == 0) {
save = curthread_pflags_set(TDP_SYNCIO);
@@ -151,7 +150,6 @@ sys_sync(td, uap)
curthread_pflags_restore(save);
vn_finished_write(mp);
}
- VFS_UNLOCK_GIANT(vfslocked);
mtx_lock(&mountlist_mtx);
nmp = TAILQ_NEXT(mp, mnt_list);
vfs_unbusy(mp);
@@ -182,7 +180,6 @@ sys_quotactl(td, uap)
} */ *uap;
{
struct mount *mp;
- int vfslocked;
int error;
struct nameidata nd;
@@ -190,21 +187,18 @@ sys_quotactl(td, uap)
AUDIT_ARG_UID(uap->uid);
if (!prison_allow(td->td_ucred, PR_ALLOW_QUOTAS))
return (EPERM);
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1,
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1,
UIO_USERSPACE, uap->path, td);
if ((error = namei(&nd)) != 0)
return (error);
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
mp = nd.ni_vp->v_mount;
vfs_ref(mp);
vput(nd.ni_vp);
error = vfs_busy(mp, 0);
vfs_rel(mp);
- if (error) {
- VFS_UNLOCK_GIANT(vfslocked);
+ if (error)
return (error);
- }
error = VFS_QUOTACTL(mp, uap->cmd, uap->uid, uap->arg);
/*
@@ -220,7 +214,6 @@ sys_quotactl(td, uap)
*/
if ((uap->cmd >> SUBCMDSHIFT) != Q_QUOTAON)
vfs_unbusy(mp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -297,26 +290,22 @@ kern_statfs(struct thread *td, char *path, enum uio_seg pathseg,
{
struct mount *mp;
struct statfs *sp, sb;
- int vfslocked;
int error;
struct nameidata nd;
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | MPSAFE |
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF |
AUDITVNODE1, pathseg, path, td);
error = namei(&nd);
if (error)
return (error);
- vfslocked = NDHASGIANT(&nd);
mp = nd.ni_vp->v_mount;
vfs_ref(mp);
NDFREE(&nd, NDF_ONLY_PNBUF);
vput(nd.ni_vp);
error = vfs_busy(mp, 0);
vfs_rel(mp);
- if (error) {
- VFS_UNLOCK_GIANT(vfslocked);
+ if (error)
return (error);
- }
#ifdef MAC
error = mac_mount_check_stat(td->td_ucred, mp);
if (error)
@@ -341,7 +330,6 @@ kern_statfs(struct thread *td, char *path, enum uio_seg pathseg,
*buf = *sp;
out:
vfs_unbusy(mp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -377,7 +365,6 @@ kern_fstatfs(struct thread *td, int fd, struct statfs *buf)
struct file *fp;
struct mount *mp;
struct statfs *sp, sb;
- int vfslocked;
struct vnode *vp;
int error;
@@ -386,7 +373,6 @@ kern_fstatfs(struct thread *td, int fd, struct statfs *buf)
if (error)
return (error);
vp = fp->f_vnode;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vn_lock(vp, LK_SHARED | LK_RETRY);
#ifdef AUDIT
AUDIT_ARG_VNODE1(vp);
@@ -402,10 +388,8 @@ kern_fstatfs(struct thread *td, int fd, struct statfs *buf)
}
error = vfs_busy(mp, 0);
vfs_rel(mp);
- if (error) {
- VFS_UNLOCK_GIANT(vfslocked);
+ if (error)
return (error);
- }
#ifdef MAC
error = mac_mount_check_stat(td->td_ucred, mp);
if (error)
@@ -431,7 +415,6 @@ kern_fstatfs(struct thread *td, int fd, struct statfs *buf)
out:
if (mp)
vfs_unbusy(mp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -471,7 +454,6 @@ kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize,
struct mount *mp, *nmp;
struct statfs *sfsp, *sp, sb;
size_t count, maxcount;
- int vfslocked;
int error;
maxcount = bufsize / sizeof(struct statfs);
@@ -508,7 +490,6 @@ kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize,
nmp = TAILQ_NEXT(mp, mnt_list);
continue;
}
- vfslocked = VFS_LOCK_GIANT(mp);
if (sfsp && count < maxcount) {
sp = &mp->mnt_stat;
/*
@@ -526,7 +507,6 @@ kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize,
if (((flags & (MNT_LAZY|MNT_NOWAIT)) == 0 ||
(flags & MNT_WAIT)) &&
(error = VFS_STATFS(mp, sp))) {
- VFS_UNLOCK_GIANT(vfslocked);
mtx_lock(&mountlist_mtx);
nmp = TAILQ_NEXT(mp, mnt_list);
vfs_unbusy(mp);
@@ -544,13 +524,11 @@ kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize,
error = copyout(sp, sfsp, sizeof(*sp));
if (error) {
vfs_unbusy(mp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
}
sfsp++;
}
- VFS_UNLOCK_GIANT(vfslocked);
count++;
mtx_lock(&mountlist_mtx);
nmp = TAILQ_NEXT(mp, mnt_list);
@@ -751,7 +729,6 @@ sys_fchdir(td, uap)
struct vnode *vp, *tdp, *vpold;
struct mount *mp;
struct file *fp;
- int vfslocked;
int error;
AUDIT_ARG_FD(uap->fd);
@@ -760,40 +737,29 @@ sys_fchdir(td, uap)
vp = fp->f_vnode;
VREF(vp);
fdrop(fp, td);
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vn_lock(vp, LK_SHARED | LK_RETRY);
AUDIT_ARG_VNODE1(vp);
error = change_dir(vp, td);
while (!error && (mp = vp->v_mountedhere) != NULL) {
- int tvfslocked;
if (vfs_busy(mp, 0))
continue;
- tvfslocked = VFS_LOCK_GIANT(mp);
error = VFS_ROOT(mp, LK_SHARED, &tdp);
vfs_unbusy(mp);
- if (error) {
- VFS_UNLOCK_GIANT(tvfslocked);
+ if (error)
break;
- }
vput(vp);
- VFS_UNLOCK_GIANT(vfslocked);
vp = tdp;
- vfslocked = tvfslocked;
}
if (error) {
vput(vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
VOP_UNLOCK(vp, 0);
- VFS_UNLOCK_GIANT(vfslocked);
FILEDESC_XLOCK(fdp);
vpold = fdp->fd_cdir;
fdp->fd_cdir = vp;
FILEDESC_XUNLOCK(fdp);
- vfslocked = VFS_LOCK_GIANT(vpold->v_mount);
vrele(vpold);
- VFS_UNLOCK_GIANT(vfslocked);
return (0);
}
@@ -823,29 +789,23 @@ kern_chdir(struct thread *td, char *path, enum uio_seg pathseg)
int error;
struct nameidata nd;
struct vnode *vp;
- int vfslocked;
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | AUDITVNODE1 |
- MPSAFE, pathseg, path, td);
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | AUDITVNODE1,
+ pathseg, path, td);
if ((error = namei(&nd)) != 0)
return (error);
- vfslocked = NDHASGIANT(&nd);
if ((error = change_dir(nd.ni_vp, td)) != 0) {
vput(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
NDFREE(&nd, NDF_ONLY_PNBUF);
return (error);
}
VOP_UNLOCK(nd.ni_vp, 0);
- VFS_UNLOCK_GIANT(vfslocked);
NDFREE(&nd, NDF_ONLY_PNBUF);
FILEDESC_XLOCK(fdp);
vp = fdp->fd_cdir;
fdp->fd_cdir = nd.ni_vp;
FILEDESC_XUNLOCK(fdp);
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (0);
}
@@ -907,17 +867,15 @@ sys_chroot(td, uap)
{
int error;
struct nameidata nd;
- int vfslocked;
error = priv_check(td, PRIV_VFS_CHROOT);
if (error)
return (error);
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | MPSAFE |
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF |
AUDITVNODE1, UIO_USERSPACE, uap->path, td);
error = namei(&nd);
if (error)
goto error;
- vfslocked = NDHASGIANT(&nd);
if ((error = change_dir(nd.ni_vp, td)) != 0)
goto e_vunlock;
#ifdef MAC
@@ -927,12 +885,10 @@ sys_chroot(td, uap)
VOP_UNLOCK(nd.ni_vp, 0);
error = change_root(nd.ni_vp, td);
vrele(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
NDFREE(&nd, NDF_ONLY_PNBUF);
return (error);
e_vunlock:
vput(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
error:
NDFREE(&nd, NDF_ONLY_PNBUF);
return (error);
@@ -973,10 +929,8 @@ change_root(vp, td)
{
struct filedesc *fdp;
struct vnode *oldvp;
- int vfslocked;
int error;
- VFS_ASSERT_GIANT(vp->v_mount);
fdp = td->td_proc->p_fd;
FILEDESC_XLOCK(fdp);
if (chroot_allow_open_directories == 0 ||
@@ -995,9 +949,7 @@ change_root(vp, td)
VREF(fdp->fd_jdir);
}
FILEDESC_XUNLOCK(fdp);
- vfslocked = VFS_LOCK_GIANT(oldvp->v_mount);
vrele(oldvp);
- VFS_UNLOCK_GIANT(vfslocked);
return (0);
}
@@ -1093,7 +1045,6 @@ kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
int cmode;
int indx = -1, error;
struct nameidata nd;
- int vfslocked;
cap_rights_t rights_needed = CAP_LOOKUP;
AUDIT_ARG_FFLAGS(flags);
@@ -1126,7 +1077,7 @@ kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
/* Set the flags early so the finit in devfs can pick them up. */
fp->f_flag = flags & FMASK;
cmode = ((mode &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT;
- NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | AUDITVNODE1 | MPSAFE, pathseg,
+ NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | AUDITVNODE1, pathseg,
path, fd, rights_needed, td);
td->td_dupfd = -1; /* XXX check for fdopen */
error = vn_open(&nd, &flags, cmode, fp);
@@ -1160,7 +1111,6 @@ kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
goto bad_unlocked;
}
td->td_dupfd = 0;
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
vp = nd.ni_vp;
@@ -1187,7 +1137,6 @@ kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
if (error)
goto bad;
}
- VFS_UNLOCK_GIANT(vfslocked);
success:
/*
* If we haven't already installed the FD (for dupfdopen), do so now.
@@ -1217,7 +1166,6 @@ success:
td->td_retval[0] = indx;
return (0);
bad:
- VFS_UNLOCK_GIANT(vfslocked);
bad_unlocked:
KASSERT(indx == -1, ("indx=%d, should be -1", indx));
fdrop(fp, td);
@@ -1305,7 +1253,6 @@ kern_mknodat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
int error;
int whiteout = 0;
struct nameidata nd;
- int vfslocked;
AUDIT_ARG_MODE(mode);
AUDIT_ARG_DEV(dev);
@@ -1333,11 +1280,10 @@ kern_mknodat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
restart:
bwillwrite();
NDINIT_ATRIGHTS(&nd, CREATE,
- LOCKPARENT | SAVENAME | MPSAFE | AUDITVNODE1, pathseg, path, fd,
+ LOCKPARENT | SAVENAME | AUDITVNODE1, pathseg, path, fd,
CAP_MKNOD, td);
if ((error = namei(&nd)) != 0)
return (error);
- vfslocked = NDHASGIANT(&nd);
vp = nd.ni_vp;
if (vp != NULL) {
NDFREE(&nd, NDF_ONLY_PNBUF);
@@ -1346,7 +1292,6 @@ restart:
else
vput(nd.ni_dvp);
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (EEXIST);
} else {
VATTR_NULL(&vattr);
@@ -1375,7 +1320,6 @@ restart:
if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) {
NDFREE(&nd, NDF_ONLY_PNBUF);
vput(nd.ni_dvp);
- VFS_UNLOCK_GIANT(vfslocked);
if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0)
return (error);
goto restart;
@@ -1398,7 +1342,6 @@ restart:
NDFREE(&nd, NDF_ONLY_PNBUF);
vput(nd.ni_dvp);
vn_finished_write(mp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -1453,17 +1396,15 @@ kern_mkfifoat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
struct vattr vattr;
int error;
struct nameidata nd;
- int vfslocked;
AUDIT_ARG_MODE(mode);
restart:
bwillwrite();
NDINIT_ATRIGHTS(&nd, CREATE,
- LOCKPARENT | SAVENAME | MPSAFE | AUDITVNODE1, pathseg, path, fd,
+ LOCKPARENT | SAVENAME | AUDITVNODE1, pathseg, path, fd,
CAP_MKFIFO, td);
if ((error = namei(&nd)) != 0)
return (error);
- vfslocked = NDHASGIANT(&nd);
if (nd.ni_vp != NULL) {
NDFREE(&nd, NDF_ONLY_PNBUF);
if (nd.ni_vp == nd.ni_dvp)
@@ -1471,13 +1412,11 @@ restart:
else
vput(nd.ni_dvp);
vrele(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (EEXIST);
}
if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) {
NDFREE(&nd, NDF_ONLY_PNBUF);
vput(nd.ni_dvp);
- VFS_UNLOCK_GIANT(vfslocked);
if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0)
return (error);
goto restart;
@@ -1499,7 +1438,6 @@ out:
#endif
vput(nd.ni_dvp);
vn_finished_write(mp);
- VFS_UNLOCK_GIANT(vfslocked);
NDFREE(&nd, NDF_ONLY_PNBUF);
return (error);
}
@@ -1600,33 +1538,27 @@ kern_linkat(struct thread *td, int fd1, int fd2, char *path1, char *path2,
struct vnode *vp;
struct mount *mp;
struct nameidata nd;
- int vfslocked;
- int lvfslocked;
int error;
bwillwrite();
- NDINIT_AT(&nd, LOOKUP, follow | MPSAFE | AUDITVNODE1, segflg, path1,
+ NDINIT_AT(&nd, LOOKUP, follow | AUDITVNODE1, segflg, path1,
fd1, td);
if ((error = namei(&nd)) != 0)
return (error);
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
vp = nd.ni_vp;
if (vp->v_type == VDIR) {
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (EPERM); /* POSIX */
}
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) {
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
- NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | MPSAFE |
+ NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME |
AUDITVNODE2, segflg, path2, fd2, CAP_CREATE, td);
if ((error = namei(&nd)) == 0) {
- lvfslocked = NDHASGIANT(&nd);
if (nd.ni_vp != NULL) {
if (nd.ni_dvp == nd.ni_vp)
vrele(nd.ni_dvp);
@@ -1648,11 +1580,9 @@ kern_linkat(struct thread *td, int fd1, int fd2, char *path1, char *path2,
vput(nd.ni_dvp);
}
NDFREE(&nd, NDF_ONLY_PNBUF);
- VFS_UNLOCK_GIANT(lvfslocked);
}
vrele(vp);
vn_finished_write(mp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -1708,7 +1638,6 @@ kern_symlinkat(struct thread *td, char *path1, int fd, char *path2,
char *syspath;
int error;
struct nameidata nd;
- int vfslocked;
if (segflg == UIO_SYSSPACE) {
syspath = path1;
@@ -1720,11 +1649,10 @@ kern_symlinkat(struct thread *td, char *path1, int fd, char *path2,
AUDIT_ARG_TEXT(syspath);
restart:
bwillwrite();
- NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | MPSAFE |
+ NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME |
AUDITVNODE1, segflg, path2, fd, CAP_CREATE, td);
if ((error = namei(&nd)) != 0)
goto out;
- vfslocked = NDHASGIANT(&nd);
if (nd.ni_vp) {
NDFREE(&nd, NDF_ONLY_PNBUF);
if (nd.ni_vp == nd.ni_dvp)
@@ -1732,14 +1660,12 @@ restart:
else
vput(nd.ni_dvp);
vrele(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
error = EEXIST;
goto out;
}
if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) {
NDFREE(&nd, NDF_ONLY_PNBUF);
vput(nd.ni_dvp);
- VFS_UNLOCK_GIANT(vfslocked);
if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0)
goto out;
goto restart;
@@ -1762,7 +1688,6 @@ out2:
NDFREE(&nd, NDF_ONLY_PNBUF);
vput(nd.ni_dvp);
vn_finished_write(mp);
- VFS_UNLOCK_GIANT(vfslocked);
out:
if (segflg != UIO_SYSSPACE)
uma_zfree(namei_zone, syspath);
@@ -1782,16 +1707,14 @@ sys_undelete(td, uap)
int error;
struct mount *mp;
struct nameidata nd;
- int vfslocked;
restart:
bwillwrite();
- NDINIT(&nd, DELETE, LOCKPARENT | DOWHITEOUT | MPSAFE | AUDITVNODE1,
+ NDINIT(&nd, DELETE, LOCKPARENT | DOWHITEOUT | AUDITVNODE1,
UIO_USERSPACE, uap->path, td);
error = namei(&nd);
if (error)
return (error);
- vfslocked = NDHASGIANT(&nd);
if (nd.ni_vp != NULLVP || !(nd.ni_cnd.cn_flags & ISWHITEOUT)) {
NDFREE(&nd, NDF_ONLY_PNBUF);
@@ -1801,13 +1724,11 @@ restart:
vput(nd.ni_dvp);
if (nd.ni_vp)
vrele(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (EEXIST);
}
if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) {
NDFREE(&nd, NDF_ONLY_PNBUF);
vput(nd.ni_dvp);
- VFS_UNLOCK_GIANT(vfslocked);
if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0)
return (error);
goto restart;
@@ -1816,7 +1737,6 @@ restart:
NDFREE(&nd, NDF_ONLY_PNBUF);
vput(nd.ni_dvp);
vn_finished_write(mp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -1878,15 +1798,13 @@ kern_unlinkat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
int error;
struct nameidata nd;
struct stat sb;
- int vfslocked;
restart:
bwillwrite();
- NDINIT_ATRIGHTS(&nd, DELETE, LOCKPARENT | LOCKLEAF | MPSAFE |
+ NDINIT_ATRIGHTS(&nd, DELETE, LOCKPARENT | LOCKLEAF |
AUDITVNODE1, pathseg, path, fd, CAP_DELETE, td);
if ((error = namei(&nd)) != 0)
return (error == EINVAL ? EPERM : error);
- vfslocked = NDHASGIANT(&nd);
vp = nd.ni_vp;
if (vp->v_type == VDIR && oldinum == 0) {
error = EPERM; /* POSIX */
@@ -1911,7 +1829,6 @@ restart:
vrele(vp);
else
vput(vp);
- VFS_UNLOCK_GIANT(vfslocked);
if ((error = vn_start_write(NULL, &mp,
V_XSLEEP | PCATCH)) != 0)
return (error);
@@ -1935,7 +1852,6 @@ out:
vrele(vp);
else
vput(vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -1966,7 +1882,6 @@ sys_lseek(td, uap)
struct vattr vattr;
off_t foffset, offset, size;
int error, noneg;
- int vfslocked;
AUDIT_ARG_FD(uap->fd);
if ((error = fget(td, uap->fd, CAP_SEEK, &fp)) != 0)
@@ -1977,7 +1892,6 @@ sys_lseek(td, uap)
}
vp = fp->f_vnode;
foffset = foffset_lock(fp, 0);
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
noneg = (vp->v_type != VCHR);
offset = uap->offset;
switch (uap->whence) {
@@ -2032,7 +1946,6 @@ sys_lseek(td, uap)
*(off_t *)(td->td_retval) = offset;
drop:
fdrop(fp, td);
- VFS_UNLOCK_GIANT(vfslocked);
foffset_unlock(fp, offset, error != 0 ? FOF_NOUPDATE : 0);
return (error);
}
@@ -2172,7 +2085,6 @@ kern_accessat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
struct ucred *cred, *tmpcred;
struct vnode *vp;
struct nameidata nd;
- int vfslocked;
int error;
/*
@@ -2188,17 +2100,15 @@ kern_accessat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
} else
cred = tmpcred = td->td_ucred;
AUDIT_ARG_VALUE(amode);
- NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | MPSAFE |
+ NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF |
AUDITVNODE1, pathseg, path, fd, CAP_FSTAT, td);
if ((error = namei(&nd)) != 0)
goto out1;
- vfslocked = NDHASGIANT(&nd);
vp = nd.ni_vp;
error = vn_access(vp, amode, tmpcred, td);
NDFREE(&nd, NDF_ONLY_PNBUF);
vput(vp);
- VFS_UNLOCK_GIANT(vfslocked);
out1:
if (!(flag & AT_EACCESS)) {
td->td_ucred = cred;
@@ -2393,18 +2303,17 @@ kern_statat_vnhook(struct thread *td, int flag, int fd, char *path,
{
struct nameidata nd;
struct stat sb;
- int error, vfslocked;
+ int error;
if (flag & ~AT_SYMLINK_NOFOLLOW)
return (EINVAL);
NDINIT_ATRIGHTS(&nd, LOOKUP, ((flag & AT_SYMLINK_NOFOLLOW) ? NOFOLLOW :
- FOLLOW) | LOCKSHARED | LOCKLEAF | AUDITVNODE1 | MPSAFE, pathseg,
+ FOLLOW) | LOCKSHARED | LOCKLEAF | AUDITVNODE1, pathseg,
path, fd, CAP_FSTAT, td);
if ((error = namei(&nd)) != 0)
return (error);
- vfslocked = NDHASGIANT(&nd);
error = vn_stat(nd.ni_vp, &sb, td->td_ucred, NOCRED, td);
if (!error) {
SDT_PROBE(vfs, , stat, mode, path, sb.st_mode, 0, 0, 0);
@@ -2415,7 +2324,6 @@ kern_statat_vnhook(struct thread *td, int flag, int fd, char *path,
}
NDFREE(&nd, NDF_ONLY_PNBUF);
vput(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
if (error)
return (error);
*sbp = sb;
@@ -2586,13 +2494,12 @@ kern_pathconf(struct thread *td, char *path, enum uio_seg pathseg, int name,
u_long flags)
{
struct nameidata nd;
- int error, vfslocked;
+ int error;
- NDINIT(&nd, LOOKUP, LOCKSHARED | LOCKLEAF | MPSAFE | AUDITVNODE1 |
- flags, pathseg, path, td);
+ NDINIT(&nd, LOOKUP, LOCKSHARED | LOCKLEAF | AUDITVNODE1 | flags,
+ pathseg, path, td);
if ((error = namei(&nd)) != 0)
return (error);
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
/* If asynchronous I/O is available, it works for all files. */
@@ -2601,7 +2508,6 @@ kern_pathconf(struct thread *td, char *path, enum uio_seg pathseg, int name,
else
error = VOP_PATHCONF(nd.ni_vp, name, td->td_retval);
vput(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -2662,24 +2568,21 @@ kern_readlinkat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
struct uio auio;
int error;
struct nameidata nd;
- int vfslocked;
if (count > IOSIZE_MAX)
return (EINVAL);
- NDINIT_AT(&nd, LOOKUP, NOFOLLOW | LOCKSHARED | LOCKLEAF | MPSAFE |
+ NDINIT_AT(&nd, LOOKUP, NOFOLLOW | LOCKSHARED | LOCKLEAF |
AUDITVNODE1, pathseg, path, fd, td);
if ((error = namei(&nd)) != 0)
return (error);
NDFREE(&nd, NDF_ONLY_PNBUF);
- vfslocked = NDHASGIANT(&nd);
vp = nd.ni_vp;
#ifdef MAC
error = mac_vnode_check_readlink(td->td_ucred, vp);
if (error) {
vput(vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
#endif
@@ -2698,7 +2601,6 @@ kern_readlinkat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
error = VOP_READLINK(vp, &auio, td->td_ucred);
}
vput(vp);
- VFS_UNLOCK_GIANT(vfslocked);
td->td_retval[0] = count - auio.uio_resid;
return (error);
}
@@ -2766,18 +2668,15 @@ sys_chflags(td, uap)
{
int error;
struct nameidata nd;
- int vfslocked;
AUDIT_ARG_FFLAGS(uap->flags);
- NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE | AUDITVNODE1, UIO_USERSPACE,
+ NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, UIO_USERSPACE,
uap->path, td);
if ((error = namei(&nd)) != 0)
return (error);
NDFREE(&nd, NDF_ONLY_PNBUF);
- vfslocked = NDHASGIANT(&nd);
error = setfflags(td, nd.ni_vp, uap->flags);
vrele(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -2794,18 +2693,15 @@ sys_lchflags(td, uap)
{
int error;
struct nameidata nd;
- int vfslocked;
AUDIT_ARG_FFLAGS(uap->flags);
- NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE | AUDITVNODE1, UIO_USERSPACE,
+ NDINIT(&nd, LOOKUP, NOFOLLOW | AUDITVNODE1, UIO_USERSPACE,
uap->path, td);
if ((error = namei(&nd)) != 0)
return (error);
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
error = setfflags(td, nd.ni_vp, uap->flags);
vrele(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -2827,7 +2723,6 @@ sys_fchflags(td, uap)
} */ *uap;
{
struct file *fp;
- int vfslocked;
int error;
AUDIT_ARG_FD(uap->fd);
@@ -2835,14 +2730,12 @@ sys_fchflags(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, CAP_FCHFLAGS,
&fp)) != 0)
return (error);
- vfslocked = VFS_LOCK_GIANT(fp->f_vnode->v_mount);
#ifdef AUDIT
vn_lock(fp->f_vnode, LK_SHARED | LK_RETRY);
AUDIT_ARG_VNODE1(fp->f_vnode);
VOP_UNLOCK(fp->f_vnode, 0);
#endif
error = setfflags(td, fp->f_vnode, uap->flags);
- VFS_UNLOCK_GIANT(vfslocked);
fdrop(fp, td);
return (error);
}
@@ -2955,20 +2848,17 @@ kern_fchmodat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
{
int error;
struct nameidata nd;
- int vfslocked;
int follow;
AUDIT_ARG_MODE(mode);
follow = (flag & AT_SYMLINK_NOFOLLOW) ? NOFOLLOW : FOLLOW;
- NDINIT_ATRIGHTS(&nd, LOOKUP, follow | MPSAFE | AUDITVNODE1, pathseg,
+ NDINIT_ATRIGHTS(&nd, LOOKUP, follow | AUDITVNODE1, pathseg,
path, fd, CAP_FCHMOD, td);
if ((error = namei(&nd)) != 0)
return (error);
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
error = setfmode(td, td->td_ucred, nd.ni_vp, mode);
vrele(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -3088,20 +2978,18 @@ kern_fchownat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
int uid, int gid, int flag)
{
struct nameidata nd;
- int error, vfslocked, follow;
+ int error, follow;
AUDIT_ARG_OWNER(uid, gid);
follow = (flag & AT_SYMLINK_NOFOLLOW) ? NOFOLLOW : FOLLOW;
- NDINIT_ATRIGHTS(&nd, LOOKUP, follow | MPSAFE | AUDITVNODE1, pathseg,
+ NDINIT_ATRIGHTS(&nd, LOOKUP, follow | AUDITVNODE1, pathseg,
path, fd, CAP_FCHOWN, td);
if ((error = namei(&nd)) != 0)
return (error);
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
error = setfown(td, td->td_ucred, nd.ni_vp, uid, gid);
vrele(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -3296,20 +3184,18 @@ kern_utimesat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
{
struct nameidata nd;
struct timespec ts[2];
- int error, vfslocked;
+ int error;
if ((error = getutimes(tptr, tptrseg, ts)) != 0)
return (error);
- NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | MPSAFE | AUDITVNODE1, pathseg,
+ NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | AUDITVNODE1, pathseg,
path, fd, CAP_FUTIMES, td);
if ((error = namei(&nd)) != 0)
return (error);
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
error = setutimes(td, nd.ni_vp, ts, 2, tptr == NULL);
vrele(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -3342,18 +3228,15 @@ kern_lutimes(struct thread *td, char *path, enum uio_seg pathseg,
struct timespec ts[2];
int error;
struct nameidata nd;
- int vfslocked;
if ((error = getutimes(tptr, tptrseg, ts)) != 0)
return (error);
- NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE | AUDITVNODE1, pathseg, path, td);
+ NDINIT(&nd, LOOKUP, NOFOLLOW | AUDITVNODE1, pathseg, path, td);
if ((error = namei(&nd)) != 0)
return (error);
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
error = setutimes(td, nd.ni_vp, ts, 2, tptr == NULL);
vrele(nd.ni_vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -3384,7 +3267,6 @@ kern_futimes(struct thread *td, int fd, struct timeval *tptr,
{
struct timespec ts[2];
struct file *fp;
- int vfslocked;
int error;
AUDIT_ARG_FD(fd);
@@ -3393,14 +3275,12 @@ kern_futimes(struct thread *td, int fd, struct timeval *tptr,
if ((error = getvnode(td->td_proc->p_fd, fd, CAP_FUTIMES, &fp))
!= 0)
return (error);
- vfslocked = VFS_LOCK_GIANT(fp->f_vnode->v_mount);
#ifdef AUDIT
vn_lock(fp->f_vnode, LK_SHARED | LK_RETRY);
AUDIT_ARG_VNODE1(fp->f_vnode);
VOP_UNLOCK(fp->f_vnode, 0);
#endif
error = setutimes(td, fp->f_vnode, ts, 2, tptr == NULL);
- VFS_UNLOCK_GIANT(vfslocked);
fdrop(fp, td);
return (error);
}
@@ -3436,20 +3316,18 @@ kern_truncate(struct thread *td, char *path, enum uio_seg pathseg, off_t length)
void *rl_cookie;
struct vattr vattr;
struct nameidata nd;
- int error, vfslocked;
+ int error;
if (length < 0)
return(EINVAL);
- NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE | AUDITVNODE1, pathseg, path, td);
+ NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, pathseg, path, td);
if ((error = namei(&nd)) != 0)
return (error);
- vfslocked = NDHASGIANT(&nd);
vp = nd.ni_vp;
rl_cookie = vn_rangelock_wlock(vp, 0, OFF_MAX);
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) {
vn_rangelock_unlock(vp, rl_cookie);
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
NDFREE(&nd, NDF_ONLY_PNBUF);
@@ -3470,7 +3348,6 @@ kern_truncate(struct thread *td, char *path, enum uio_seg pathseg, off_t length)
vn_finished_write(mp);
vn_rangelock_unlock(vp, rl_cookie);
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -3543,7 +3420,6 @@ sys_fsync(td, uap)
struct vnode *vp;
struct mount *mp;
struct file *fp;
- int vfslocked;
int error, lock_flags;
AUDIT_ARG_FD(uap->fd);
@@ -3551,7 +3427,6 @@ sys_fsync(td, uap)
&fp)) != 0)
return (error);
vp = fp->f_vnode;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0)
goto drop;
if (MNT_SHARED_WRITES(mp) ||
@@ -3572,7 +3447,6 @@ sys_fsync(td, uap)
VOP_UNLOCK(vp, 0);
vn_finished_write(mp);
drop:
- VFS_UNLOCK_GIANT(vfslocked);
fdrop(fp, td);
return (error);
}
@@ -3629,23 +3503,19 @@ kern_renameat(struct thread *td, int oldfd, char *old, int newfd, char *new,
struct mount *mp = NULL;
struct vnode *tvp, *fvp, *tdvp;
struct nameidata fromnd, tond;
- int tvfslocked;
- int fvfslocked;
int error;
bwillwrite();
#ifdef MAC
NDINIT_ATRIGHTS(&fromnd, DELETE, LOCKPARENT | LOCKLEAF | SAVESTART |
- MPSAFE | AUDITVNODE1, pathseg, old, oldfd, CAP_DELETE, td);
+ AUDITVNODE1, pathseg, old, oldfd, CAP_DELETE, td);
#else
- NDINIT_ATRIGHTS(&fromnd, DELETE, WANTPARENT | SAVESTART | MPSAFE |
+ NDINIT_ATRIGHTS(&fromnd, DELETE, WANTPARENT | SAVESTART |
AUDITVNODE1, pathseg, old, oldfd, CAP_DELETE, td);
#endif
if ((error = namei(&fromnd)) != 0)
return (error);
- fvfslocked = NDHASGIANT(&fromnd);
- tvfslocked = 0;
#ifdef MAC
error = mac_vnode_check_rename_from(td->td_ucred, fromnd.ni_dvp,
fromnd.ni_vp, &fromnd.ni_cnd);
@@ -3663,7 +3533,7 @@ kern_renameat(struct thread *td, int oldfd, char *old, int newfd, char *new,
goto out1;
}
NDINIT_ATRIGHTS(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE |
- SAVESTART | MPSAFE | AUDITVNODE2, pathseg, new, newfd, CAP_CREATE,
+ SAVESTART | AUDITVNODE2, pathseg, new, newfd, CAP_CREATE,
td);
if (fromnd.ni_vp->v_type == VDIR)
tond.ni_cnd.cn_flags |= WILLBEDIR;
@@ -3677,7 +3547,6 @@ kern_renameat(struct thread *td, int oldfd, char *old, int newfd, char *new,
vn_finished_write(mp);
goto out1;
}
- tvfslocked = NDHASGIANT(&tond);
tdvp = tond.ni_dvp;
tvp = tond.ni_vp;
if (tvp != NULL) {
@@ -3727,8 +3596,6 @@ out:
out1:
if (fromnd.ni_startdir)
vrele(fromnd.ni_startdir);
- VFS_UNLOCK_GIANT(fvfslocked);
- VFS_UNLOCK_GIANT(tvfslocked);
if (error == -1)
return (0);
return (error);
@@ -3785,17 +3652,15 @@ kern_mkdirat(struct thread *td, int fd, char *path, enum uio_seg segflg,
struct vattr vattr;
int error;
struct nameidata nd;
- int vfslocked;
AUDIT_ARG_MODE(mode);
restart:
bwillwrite();
- NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | MPSAFE |
+ NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME |
AUDITVNODE1, segflg, path, fd, CAP_MKDIR, td);
nd.ni_cnd.cn_flags |= WILLBEDIR;
if ((error = namei(&nd)) != 0)
return (error);
- vfslocked = NDHASGIANT(&nd);
vp = nd.ni_vp;
if (vp != NULL) {
NDFREE(&nd, NDF_ONLY_PNBUF);
@@ -3809,13 +3674,11 @@ restart:
else
vput(nd.ni_dvp);
vrele(vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (EEXIST);
}
if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) {
NDFREE(&nd, NDF_ONLY_PNBUF);
vput(nd.ni_dvp);
- VFS_UNLOCK_GIANT(vfslocked);
if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0)
return (error);
goto restart;
@@ -3838,7 +3701,6 @@ out:
if (!error)
vput(nd.ni_vp);
vn_finished_write(mp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -3875,15 +3737,13 @@ kern_rmdirat(struct thread *td, int fd, char *path, enum uio_seg pathseg)
struct vnode *vp;
int error;
struct nameidata nd;
- int vfslocked;
restart:
bwillwrite();
- NDINIT_ATRIGHTS(&nd, DELETE, LOCKPARENT | LOCKLEAF | MPSAFE |
+ NDINIT_ATRIGHTS(&nd, DELETE, LOCKPARENT | LOCKLEAF |
AUDITVNODE1, pathseg, path, fd, CAP_RMDIR, td);
if ((error = namei(&nd)) != 0)
return (error);
- vfslocked = NDHASGIANT(&nd);
vp = nd.ni_vp;
if (vp->v_type != VDIR) {
error = ENOTDIR;
@@ -3916,7 +3776,6 @@ restart:
vrele(nd.ni_dvp);
else
vput(nd.ni_dvp);
- VFS_UNLOCK_GIANT(vfslocked);
if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0)
return (error);
goto restart;
@@ -3930,7 +3789,6 @@ out:
vrele(nd.ni_dvp);
else
vput(nd.ni_dvp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -3968,7 +3826,7 @@ kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap,
struct iovec aiov, kiov;
struct dirent *dp, *edp;
caddr_t dirbuf;
- int error, eofflag, readcnt, vfslocked;
+ int error, eofflag, readcnt;
long loff;
off_t foffset;
@@ -3985,9 +3843,7 @@ kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap,
vp = fp->f_vnode;
foffset = foffset_lock(fp, 0);
unionread:
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
if (vp->v_type != VDIR) {
- VFS_UNLOCK_GIANT(vfslocked);
foffset_unlock(fp, foffset, 0);
fdrop(fp, td);
return (EINVAL);
@@ -4006,7 +3862,6 @@ unionread:
error = mac_vnode_check_readdir(td->td_ucred, vp);
if (error) {
VOP_UNLOCK(vp, 0);
- VFS_UNLOCK_GIANT(vfslocked);
foffset_unlock(fp, foffset, FOF_NOUPDATE);
fdrop(fp, td);
return (error);
@@ -4065,7 +3920,6 @@ unionread:
}
if (error) {
VOP_UNLOCK(vp, 0);
- VFS_UNLOCK_GIANT(vfslocked);
foffset_unlock(fp, foffset, 0);
fdrop(fp, td);
return (error);
@@ -4080,11 +3934,9 @@ unionread:
fp->f_data = vp;
foffset = 0;
vput(tvp);
- VFS_UNLOCK_GIANT(vfslocked);
goto unionread;
}
VOP_UNLOCK(vp, 0);
- VFS_UNLOCK_GIANT(vfslocked);
foffset_unlock(fp, foffset, 0);
fdrop(fp, td);
td->td_retval[0] = uap->count - auio.uio_resid;
@@ -4135,7 +3987,6 @@ kern_getdirentries(struct thread *td, int fd, char *buf, u_int count,
struct file *fp;
struct uio auio;
struct iovec aiov;
- int vfslocked;
long loff;
int error, eofflag;
off_t foffset;
@@ -4154,9 +4005,7 @@ kern_getdirentries(struct thread *td, int fd, char *buf, u_int count,
vp = fp->f_vnode;
foffset = foffset_lock(fp, 0);
unionread:
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
if (vp->v_type != VDIR) {
- VFS_UNLOCK_GIANT(vfslocked);
error = EINVAL;
goto fail;
}
@@ -4179,7 +4028,6 @@ unionread:
foffset = auio.uio_offset;
if (error) {
VOP_UNLOCK(vp, 0);
- VFS_UNLOCK_GIANT(vfslocked);
goto fail;
}
if (count == auio.uio_resid &&
@@ -4192,11 +4040,9 @@ unionread:
fp->f_data = vp;
foffset = 0;
vput(tvp);
- VFS_UNLOCK_GIANT(vfslocked);
goto unionread;
}
VOP_UNLOCK(vp, 0);
- VFS_UNLOCK_GIANT(vfslocked);
*basep = loff;
if (residp != NULL)
*residp = auio.uio_resid;
@@ -4276,13 +4122,11 @@ sys_revoke(td, uap)
struct vattr vattr;
int error;
struct nameidata nd;
- int vfslocked;
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1,
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1,
UIO_USERSPACE, uap->path, td);
if ((error = namei(&nd)) != 0)
return (error);
- vfslocked = NDHASGIANT(&nd);
vp = nd.ni_vp;
NDFREE(&nd, NDF_ONLY_PNBUF);
if (vp->v_type != VCHR || vp->v_rdev == NULL) {
@@ -4306,7 +4150,6 @@ sys_revoke(td, uap)
VOP_REVOKE(vp, REVOKEALL);
out:
vput(vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -4382,25 +4225,22 @@ sys_lgetfh(td, uap)
struct nameidata nd;
fhandle_t fh;
register struct vnode *vp;
- int vfslocked;
int error;
error = priv_check(td, PRIV_VFS_GETFH);
if (error)
return (error);
- NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1,
+ NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | AUDITVNODE1,
UIO_USERSPACE, uap->fname, td);
error = namei(&nd);
if (error)
return (error);
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
vp = nd.ni_vp;
bzero(&fh, sizeof(fh));
fh.fh_fsid = vp->v_mount->mnt_stat.f_fsid;
error = VOP_VPTOFH(vp, &fh.fh_fid);
vput(vp);
- VFS_UNLOCK_GIANT(vfslocked);
if (error)
return (error);
error = copyout(&fh, uap->fhp, sizeof (fh));
@@ -4421,25 +4261,22 @@ sys_getfh(td, uap)
struct nameidata nd;
fhandle_t fh;
register struct vnode *vp;
- int vfslocked;
int error;
error = priv_check(td, PRIV_VFS_GETFH);
if (error)
return (error);
- NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1,
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1,
UIO_USERSPACE, uap->fname, td);
error = namei(&nd);
if (error)
return (error);
- vfslocked = NDHASGIANT(&nd);
NDFREE(&nd, NDF_ONLY_PNBUF);
vp = nd.ni_vp;
bzero(&fh, sizeof(fh));
fh.fh_fsid = vp->v_mount->mnt_stat.f_fsid;
error = VOP_VPTOFH(vp, &fh.fh_fid);
vput(vp);
- VFS_UNLOCK_GIANT(vfslocked);
if (error)
return (error);
error = copyout(&fh, uap->fhp, sizeof (fh));
@@ -4472,7 +4309,6 @@ sys_fhopen(td, uap)
struct fhandle fhp;
struct file *fp;
int fmode, error;
- int vfslocked;
int indx;
error = priv_check(td, PRIV_VFS_FHOPEN);
@@ -4490,19 +4326,15 @@ sys_fhopen(td, uap)
mp = vfs_busyfs(&fhp.fh_fsid);
if (mp == NULL)
return (ESTALE);
- vfslocked = VFS_LOCK_GIANT(mp);
/* now give me my vnode, it gets returned to me locked */
error = VFS_FHTOVP(mp, &fhp.fh_fid, LK_EXCLUSIVE, &vp);
vfs_unbusy(mp);
- if (error) {
- VFS_UNLOCK_GIANT(vfslocked);
+ if (error)
return (error);
- }
error = falloc_noinstall(td, &fp);
if (error) {
vput(vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
/*
@@ -4539,7 +4371,6 @@ sys_fhopen(td, uap)
error = finstall(td, fp, &indx, fmode);
bad:
- VFS_UNLOCK_GIANT(vfslocked);
fdrop(fp, td);
td->td_retval[0] = indx;
return (error);
@@ -4581,7 +4412,6 @@ kern_fhstat(struct thread *td, struct fhandle fh, struct stat *sb)
{
struct mount *mp;
struct vnode *vp;
- int vfslocked;
int error;
error = priv_check(td, PRIV_VFS_FHSTAT);
@@ -4589,16 +4419,12 @@ kern_fhstat(struct thread *td, struct fhandle fh, struct stat *sb)
return (error);
if ((mp = vfs_busyfs(&fh.fh_fsid)) == NULL)
return (ESTALE);
- vfslocked = VFS_LOCK_GIANT(mp);
error = VFS_FHTOVP(mp, &fh.fh_fid, LK_EXCLUSIVE, &vp);
vfs_unbusy(mp);
- if (error) {
- VFS_UNLOCK_GIANT(vfslocked);
+ if (error)
return (error);
- }
error = vn_stat(vp, sb, td->td_ucred, NOCRED, td);
vput(vp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -4638,7 +4464,6 @@ kern_fhstatfs(struct thread *td, fhandle_t fh, struct statfs *buf)
struct statfs *sp;
struct mount *mp;
struct vnode *vp;
- int vfslocked;
int error;
error = priv_check(td, PRIV_VFS_FHSTATFS);
@@ -4646,11 +4471,9 @@ kern_fhstatfs(struct thread *td, fhandle_t fh, struct statfs *buf)
return (error);
if ((mp = vfs_busyfs(&fh.fh_fsid)) == NULL)
return (ESTALE);
- vfslocked = VFS_LOCK_GIANT(mp);
error = VFS_FHTOVP(mp, &fh.fh_fid, LK_EXCLUSIVE, &vp);
if (error) {
vfs_unbusy(mp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
vput(vp);
@@ -4674,7 +4497,6 @@ kern_fhstatfs(struct thread *td, fhandle_t fh, struct statfs *buf)
*buf = *sp;
out:
vfs_unbusy(mp);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -4729,17 +4551,13 @@ kern_posix_fallocate(struct thread *td, int fd, off_t offset, off_t len)
ooffset = offset;
bwillwrite();
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
mp = NULL;
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
- if (error != 0) {
- VFS_UNLOCK_GIANT(vfslocked);
+ if (error != 0)
break;
- }
error = vn_lock(vp, LK_EXCLUSIVE);
if (error != 0) {
vn_finished_write(mp);
- VFS_UNLOCK_GIANT(vfslocked);
break;
}
#ifdef MAC
@@ -4749,7 +4567,6 @@ kern_posix_fallocate(struct thread *td, int fd, off_t offset, off_t len)
error = VOP_ALLOCATE(vp, &offset, &len);
VOP_UNLOCK(vp, 0);
vn_finished_write(mp);
- VFS_UNLOCK_GIANT(vfslocked);
if (olen + ooffset != offset + len) {
panic("offset + len changed from %jx/%jx to %jx/%jx",
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 49535cc7c15e..402a9d0b860b 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -125,16 +125,12 @@ vn_open_cred(struct nameidata *ndp, int *flagp, int cmode, u_int vn_open_flags,
struct vattr vat;
struct vattr *vap = &vat;
int fmode, error;
- int vfslocked, mpsafe;
- mpsafe = ndp->ni_cnd.cn_flags & MPSAFE;
restart:
- vfslocked = 0;
fmode = *flagp;
if (fmode & O_CREAT) {
ndp->ni_cnd.cn_nameiop = CREATE;
- ndp->ni_cnd.cn_flags = ISOPEN | LOCKPARENT | LOCKLEAF |
- MPSAFE;
+ ndp->ni_cnd.cn_flags = ISOPEN | LOCKPARENT | LOCKLEAF;
if ((fmode & O_EXCL) == 0 && (fmode & O_NOFOLLOW) == 0)
ndp->ni_cnd.cn_flags |= FOLLOW;
if (!(vn_open_flags & VN_OPEN_NOAUDIT))
@@ -142,9 +138,6 @@ restart:
bwillwrite();
if ((error = namei(ndp)) != 0)
return (error);
- vfslocked = NDHASGIANT(ndp);
- if (!mpsafe)
- ndp->ni_cnd.cn_flags &= ~MPSAFE;
if (ndp->ni_vp == NULL) {
VATTR_NULL(vap);
vap->va_type = VREG;
@@ -154,7 +147,6 @@ restart:
if (vn_start_write(ndp->ni_dvp, &mp, V_NOWAIT) != 0) {
NDFREE(ndp, NDF_ONLY_PNBUF);
vput(ndp->ni_dvp);
- VFS_UNLOCK_GIANT(vfslocked);
if ((error = vn_start_write(NULL, &mp,
V_XSLEEP | PCATCH)) != 0)
return (error);
@@ -170,7 +162,6 @@ restart:
vput(ndp->ni_dvp);
vn_finished_write(mp);
if (error) {
- VFS_UNLOCK_GIANT(vfslocked);
NDFREE(ndp, NDF_ONLY_PNBUF);
return (error);
}
@@ -192,30 +183,23 @@ restart:
} else {
ndp->ni_cnd.cn_nameiop = LOOKUP;
ndp->ni_cnd.cn_flags = ISOPEN |
- ((fmode & O_NOFOLLOW) ? NOFOLLOW : FOLLOW) |
- LOCKLEAF | MPSAFE;
+ ((fmode & O_NOFOLLOW) ? NOFOLLOW : FOLLOW) | LOCKLEAF;
if (!(fmode & FWRITE))
ndp->ni_cnd.cn_flags |= LOCKSHARED;
if (!(vn_open_flags & VN_OPEN_NOAUDIT))
ndp->ni_cnd.cn_flags |= AUDITVNODE1;
if ((error = namei(ndp)) != 0)
return (error);
- if (!mpsafe)
- ndp->ni_cnd.cn_flags &= ~MPSAFE;
- vfslocked = NDHASGIANT(ndp);
vp = ndp->ni_vp;
}
error = vn_open_vnode(vp, fmode, cred, td, fp);
if (error)
goto bad;
*flagp = fmode;
- if (!mpsafe)
- VFS_UNLOCK_GIANT(vfslocked);
return (0);
bad:
NDFREE(ndp, NDF_ONLY_PNBUF);
vput(vp);
- VFS_UNLOCK_GIANT(vfslocked);
*flagp = fmode;
ndp->ni_vp = NULL;
return (error);
@@ -234,7 +218,6 @@ vn_open_vnode(struct vnode *vp, int fmode, struct ucred *cred,
struct flock lf;
int error, have_flock, lock_flags, type;
- VFS_ASSERT_GIANT(vp->v_mount);
if (vp->v_type == VLNK)
return (EMLINK);
if (vp->v_type == VSOCK)
@@ -367,8 +350,6 @@ vn_close(vp, flags, file_cred, td)
else
lock_flags = LK_EXCLUSIVE;
- VFS_ASSERT_GIANT(vp->v_mount);
-
vn_start_write(vp, &mp, V_WAIT);
vn_lock(vp, lock_flags | LK_RETRY);
if (flags & FWRITE) {
@@ -441,8 +422,6 @@ vn_rdwr(enum uio_rw rw, struct vnode *vp, void *base, int len, off_t offset,
void *rl_cookie;
int error, lock_flags;
- VFS_ASSERT_GIANT(vp->v_mount);
-
auio.uio_iov = &aiov;
auio.uio_iovcnt = 1;
aiov.iov_base = base;
@@ -542,8 +521,6 @@ vn_rdwr_inchunks(rw, vp, base, len, offset, segflg, ioflg, active_cred,
int error = 0;
ssize_t iaresid;
- VFS_ASSERT_GIANT(vp->v_mount);
-
do {
int chunk;
@@ -692,7 +669,7 @@ vn_read(fp, uio, active_cred, flags, td)
struct vnode *vp;
struct mtx *mtxp;
int error, ioflag;
- int advice, vfslocked;
+ int advice;
off_t offset, start, end;
KASSERT(uio->uio_td == td, ("uio_td %p is not td %p",
@@ -705,7 +682,6 @@ vn_read(fp, uio, active_cred, flags, td)
if (fp->f_flag & O_DIRECT)
ioflag |= IO_DIRECT;
advice = get_advice(fp, uio);
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vn_lock(vp, LK_SHARED | LK_RETRY);
switch (advice) {
@@ -761,7 +737,6 @@ vn_read(fp, uio, active_cred, flags, td)
mtx_unlock(mtxp);
error = VOP_ADVISE(vp, start, end, POSIX_FADV_DONTNEED);
}
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -780,14 +755,13 @@ vn_write(fp, uio, active_cred, flags, td)
struct mount *mp;
struct mtx *mtxp;
int error, ioflag, lock_flags;
- int advice, vfslocked;
+ int advice;
off_t offset, start, end;
KASSERT(uio->uio_td == td, ("uio_td %p is not td %p",
uio->uio_td, td));
KASSERT(flags & FOF_OFFSET, ("No FOF_OFFSET"));
vp = fp->f_vnode;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
if (vp->v_type == VREG)
bwillwrite();
ioflag = IO_UNIT;
@@ -887,7 +861,6 @@ vn_write(fp, uio, active_cred, flags, td)
}
unlock:
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -1155,7 +1128,6 @@ vn_truncate(struct file *fp, off_t length, struct ucred *active_cred,
struct mount *mp;
struct vnode *vp;
void *rl_cookie;
- int vfslocked;
int error;
vp = fp->f_vnode;
@@ -1165,7 +1137,6 @@ vn_truncate(struct file *fp, off_t length, struct ucred *active_cred,
* might happen partly before and partly after the truncation.
*/
rl_cookie = vn_rangelock_wlock(vp, 0, OFF_MAX);
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
if (error)
goto out1;
@@ -1189,7 +1160,6 @@ out:
VOP_UNLOCK(vp, 0);
vn_finished_write(mp);
out1:
- VFS_UNLOCK_GIANT(vfslocked);
vn_rangelock_unlock(vp, rl_cookie);
return (error);
}
@@ -1205,14 +1175,11 @@ vn_statfile(fp, sb, active_cred, td)
struct thread *td;
{
struct vnode *vp = fp->f_vnode;
- int vfslocked;
int error;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
vn_lock(vp, LK_SHARED | LK_RETRY);
error = vn_stat(vp, sb, active_cred, fp->f_cred, td);
VOP_UNLOCK(vp, 0);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -1340,10 +1307,8 @@ vn_ioctl(fp, com, data, active_cred, td)
{
struct vnode *vp = fp->f_vnode;
struct vattr vattr;
- int vfslocked;
int error;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
error = ENOTTY;
switch (vp->v_type) {
case VREG:
@@ -1365,7 +1330,6 @@ vn_ioctl(fp, com, data, active_cred, td)
default:
break;
}
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -1380,11 +1344,9 @@ vn_poll(fp, events, active_cred, td)
struct thread *td;
{
struct vnode *vp;
- int vfslocked;
int error;
vp = fp->f_vnode;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
#ifdef MAC
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
error = mac_vnode_check_poll(active_cred, fp->f_cred, vp);
@@ -1393,7 +1355,6 @@ vn_poll(fp, events, active_cred, td)
#endif
error = VOP_POLL(vp, events, fp->f_cred, td);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -1442,13 +1403,11 @@ vn_closefile(fp, td)
{
struct vnode *vp;
struct flock lf;
- int vfslocked;
int error;
vp = fp->f_vnode;
fp->f_ops = &badfileops;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
if (fp->f_type == DTYPE_VNODE && fp->f_flag & FHASLOCK)
vref(vp);
@@ -1462,7 +1421,6 @@ vn_closefile(fp, td)
(void) VOP_ADVLOCK(vp, fp, F_UNLCK, &lf, F_FLOCK);
vrele(vp);
}
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -1702,14 +1660,10 @@ vfs_write_resume(mp)
static int
vn_kqfilter(struct file *fp, struct knote *kn)
{
- int vfslocked;
int error;
- vfslocked = VFS_LOCK_GIANT(fp->f_vnode->v_mount);
error = VOP_KQFILTER(fp->f_vnode, kn);
- VFS_UNLOCK_GIANT(vfslocked);
-
- return error;
+ return (error);
}
/*
@@ -1885,17 +1839,15 @@ vn_chmod(struct file *fp, mode_t mode, struct ucred *active_cred,
struct thread *td)
{
struct vnode *vp;
- int error, vfslocked;
+ int error;
vp = fp->f_vnode;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
#ifdef AUDIT
vn_lock(vp, LK_SHARED | LK_RETRY);
AUDIT_ARG_VNODE1(vp);
VOP_UNLOCK(vp, 0);
#endif
error = setfmode(td, active_cred, vp, mode);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
@@ -1904,17 +1856,15 @@ vn_chown(struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred,
struct thread *td)
{
struct vnode *vp;
- int error, vfslocked;
+ int error;
vp = fp->f_vnode;
- vfslocked = VFS_LOCK_GIANT(vp->v_mount);
#ifdef AUDIT
vn_lock(vp, LK_SHARED | LK_RETRY);
AUDIT_ARG_VNODE1(vp);
VOP_UNLOCK(vp, 0);
#endif
error = setfown(td, active_cred, vp, uid, gid);
- VFS_UNLOCK_GIANT(vfslocked);
return (error);
}