Remove the support for using non-mpsafe filesystem modules.
In particular, do not lock Giant conditionally when calling into the filesystem module, remove the VFS_LOCK_GIANT() and related macros. Stop handling buffers belonging to non-mpsafe filesystems. The VFS_VERSION is bumped to indicate the interface change which does not result in the interface signatures changes. Conducted and reviewed by: attilio Tested by: pho
This commit is contained in:
parent
bf3d102133
commit
5050aa86cf
@ -38,6 +38,8 @@
|
||||
# xargs -n1 | sort | uniq -d;
|
||||
# done
|
||||
|
||||
# 20121022: VFS_LOCK_GIANT elimination
|
||||
OLD_FILES+=usr/share/man/man9/VFS_LOCK_GIANT.9.gz
|
||||
# 20121004: remove incomplete unwind.h
|
||||
OLD_FILES+=usr/include/clang/3.2/unwind.h
|
||||
# 20120908: pf cleanup
|
||||
|
@ -430,14 +430,6 @@ extern int fop_getattr(vnode_t *vp, vattr_t *vap);
|
||||
|
||||
#define vn_lock(vp, type)
|
||||
#define VOP_UNLOCK(vp, type)
|
||||
#ifdef VFS_LOCK_GIANT
|
||||
#undef VFS_LOCK_GIANT
|
||||
#endif
|
||||
#define VFS_LOCK_GIANT(mp) 0
|
||||
#ifdef VFS_UNLOCK_GIANT
|
||||
#undef VFS_UNLOCK_GIANT
|
||||
#endif
|
||||
#define VFS_UNLOCK_GIANT(vfslocked)
|
||||
|
||||
extern int vn_open(char *path, int x1, int oflags, int mode, vnode_t **vpp,
|
||||
int x2, int x3);
|
||||
|
@ -280,7 +280,6 @@ MAN= accept_filter.9 \
|
||||
vfs_getnewfsid.9 \
|
||||
vfs_getopt.9 \
|
||||
vfs_getvfs.9 \
|
||||
VFS_LOCK_GIANT.9 \
|
||||
VFS_MOUNT.9 \
|
||||
vfs_mount.9 \
|
||||
vfs_mountedfrom.9 \
|
||||
@ -1413,7 +1412,6 @@ MLINKS+=vfs_getopt.9 vfs_copyopt.9 \
|
||||
vfs_getopt.9 vfs_setopt.9 \
|
||||
vfs_getopt.9 vfs_setopt_part.9 \
|
||||
vfs_getopt.9 vfs_setopts.9
|
||||
MLINKS+=VFS_LOCK_GIANT.9 VFS_UNLOCK_GIANT.9
|
||||
MLINKS+=vhold.9 vdrop.9 \
|
||||
vhold.9 vdropl.9 \
|
||||
vhold.9 vholdl.9
|
||||
|
@ -1,93 +0,0 @@
|
||||
.\"
|
||||
.\" Copyright (c) 2005 Robert N. M. Watson
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice(s), this list of conditions and the following disclaimer as
|
||||
.\" the first lines of this file unmodified other than the possible
|
||||
.\" addition of one or more copyright notices.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice(s), this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
|
||||
.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
.\" DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
|
||||
.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
.\" DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd September 21, 2005
|
||||
.Dt VFS_LOCK_GIANT 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm VFS_LOCK_GIANT ,
|
||||
.Nm VFS_UNLOCK_GIANT
|
||||
.Nd "conditionally lock and unlock Giant around entry into VFS"
|
||||
.Sh SYNOPSIS
|
||||
.In sys/param.h
|
||||
.In sys/mount.h
|
||||
.In sys/vnode.h
|
||||
.Ft int
|
||||
.Fn VFS_LOCK_GIANT "struct mount *mp"
|
||||
.Ft void
|
||||
.Fn VFS_UNLOCK_GIANT "int vfslocked"
|
||||
.Sh DESCRIPTION
|
||||
.Fn VFS_LOCK_GIANT
|
||||
will conditionally acquire the
|
||||
.Va Giant
|
||||
lock if the file system referenced by
|
||||
.Fa mp
|
||||
is marked as MPSAFE or not, returning a flag indicating whether
|
||||
.Va Giant
|
||||
was
|
||||
set, which may later be passed to
|
||||
.Fn VFS_UNLOCK_GIANT .
|
||||
The value of
|
||||
.Fa mp
|
||||
will typically be derived from the mount pointer in a
|
||||
.Vt vnode
|
||||
on which a VFS operation will be performed.
|
||||
.Pp
|
||||
.Fn VFS_UNLOCK_GIANT
|
||||
conditionally releases the
|
||||
.Va Giant
|
||||
lock if the passed
|
||||
.Fa vfslocked
|
||||
argument is non-zero.
|
||||
It is expected that the argument will be derived from the return values of
|
||||
.Fn VFS_LOCK_GIANT
|
||||
or
|
||||
.Xr NDHASGIANT 9 .
|
||||
.Sh RETURN VALUES
|
||||
.Fn VFS_LOCK_GIANT
|
||||
returns a boolean indicating whether or not
|
||||
.Va Giant
|
||||
was acquired.
|
||||
.Sh SEE ALSO
|
||||
.Xr mutex 9 ,
|
||||
.Xr NDHASGIANT 9 ,
|
||||
.Xr vnode 9
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
MPSAFE VFS support for
|
||||
.Fx
|
||||
was implemented by
|
||||
.An Jeff Roberson .
|
||||
.Pp
|
||||
This manual page was written by
|
||||
.An Robert Watson .
|
||||
.Sh BUGS
|
||||
Non-MPSAFE file systems exist, requiring callers conditional locking and
|
||||
unlocking of
|
||||
.Va Giant .
|
@ -168,19 +168,6 @@ This flag allows the
|
||||
function to return the parent (directory) vnode in an unlocked state.
|
||||
The parent vnode must be released separately by using
|
||||
.Xr vrele 9 .
|
||||
.It Dv MPSAFE
|
||||
With this flag set,
|
||||
.Fn namei
|
||||
will conditionally acquire
|
||||
.Va Giant
|
||||
if it is required by a traversed file system.
|
||||
MPSAFE callers should pass the results of
|
||||
.Fn NDHASGIANT
|
||||
to
|
||||
.Xr VFS_UNLOCK_GIANT
|
||||
in order to conditionally release
|
||||
.Va Giant
|
||||
if necessary.
|
||||
.It Dv NOCACHE
|
||||
Avoid
|
||||
.Fn namei
|
||||
@ -354,7 +341,6 @@ An attempt is made to modify a file or directory on a read-only file system.
|
||||
.Xr uio 9 ,
|
||||
.Xr uma 9 ,
|
||||
.Xr VFS 9 ,
|
||||
.Xr VFS_UNLOCK_GIANT 9 ,
|
||||
.Xr vnode 9 ,
|
||||
.Xr vput 9 ,
|
||||
.Xr vref 9
|
||||
|
@ -594,14 +594,12 @@ ctl_be_block_flush_file(struct ctl_be_block_lun *be_lun,
|
||||
{
|
||||
union ctl_io *io;
|
||||
struct mount *mountpoint;
|
||||
int vfs_is_locked, error, lock_flags;
|
||||
int error, lock_flags;
|
||||
|
||||
DPRINTF("entered\n");
|
||||
|
||||
io = beio->io;
|
||||
|
||||
vfs_is_locked = VFS_LOCK_GIANT(be_lun->vn->v_mount);
|
||||
|
||||
(void) vn_start_write(be_lun->vn, &mountpoint, V_WAIT);
|
||||
|
||||
if (MNT_SHARED_WRITES(mountpoint)
|
||||
@ -621,8 +619,6 @@ ctl_be_block_flush_file(struct ctl_be_block_lun *be_lun,
|
||||
|
||||
vn_finished_write(mountpoint);
|
||||
|
||||
VFS_UNLOCK_GIANT(vfs_is_locked);
|
||||
|
||||
if (error == 0)
|
||||
ctl_set_success(&io->scsiio);
|
||||
else {
|
||||
@ -648,7 +644,7 @@ ctl_be_block_dispatch_file(struct ctl_be_block_lun *be_lun,
|
||||
union ctl_io *io;
|
||||
struct uio xuio;
|
||||
struct iovec *xiovec;
|
||||
int vfs_is_locked, flags;
|
||||
int flags;
|
||||
int error, i;
|
||||
|
||||
DPRINTF("entered\n");
|
||||
@ -681,7 +677,6 @@ ctl_be_block_dispatch_file(struct ctl_be_block_lun *be_lun,
|
||||
xiovec->iov_len = beio->sg_segs[i].len;
|
||||
}
|
||||
|
||||
vfs_is_locked = VFS_LOCK_GIANT(be_lun->vn->v_mount);
|
||||
if (beio->bio_cmd == BIO_READ) {
|
||||
vn_lock(be_lun->vn, LK_SHARED | LK_RETRY);
|
||||
|
||||
@ -754,7 +749,6 @@ ctl_be_block_dispatch_file(struct ctl_be_block_lun *be_lun,
|
||||
|
||||
vn_finished_write(mountpoint);
|
||||
}
|
||||
VFS_UNLOCK_GIANT(vfs_is_locked);
|
||||
|
||||
/*
|
||||
* If we got an error, set the sense data to "MEDIUM ERROR" and
|
||||
@ -1478,7 +1472,6 @@ ctl_be_block_close(struct ctl_be_block_lun *be_lun)
|
||||
DROP_GIANT();
|
||||
if (be_lun->vn) {
|
||||
int flags = FREAD | FWRITE;
|
||||
int vfs_is_locked = 0;
|
||||
|
||||
switch (be_lun->dev_type) {
|
||||
case CTL_BE_BLOCK_DEV:
|
||||
@ -1490,7 +1483,6 @@ ctl_be_block_close(struct ctl_be_block_lun *be_lun)
|
||||
}
|
||||
break;
|
||||
case CTL_BE_BLOCK_FILE:
|
||||
vfs_is_locked = VFS_LOCK_GIANT(be_lun->vn->v_mount);
|
||||
break;
|
||||
case CTL_BE_BLOCK_NONE:
|
||||
default:
|
||||
@ -1505,7 +1497,6 @@ ctl_be_block_close(struct ctl_be_block_lun *be_lun)
|
||||
case CTL_BE_BLOCK_DEV:
|
||||
break;
|
||||
case CTL_BE_BLOCK_FILE:
|
||||
VFS_UNLOCK_GIANT(vfs_is_locked);
|
||||
if (be_lun->backend.file.cred != NULL) {
|
||||
crfree(be_lun->backend.file.cred);
|
||||
be_lun->backend.file.cred = NULL;
|
||||
@ -1529,7 +1520,6 @@ ctl_be_block_open(struct ctl_be_block_softc *softc,
|
||||
struct nameidata nd;
|
||||
int flags;
|
||||
int error;
|
||||
int vfs_is_locked;
|
||||
|
||||
/*
|
||||
* XXX KDM allow a read-only option?
|
||||
@ -1587,8 +1577,6 @@ ctl_be_block_open(struct ctl_be_block_softc *softc,
|
||||
return (error);
|
||||
}
|
||||
|
||||
vfs_is_locked = NDHASGIANT(&nd);
|
||||
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
|
||||
be_lun->vn = nd.ni_vp;
|
||||
@ -1604,7 +1592,6 @@ ctl_be_block_open(struct ctl_be_block_softc *softc,
|
||||
"%s is not a disk or file", be_lun->dev_path);
|
||||
}
|
||||
VOP_UNLOCK(be_lun->vn, 0);
|
||||
VFS_UNLOCK_GIANT(vfs_is_locked);
|
||||
|
||||
if (error != 0) {
|
||||
ctl_be_block_close(be_lun);
|
||||
@ -2090,7 +2077,7 @@ ctl_be_block_modify(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
|
||||
{
|
||||
struct ctl_lun_modify_params *params;
|
||||
struct ctl_be_block_lun *be_lun;
|
||||
int vfs_is_locked, error;
|
||||
int error;
|
||||
|
||||
params = &req->reqdata.modify;
|
||||
|
||||
@ -2120,7 +2107,6 @@ ctl_be_block_modify(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
|
||||
}
|
||||
}
|
||||
|
||||
vfs_is_locked = VFS_LOCK_GIANT(be_lun->vn->v_mount);
|
||||
vn_lock(be_lun->vn, LK_SHARED | LK_RETRY);
|
||||
|
||||
if (be_lun->vn->v_type == VREG)
|
||||
@ -2129,7 +2115,6 @@ ctl_be_block_modify(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
|
||||
error = ctl_be_block_modify_dev(be_lun, req);
|
||||
|
||||
VOP_UNLOCK(be_lun->vn, 0);
|
||||
VFS_UNLOCK_GIANT(vfs_is_locked);
|
||||
|
||||
if (error != 0)
|
||||
goto bailout_error;
|
||||
|
@ -69,7 +69,7 @@ kobj_open_file_vnode(const char *file)
|
||||
struct thread *td = curthread;
|
||||
struct filedesc *fd;
|
||||
struct nameidata nd;
|
||||
int error, flags, vfslocked;
|
||||
int error, flags;
|
||||
|
||||
fd = td->td_proc->p_fd;
|
||||
FILEDESC_XLOCK(fd);
|
||||
@ -84,15 +84,13 @@ kobj_open_file_vnode(const char *file)
|
||||
FILEDESC_XUNLOCK(fd);
|
||||
|
||||
flags = FREAD | O_NOFOLLOW;
|
||||
NDINIT(&nd, LOOKUP, MPSAFE, UIO_SYSSPACE, file, td);
|
||||
NDINIT(&nd, LOOKUP, 0, UIO_SYSSPACE, file, td);
|
||||
error = vn_open_cred(&nd, &flags, 0, 0, curthread->td_ucred, NULL);
|
||||
if (error != 0)
|
||||
return (NULL);
|
||||
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);
|
||||
return (nd.ni_vp);
|
||||
}
|
||||
|
||||
@ -130,15 +128,13 @@ kobj_get_filesize_vnode(struct _buf *file, uint64_t *size)
|
||||
{
|
||||
struct vnode *vp = file->ptr;
|
||||
struct vattr va;
|
||||
int error, vfslocked;
|
||||
int error;
|
||||
|
||||
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);
|
||||
if (error == 0)
|
||||
*size = (uint64_t)va.va_size;
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -171,7 +167,7 @@ kobj_read_file_vnode(struct _buf *file, char *buf, unsigned size, unsigned off)
|
||||
struct thread *td = curthread;
|
||||
struct uio auio;
|
||||
struct iovec aiov;
|
||||
int error, vfslocked;
|
||||
int error;
|
||||
|
||||
bzero(&aiov, sizeof(aiov));
|
||||
bzero(&auio, sizeof(auio));
|
||||
@ -187,11 +183,9 @@ kobj_read_file_vnode(struct _buf *file, char *buf, unsigned size, unsigned off)
|
||||
auio.uio_resid = size;
|
||||
auio.uio_td = td;
|
||||
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
vn_lock(vp, LK_SHARED | LK_RETRY);
|
||||
error = VOP_READ(vp, &auio, IO_UNIT | IO_SYNC, td->td_ucred);
|
||||
VOP_UNLOCK(vp, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error != 0 ? -1 : size - auio.uio_resid);
|
||||
}
|
||||
|
||||
@ -221,14 +215,7 @@ void
|
||||
kobj_close_file(struct _buf *file)
|
||||
{
|
||||
|
||||
if (file->mounted) {
|
||||
struct vnode *vp = file->ptr;
|
||||
struct thread *td = curthread;
|
||||
int vfslocked;
|
||||
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
vn_close(vp, FREAD, td->td_ucred, td);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
}
|
||||
if (file->mounted)
|
||||
vn_close(file->ptr, FREAD, curthread->td_ucred, curthread);
|
||||
kmem_free(file, sizeof(*file));
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ lookupnameat(char *dirname, enum uio_seg seg, enum symfollow follow,
|
||||
vref(startvp);
|
||||
ltype = VOP_ISLOCKED(startvp);
|
||||
VOP_UNLOCK(startvp, 0);
|
||||
NDINIT_ATVP(&nd, LOOKUP, LOCKLEAF | MPSAFE | follow, seg, dirname,
|
||||
NDINIT_ATVP(&nd, LOOKUP, LOCKLEAF | follow, seg, dirname,
|
||||
startvp, curthread);
|
||||
error = namei(&nd);
|
||||
*compvpp = nd.ni_vp;
|
||||
|
@ -193,7 +193,7 @@ vn_openat(char *pnamep, enum uio_seg seg, int filemode, int createmode,
|
||||
|
||||
if (startvp != NULL)
|
||||
vref(startvp);
|
||||
NDINIT_ATVP(&nd, operation, MPSAFE, UIO_SYSSPACE, pnamep, startvp, td);
|
||||
NDINIT_ATVP(&nd, operation, 0, UIO_SYSSPACE, pnamep, startvp, td);
|
||||
filemode |= O_NOFOLLOW;
|
||||
error = vn_open_cred(&nd, &filemode, createmode, 0, td->td_ucred, NULL);
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
@ -223,13 +223,12 @@ zfs_vn_rdwr(enum uio_rw rw, vnode_t *vp, caddr_t base, ssize_t len,
|
||||
ssize_t *residp)
|
||||
{
|
||||
struct thread *td = curthread;
|
||||
int error, vfslocked;
|
||||
int error;
|
||||
ssize_t resid;
|
||||
|
||||
ASSERT(ioflag == 0);
|
||||
ASSERT(ulimit == RLIM64_INFINITY);
|
||||
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
if (rw == UIO_WRITE) {
|
||||
ioflag = IO_SYNC;
|
||||
} else {
|
||||
@ -237,7 +236,6 @@ zfs_vn_rdwr(enum uio_rw rw, vnode_t *vp, caddr_t base, ssize_t len,
|
||||
}
|
||||
error = vn_rdwr(rw, vp, base, len, offset, seg, ioflag, cr, NOCRED,
|
||||
&resid, td);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
if (residp != NULL)
|
||||
*residp = (ssize_t)resid;
|
||||
return (error);
|
||||
@ -249,11 +247,10 @@ static __inline int
|
||||
zfs_vop_fsync(vnode_t *vp, int flag, cred_t *cr)
|
||||
{
|
||||
struct mount *mp;
|
||||
int error, vfslocked;
|
||||
int error;
|
||||
|
||||
ASSERT(flag == FSYNC);
|
||||
|
||||
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);
|
||||
@ -261,7 +258,6 @@ zfs_vop_fsync(vnode_t *vp, int flag, cred_t *cr)
|
||||
VOP_UNLOCK(vp, 0);
|
||||
vn_finished_write(mp);
|
||||
drop:
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
}
|
||||
#define VOP_FSYNC(vp, flag, cr, ct) zfs_vop_fsync((vp), (flag), (cr))
|
||||
@ -269,14 +265,12 @@ zfs_vop_fsync(vnode_t *vp, int flag, cred_t *cr)
|
||||
static __inline int
|
||||
zfs_vop_close(vnode_t *vp, int flag, int count, offset_t offset, cred_t *cr)
|
||||
{
|
||||
int error, vfslocked;
|
||||
int error;
|
||||
|
||||
ASSERT(count == 1);
|
||||
ASSERT(offset == 0);
|
||||
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
error = vn_close(vp, flag, cr, curthread);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
}
|
||||
#define VOP_CLOSE(vp, oflags, count, offset, cr, ct) \
|
||||
|
@ -54,7 +54,7 @@ vdev_file_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
|
||||
vdev_file_t *vf;
|
||||
vnode_t *vp;
|
||||
vattr_t vattr;
|
||||
int error, vfslocked;
|
||||
int error;
|
||||
|
||||
/*
|
||||
* We must have a pathname, and it must be absolute.
|
||||
@ -114,11 +114,9 @@ vdev_file_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
|
||||
* Determine the physical size of the file.
|
||||
*/
|
||||
vattr.va_mask = AT_SIZE;
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
vn_lock(vp, LK_SHARED | LK_RETRY);
|
||||
error = VOP_GETATTR(vp, &vattr, kcred);
|
||||
VOP_UNLOCK(vp, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
if (error) {
|
||||
(void) VOP_CLOSE(vp, spa_mode(vd->vdev_spa), 1, 0, kcred, NULL);
|
||||
vd->vdev_stat.vs_aux = VDEV_AUX_OPEN_FAILED;
|
||||
|
@ -1092,14 +1092,12 @@ zfs_get_done(zgd_t *zgd, int error)
|
||||
{
|
||||
znode_t *zp = zgd->zgd_private;
|
||||
objset_t *os = zp->z_zfsvfs->z_os;
|
||||
int vfslocked;
|
||||
|
||||
if (zgd->zgd_db)
|
||||
dmu_buf_rele(zgd->zgd_db, zgd);
|
||||
|
||||
zfs_range_unlock(zgd->zgd_rl);
|
||||
|
||||
vfslocked = VFS_LOCK_GIANT(zp->z_zfsvfs->z_vfs);
|
||||
/*
|
||||
* Release the vnode asynchronously as we currently have the
|
||||
* txg stopped from syncing.
|
||||
@ -1110,7 +1108,6 @@ zfs_get_done(zgd_t *zgd, int error)
|
||||
zil_add_block(zgd->zgd_zilog, zgd->zgd_bp);
|
||||
|
||||
kmem_free(zgd, sizeof (zgd_t));
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -6337,7 +6334,7 @@ vop_getextattr {
|
||||
}
|
||||
|
||||
flags = FREAD;
|
||||
NDINIT_ATVP(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_SYSSPACE, attrname,
|
||||
NDINIT_ATVP(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, attrname,
|
||||
xvp, td);
|
||||
error = vn_open_cred(&nd, &flags, 0, 0, ap->a_cred, NULL);
|
||||
vp = nd.ni_vp;
|
||||
@ -6405,7 +6402,7 @@ vop_deleteextattr {
|
||||
return (error);
|
||||
}
|
||||
|
||||
NDINIT_ATVP(&nd, DELETE, NOFOLLOW | LOCKPARENT | LOCKLEAF | MPSAFE,
|
||||
NDINIT_ATVP(&nd, DELETE, NOFOLLOW | LOCKPARENT | LOCKLEAF,
|
||||
UIO_SYSSPACE, attrname, xvp, td);
|
||||
error = namei(&nd);
|
||||
vp = nd.ni_vp;
|
||||
@ -6472,7 +6469,7 @@ vop_setextattr {
|
||||
}
|
||||
|
||||
flags = FFLAGS(O_WRONLY | O_CREAT);
|
||||
NDINIT_ATVP(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_SYSSPACE, attrname,
|
||||
NDINIT_ATVP(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, attrname,
|
||||
xvp, td);
|
||||
error = vn_open_cred(&nd, &flags, 0600, 0, ap->a_cred, NULL);
|
||||
vp = nd.ni_vp;
|
||||
@ -6553,7 +6550,7 @@ vop_listextattr {
|
||||
return (error);
|
||||
}
|
||||
|
||||
NDINIT_ATVP(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKSHARED | MPSAFE,
|
||||
NDINIT_ATVP(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKSHARED,
|
||||
UIO_SYSSPACE, ".", xvp, td);
|
||||
error = namei(&nd);
|
||||
vp = nd.ni_vp;
|
||||
|
@ -1404,7 +1404,6 @@ zfs_zinactive(znode_t *zp)
|
||||
vnode_t *vp = ZTOV(zp);
|
||||
zfsvfs_t *zfsvfs = zp->z_zfsvfs;
|
||||
uint64_t z_id = zp->z_id;
|
||||
int vfslocked;
|
||||
|
||||
ASSERT(zp->z_sa_hdl);
|
||||
|
||||
@ -1437,9 +1436,7 @@ zfs_zinactive(znode_t *zp)
|
||||
ZFS_OBJ_HOLD_EXIT(zfsvfs, z_id);
|
||||
ASSERT(vp->v_count == 0);
|
||||
vrecycle(vp);
|
||||
vfslocked = VFS_LOCK_GIANT(zfsvfs->z_vfs);
|
||||
zfs_rmnode(zp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -335,7 +335,7 @@ linprocfs_domtab(PFS_FILL_ARGS)
|
||||
int error;
|
||||
|
||||
/* resolve symlinks etc. in the emulation tree prefix */
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, linux_emul_path, td);
|
||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, linux_emul_path, td);
|
||||
flep = NULL;
|
||||
error = namei(&nd);
|
||||
lep = linux_emul_path;
|
||||
@ -343,7 +343,6 @@ linprocfs_domtab(PFS_FILL_ARGS)
|
||||
if (vn_fullpath(td, nd.ni_vp, &dlep, &flep) == 0)
|
||||
lep = dlep;
|
||||
vrele(nd.ni_vp);
|
||||
VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
|
||||
}
|
||||
lep_len = strlen(lep);
|
||||
|
||||
@ -414,7 +413,7 @@ linprocfs_dopartitions(PFS_FILL_ARGS)
|
||||
int major, minor;
|
||||
|
||||
/* resolve symlinks etc. in the emulation tree prefix */
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, linux_emul_path, td);
|
||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, linux_emul_path, td);
|
||||
flep = NULL;
|
||||
error = namei(&nd);
|
||||
lep = linux_emul_path;
|
||||
@ -422,7 +421,6 @@ linprocfs_dopartitions(PFS_FILL_ARGS)
|
||||
if (vn_fullpath(td, nd.ni_vp, &dlep, &flep) == 0)
|
||||
lep = dlep;
|
||||
vrele(nd.ni_vp);
|
||||
VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
|
||||
}
|
||||
lep_len = strlen(lep);
|
||||
|
||||
@ -1012,7 +1010,6 @@ linprocfs_doprocmaps(PFS_FILL_ARGS)
|
||||
int error;
|
||||
struct vnode *vp;
|
||||
struct vattr vat;
|
||||
int locked;
|
||||
|
||||
PROC_LOCK(p);
|
||||
error = p_candebug(td, p);
|
||||
@ -1065,12 +1062,10 @@ linprocfs_doprocmaps(PFS_FILL_ARGS)
|
||||
VM_OBJECT_UNLOCK(obj);
|
||||
if (vp) {
|
||||
vn_fullpath(td, vp, &name, &freename);
|
||||
locked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
vn_lock(vp, LK_SHARED | LK_RETRY);
|
||||
VOP_GETATTR(vp, &vat, td->td_ucred);
|
||||
ino = vat.va_fileid;
|
||||
vput(vp);
|
||||
VFS_UNLOCK_GIANT(locked);
|
||||
}
|
||||
} else {
|
||||
flags = 0;
|
||||
|
@ -337,7 +337,7 @@ getdents_common(struct thread *td, struct linux_getdents64_args *args,
|
||||
struct l_dirent64 *linux_dirent64;
|
||||
int buflen, error, eofflag, nbytes, justone;
|
||||
u_long *cookies = NULL, *cookiep;
|
||||
int ncookies, vfslocked;
|
||||
int ncookies;
|
||||
|
||||
nbytes = args->count;
|
||||
if (nbytes == 1) {
|
||||
@ -359,9 +359,7 @@ getdents_common(struct thread *td, struct linux_getdents64_args *args,
|
||||
|
||||
off = foffset_lock(fp, 0);
|
||||
vp = fp->f_vnode;
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
if (vp->v_type != VDIR) {
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
foffset_unlock(fp, off, 0);
|
||||
fdrop(fp, td);
|
||||
return (EINVAL);
|
||||
@ -521,7 +519,6 @@ getdents_common(struct thread *td, struct linux_getdents64_args *args,
|
||||
free(cookies, M_TEMP);
|
||||
|
||||
VOP_UNLOCK(vp, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
foffset_unlock(fp, off, 0);
|
||||
fdrop(fp, td);
|
||||
free(buf, M_TEMP);
|
||||
|
@ -247,7 +247,7 @@ linux_uselib(struct thread *td, struct linux_uselib_args *args)
|
||||
char *library;
|
||||
ssize_t aresid;
|
||||
int error;
|
||||
int locked, vfslocked;
|
||||
int locked;
|
||||
|
||||
LCONVPATHEXIST(td, args->library, &library);
|
||||
|
||||
@ -257,11 +257,10 @@ linux_uselib(struct thread *td, struct linux_uselib_args *args)
|
||||
#endif
|
||||
|
||||
a_out = NULL;
|
||||
vfslocked = 0;
|
||||
locked = 0;
|
||||
vp = NULL;
|
||||
|
||||
NDINIT(&ni, LOOKUP, ISOPEN | FOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1,
|
||||
NDINIT(&ni, LOOKUP, ISOPEN | FOLLOW | LOCKLEAF | AUDITVNODE1,
|
||||
UIO_SYSSPACE, library, td);
|
||||
error = namei(&ni);
|
||||
LFREEPATH(library);
|
||||
@ -269,7 +268,6 @@ linux_uselib(struct thread *td, struct linux_uselib_args *args)
|
||||
goto cleanup;
|
||||
|
||||
vp = ni.ni_vp;
|
||||
vfslocked = NDHASGIANT(&ni);
|
||||
NDFREE(&ni, NDF_ONLY_PNBUF);
|
||||
|
||||
/*
|
||||
@ -393,7 +391,6 @@ linux_uselib(struct thread *td, struct linux_uselib_args *args)
|
||||
*/
|
||||
locked = 0;
|
||||
VOP_UNLOCK(vp, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
|
||||
/*
|
||||
* Check if file_offset page aligned. Currently we cannot handle
|
||||
@ -463,10 +460,8 @@ linux_uselib(struct thread *td, struct linux_uselib_args *args)
|
||||
|
||||
cleanup:
|
||||
/* Unlock vnode if needed */
|
||||
if (locked) {
|
||||
if (locked)
|
||||
VOP_UNLOCK(vp, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
}
|
||||
|
||||
/* Release the temporary mapping. */
|
||||
if (a_out)
|
||||
|
@ -2741,7 +2741,7 @@ NdisOpenFile(status, filehandle, filelength, filename, highestaddr)
|
||||
char *afilename = NULL;
|
||||
struct thread *td = curthread;
|
||||
struct nameidata nd;
|
||||
int flags, error, vfslocked;
|
||||
int flags, error;
|
||||
struct vattr vat;
|
||||
struct vattr *vap = &vat;
|
||||
ndis_fh *fh;
|
||||
@ -2821,7 +2821,7 @@ NdisOpenFile(status, filehandle, filelength, filename, highestaddr)
|
||||
if (td->td_proc->p_fd->fd_cdir == NULL)
|
||||
td->td_proc->p_fd->fd_cdir = rootvnode;
|
||||
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, path, td);
|
||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, td);
|
||||
|
||||
flags = FREAD;
|
||||
error = vn_open(&nd, &flags, 0, NULL);
|
||||
@ -2833,7 +2833,6 @@ NdisOpenFile(status, filehandle, filelength, filename, highestaddr)
|
||||
free(afilename, M_DEVBUF);
|
||||
return;
|
||||
}
|
||||
vfslocked = NDHASGIANT(&nd);
|
||||
|
||||
ExFreePool(path);
|
||||
|
||||
@ -2842,7 +2841,6 @@ NdisOpenFile(status, filehandle, filelength, filename, highestaddr)
|
||||
/* Get the file size. */
|
||||
VOP_GETATTR(nd.ni_vp, vap, td->td_ucred);
|
||||
VOP_UNLOCK(nd.ni_vp, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
|
||||
fh->nf_vp = nd.ni_vp;
|
||||
fh->nf_map = NULL;
|
||||
@ -2862,7 +2860,7 @@ NdisMapFile(status, mappedbuffer, filehandle)
|
||||
struct thread *td = curthread;
|
||||
linker_file_t lf;
|
||||
caddr_t kldstart;
|
||||
int error, vfslocked;
|
||||
int error;
|
||||
ssize_t resid;
|
||||
struct vnode *vp;
|
||||
|
||||
@ -2903,10 +2901,8 @@ NdisMapFile(status, mappedbuffer, filehandle)
|
||||
}
|
||||
|
||||
vp = fh->nf_vp;
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
error = vn_rdwr(UIO_READ, vp, fh->nf_map, fh->nf_maplen, 0,
|
||||
UIO_SYSSPACE, 0, td->td_ucred, NOCRED, &resid, td);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
|
||||
if (error)
|
||||
*status = NDIS_STATUS_FAILURE;
|
||||
@ -2937,7 +2933,6 @@ NdisCloseFile(filehandle)
|
||||
{
|
||||
struct thread *td = curthread;
|
||||
ndis_fh *fh;
|
||||
int vfslocked;
|
||||
struct vnode *vp;
|
||||
|
||||
if (filehandle == NULL)
|
||||
@ -2955,9 +2950,7 @@ NdisCloseFile(filehandle)
|
||||
|
||||
if (fh->nf_type == NDIS_FH_TYPE_VFS) {
|
||||
vp = fh->nf_vp;
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
vn_close(vp, FREAD, td->td_ucred, td);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
}
|
||||
|
||||
fh->nf_vp = NULL;
|
||||
|
@ -241,7 +241,7 @@ svr4_sys_getdents64(td, uap)
|
||||
struct iovec aiov;
|
||||
off_t off;
|
||||
struct svr4_dirent64 svr4_dirent;
|
||||
int buflen, error, eofflag, nbytes, justone, vfslocked;
|
||||
int buflen, error, eofflag, nbytes, justone;
|
||||
u_long *cookies = NULL, *cookiep;
|
||||
int ncookies;
|
||||
|
||||
@ -258,9 +258,7 @@ svr4_sys_getdents64(td, uap)
|
||||
}
|
||||
|
||||
vp = fp->f_vnode;
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
if (vp->v_type != VDIR) {
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
fdrop(fp, td);
|
||||
return (EINVAL);
|
||||
}
|
||||
@ -397,7 +395,6 @@ svr4_sys_getdents64(td, uap)
|
||||
td->td_retval[0] = nbytes - resid;
|
||||
out:
|
||||
VOP_UNLOCK(vp, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
fdrop(fp, td);
|
||||
if (cookies)
|
||||
free(cookies, M_TEMP);
|
||||
@ -422,7 +419,7 @@ svr4_sys_getdents(td, uap)
|
||||
struct iovec aiov;
|
||||
struct svr4_dirent idb;
|
||||
off_t off; /* true file offset */
|
||||
int buflen, error, eofflag, vfslocked;
|
||||
int buflen, error, eofflag;
|
||||
u_long *cookiebuf = NULL, *cookie;
|
||||
int ncookies = 0, *retval = td->td_retval;
|
||||
|
||||
@ -439,9 +436,7 @@ svr4_sys_getdents(td, uap)
|
||||
}
|
||||
|
||||
vp = fp->f_vnode;
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
if (vp->v_type != VDIR) {
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
fdrop(fp, td);
|
||||
return (EINVAL);
|
||||
}
|
||||
@ -534,7 +529,6 @@ svr4_sys_getdents(td, uap)
|
||||
*retval = uap->nbytes - resid;
|
||||
out:
|
||||
VOP_UNLOCK(vp, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
fdrop(fp, td);
|
||||
if (cookiebuf)
|
||||
free(cookiebuf, M_TEMP);
|
||||
@ -614,7 +608,7 @@ svr4_sys_fchroot(td, uap)
|
||||
struct filedesc *fdp = td->td_proc->p_fd;
|
||||
struct vnode *vp;
|
||||
struct file *fp;
|
||||
int error, vfslocked;
|
||||
int error;
|
||||
|
||||
if ((error = priv_check(td, PRIV_VFS_FCHROOT)) != 0)
|
||||
return error;
|
||||
@ -624,7 +618,6 @@ svr4_sys_fchroot(td, uap)
|
||||
vp = fp->f_vnode;
|
||||
VREF(vp);
|
||||
fdrop(fp, td);
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
error = change_dir(vp, td);
|
||||
if (error)
|
||||
@ -637,11 +630,9 @@ svr4_sys_fchroot(td, uap)
|
||||
VOP_UNLOCK(vp, 0);
|
||||
error = change_root(vp, td);
|
||||
vrele(vp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
fail:
|
||||
vput(vp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -1652,13 +1643,12 @@ svr4_sys_resolvepath(td, uap)
|
||||
int error, *retval = td->td_retval;
|
||||
unsigned int ncopy;
|
||||
|
||||
NDINIT(&nd, LOOKUP, NOFOLLOW | SAVENAME | MPSAFE, UIO_USERSPACE,
|
||||
NDINIT(&nd, LOOKUP, NOFOLLOW | SAVENAME, UIO_USERSPACE,
|
||||
uap->path, td);
|
||||
|
||||
if ((error = namei(&nd)) != 0)
|
||||
return (error);
|
||||
NDFREE(&nd, NDF_NO_FREE_PNBUF);
|
||||
VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
|
||||
|
||||
ncopy = min(uap->bufsiz, strlen(nd.ni_cnd.cn_pnbuf) + 1);
|
||||
if ((error = copyout(nd.ni_cnd.cn_pnbuf, uap->buf, ncopy)) != 0)
|
||||
|
@ -1088,9 +1088,6 @@ options REISERFS
|
||||
# unsuitable for inclusion on machines with untrusted local users.
|
||||
options VFS_AIO
|
||||
|
||||
# Enable mounting of non-MPSAFE filesystems.
|
||||
options VFS_ALLOW_NONMPSAFE
|
||||
|
||||
# Cryptographically secure random number generator; /dev/random
|
||||
device random
|
||||
|
||||
|
@ -188,7 +188,6 @@ SW_WATCHDOG opt_watchdog.h
|
||||
TURNSTILE_PROFILING
|
||||
UMTX_PROFILING
|
||||
VFS_AIO
|
||||
VFS_ALLOW_NONMPSAFE
|
||||
VERBOSE_SYSINIT opt_global.h
|
||||
WLCACHE opt_wavelan.h
|
||||
WLDEBUG opt_wavelan.h
|
||||
|
@ -1632,7 +1632,6 @@ pmc_log_kernel_mappings(struct pmc *pm)
|
||||
static void
|
||||
pmc_log_process_mappings(struct pmc_owner *po, struct proc *p)
|
||||
{
|
||||
int locked;
|
||||
vm_map_t map;
|
||||
struct vnode *vp;
|
||||
struct vmspace *vm;
|
||||
@ -1742,9 +1741,7 @@ pmc_log_process_mappings(struct pmc_owner *po, struct proc *p)
|
||||
pmc_getfilename(vp, &fullpath, &freepath);
|
||||
last_vp = vp;
|
||||
|
||||
locked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
vrele(vp);
|
||||
VFS_UNLOCK_GIANT(locked);
|
||||
|
||||
vp = NULL;
|
||||
pmclog_process_map_in(po, p->p_pid, start_addr, fullpath);
|
||||
|
@ -512,7 +512,7 @@ mdstart_preload(struct md_s *sc, struct bio *bp)
|
||||
static int
|
||||
mdstart_vnode(struct md_s *sc, struct bio *bp)
|
||||
{
|
||||
int error, vfslocked;
|
||||
int error;
|
||||
struct uio auio;
|
||||
struct iovec aiov;
|
||||
struct mount *mp;
|
||||
@ -542,13 +542,11 @@ mdstart_vnode(struct md_s *sc, struct bio *bp)
|
||||
*/
|
||||
|
||||
if (bp->bio_cmd == BIO_FLUSH) {
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
(void) vn_start_write(vp, &mp, V_WAIT);
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
error = VOP_FSYNC(vp, MNT_WAIT, td);
|
||||
VOP_UNLOCK(vp, 0);
|
||||
vn_finished_write(mp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -570,7 +568,6 @@ mdstart_vnode(struct md_s *sc, struct bio *bp)
|
||||
auio.uio_rw = UIO_WRITE;
|
||||
auio.uio_td = td;
|
||||
end = bp->bio_offset + bp->bio_length;
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
(void) vn_start_write(vp, &mp, V_WAIT);
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
error = 0;
|
||||
@ -588,7 +585,6 @@ mdstart_vnode(struct md_s *sc, struct bio *bp)
|
||||
VOP_UNLOCK(vp, 0);
|
||||
vn_finished_write(mp);
|
||||
bp->bio_resid = end - auio.uio_offset;
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -610,7 +606,6 @@ mdstart_vnode(struct md_s *sc, struct bio *bp)
|
||||
* When reading set IO_DIRECT to try to avoid double-caching
|
||||
* the data. When writing IO_DIRECT is not optimal.
|
||||
*/
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
if (bp->bio_cmd == BIO_READ) {
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
error = VOP_READ(vp, &auio, IO_DIRECT, sc->cred);
|
||||
@ -623,7 +618,6 @@ mdstart_vnode(struct md_s *sc, struct bio *bp)
|
||||
VOP_UNLOCK(vp, 0);
|
||||
vn_finished_write(mp);
|
||||
}
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
bp->bio_resid = auio.uio_resid;
|
||||
return (error);
|
||||
}
|
||||
@ -957,7 +951,7 @@ mdcreate_vnode(struct md_s *sc, struct md_ioctl *mdio, struct thread *td)
|
||||
struct vattr vattr;
|
||||
struct nameidata nd;
|
||||
char *fname;
|
||||
int error, flags, vfslocked;
|
||||
int error, flags;
|
||||
|
||||
/*
|
||||
* Kernel-originated requests must have the filename appended
|
||||
@ -976,11 +970,10 @@ mdcreate_vnode(struct md_s *sc, struct md_ioctl *mdio, struct thread *td)
|
||||
* set the FWRITE mask before trying to open the backing store.
|
||||
*/
|
||||
flags = FREAD | ((mdio->md_options & MD_READONLY) ? 0 : FWRITE);
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, sc->file, td);
|
||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, sc->file, td);
|
||||
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 = EINVAL;
|
||||
@ -1016,19 +1009,16 @@ mdcreate_vnode(struct md_s *sc, struct md_ioctl *mdio, struct thread *td)
|
||||
nd.ni_vp->v_vflag &= ~VV_MD;
|
||||
goto bad;
|
||||
}
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (0);
|
||||
bad:
|
||||
VOP_UNLOCK(nd.ni_vp, 0);
|
||||
(void)vn_close(nd.ni_vp, flags, td->td_ucred, td);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
}
|
||||
|
||||
static int
|
||||
mddestroy(struct md_s *sc, struct thread *td)
|
||||
{
|
||||
int vfslocked;
|
||||
|
||||
if (sc->gp) {
|
||||
sc->gp->softc = NULL;
|
||||
@ -1050,13 +1040,11 @@ mddestroy(struct md_s *sc, struct thread *td)
|
||||
mtx_unlock(&sc->queue_mtx);
|
||||
mtx_destroy(&sc->queue_mtx);
|
||||
if (sc->vnode != NULL) {
|
||||
vfslocked = VFS_LOCK_GIANT(sc->vnode->v_mount);
|
||||
vn_lock(sc->vnode, LK_EXCLUSIVE | LK_RETRY);
|
||||
sc->vnode->v_vflag &= ~VV_MD;
|
||||
VOP_UNLOCK(sc->vnode, 0);
|
||||
(void)vn_close(sc->vnode, sc->flags & MD_READONLY ?
|
||||
FREAD : (FREAD|FWRITE), sc->cred, td);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
}
|
||||
if (sc->cred != NULL)
|
||||
crfree(sc->cred);
|
||||
|
@ -142,9 +142,9 @@ static int
|
||||
swap_file_open(struct chip_swap *swap, const char *swap_file)
|
||||
{
|
||||
struct nameidata nd;
|
||||
int vfslocked, flags, error;
|
||||
int flags, error;
|
||||
|
||||
NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_SYSSPACE, swap_file,
|
||||
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, swap_file,
|
||||
curthread);
|
||||
|
||||
flags = FWRITE | FREAD | O_NOFOLLOW | O_CREAT | O_TRUNC;
|
||||
@ -157,12 +157,10 @@ swap_file_open(struct chip_swap *swap, const char *swap_file)
|
||||
}
|
||||
|
||||
swap->swap_cred = crhold(curthread->td_ucred);
|
||||
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);
|
||||
|
||||
swap->swap_vp = nd.ni_vp;
|
||||
|
||||
@ -192,7 +190,6 @@ swap_file_write(struct chip_swap *swap, struct block_state *blk_state)
|
||||
struct vnode *vp;
|
||||
struct uio auio;
|
||||
struct iovec aiov;
|
||||
int vfslocked;
|
||||
|
||||
if (swap == NULL || blk_state == NULL)
|
||||
return (-1);
|
||||
@ -222,13 +219,11 @@ swap_file_write(struct chip_swap *swap, struct block_state *blk_state)
|
||||
auio.uio_resid = swap->blk_size;
|
||||
auio.uio_td = td;
|
||||
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
vn_start_write(vp, &mp, V_WAIT);
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
VOP_WRITE(vp, &auio, IO_UNIT, swap->swap_cred);
|
||||
VOP_UNLOCK(vp, 0);
|
||||
vn_finished_write(mp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
|
||||
return (0);
|
||||
}
|
||||
@ -241,7 +236,6 @@ swap_file_read(struct chip_swap *swap, struct block_state *blk_state)
|
||||
struct vnode *vp;
|
||||
struct uio auio;
|
||||
struct iovec aiov;
|
||||
int vfslocked;
|
||||
|
||||
if (swap == NULL || blk_state == NULL)
|
||||
return (-1);
|
||||
@ -267,11 +261,9 @@ swap_file_read(struct chip_swap *swap, struct block_state *blk_state)
|
||||
auio.uio_resid = swap->blk_size;
|
||||
auio.uio_td = td;
|
||||
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
VOP_READ(vp, &auio, 0, swap->swap_cred);
|
||||
VOP_UNLOCK(vp, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
@ -2250,7 +2250,6 @@ xbb_dispatch_file(struct xbb_softc *xbb, struct xbb_xen_reqlist *reqlist,
|
||||
void **p_vaddr;
|
||||
int saved_uio_iovcnt;
|
||||
#endif /* XBB_USE_BOUNCE_BUFFERS */
|
||||
int vfs_is_locked;
|
||||
int error;
|
||||
|
||||
file_data = &xbb->backend.file;
|
||||
@ -2271,8 +2270,6 @@ xbb_dispatch_file(struct xbb_softc *xbb, struct xbb_xen_reqlist *reqlist,
|
||||
SDT_PROBE1(xbb, kernel, xbb_dispatch_file, flush,
|
||||
device_get_unit(xbb->dev));
|
||||
|
||||
vfs_is_locked = VFS_LOCK_GIANT(xbb->vn->v_mount);
|
||||
|
||||
(void) vn_start_write(xbb->vn, &mountpoint, V_WAIT);
|
||||
|
||||
vn_lock(xbb->vn, LK_EXCLUSIVE | LK_RETRY);
|
||||
@ -2281,8 +2278,6 @@ xbb_dispatch_file(struct xbb_softc *xbb, struct xbb_xen_reqlist *reqlist,
|
||||
|
||||
vn_finished_write(mountpoint);
|
||||
|
||||
VFS_UNLOCK_GIANT(vfs_is_locked);
|
||||
|
||||
goto bailout_send_response;
|
||||
/* NOTREACHED */
|
||||
}
|
||||
@ -2366,7 +2361,6 @@ xbb_dispatch_file(struct xbb_softc *xbb, struct xbb_xen_reqlist *reqlist,
|
||||
}
|
||||
#endif /* XBB_USE_BOUNCE_BUFFERS */
|
||||
|
||||
vfs_is_locked = VFS_LOCK_GIANT(xbb->vn->v_mount);
|
||||
switch (operation) {
|
||||
case BIO_READ:
|
||||
|
||||
@ -2442,7 +2436,6 @@ xbb_dispatch_file(struct xbb_softc *xbb, struct xbb_xen_reqlist *reqlist,
|
||||
panic("invalid operation %d", operation);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
VFS_UNLOCK_GIANT(vfs_is_locked);
|
||||
|
||||
#ifdef XBB_USE_BOUNCE_BUFFERS
|
||||
/* We only need to copy here for read operations */
|
||||
@ -2489,7 +2482,6 @@ xbb_close_backend(struct xbb_softc *xbb)
|
||||
DPRINTF("closing dev=%s\n", xbb->dev_name);
|
||||
if (xbb->vn) {
|
||||
int flags = FREAD;
|
||||
int vfs_is_locked = 0;
|
||||
|
||||
if ((xbb->flags & XBBF_READ_ONLY) == 0)
|
||||
flags |= FWRITE;
|
||||
@ -2504,7 +2496,6 @@ xbb_close_backend(struct xbb_softc *xbb)
|
||||
}
|
||||
break;
|
||||
case XBB_TYPE_FILE:
|
||||
vfs_is_locked = VFS_LOCK_GIANT(xbb->vn->v_mount);
|
||||
break;
|
||||
case XBB_TYPE_NONE:
|
||||
default:
|
||||
@ -2519,7 +2510,6 @@ xbb_close_backend(struct xbb_softc *xbb)
|
||||
case XBB_TYPE_DISK:
|
||||
break;
|
||||
case XBB_TYPE_FILE:
|
||||
VFS_UNLOCK_GIANT(vfs_is_locked);
|
||||
if (xbb->backend.file.cred != NULL) {
|
||||
crfree(xbb->backend.file.cred);
|
||||
xbb->backend.file.cred = NULL;
|
||||
@ -2684,7 +2674,6 @@ xbb_open_backend(struct xbb_softc *xbb)
|
||||
struct nameidata nd;
|
||||
int flags;
|
||||
int error;
|
||||
int vfs_is_locked;
|
||||
|
||||
flags = FREAD;
|
||||
error = 0;
|
||||
@ -2744,8 +2733,6 @@ xbb_open_backend(struct xbb_softc *xbb)
|
||||
return (error);
|
||||
}
|
||||
|
||||
vfs_is_locked = NDHASGIANT(&nd);
|
||||
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
|
||||
xbb->vn = nd.ni_vp;
|
||||
@ -2761,7 +2748,6 @@ xbb_open_backend(struct xbb_softc *xbb)
|
||||
"or file", xbb->dev_name);
|
||||
}
|
||||
VOP_UNLOCK(xbb->vn, 0);
|
||||
VFS_UNLOCK_GIANT(vfs_is_locked);
|
||||
|
||||
if (error != 0) {
|
||||
xbb_close_backend(xbb);
|
||||
|
@ -211,7 +211,7 @@ nfsrv_lookupfilename(struct nameidata *ndp, char *fname, NFSPROC_T *p)
|
||||
{
|
||||
int error;
|
||||
|
||||
NDINIT(ndp, LOOKUP, FOLLOW | LOCKLEAF | MPSAFE, UIO_USERSPACE, fname,
|
||||
NDINIT(ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, fname,
|
||||
p);
|
||||
error = namei(ndp);
|
||||
if (!error) {
|
||||
|
@ -2060,8 +2060,7 @@ nfsrvd_readdirplus(struct nfsrv_descript *nd, int isdgram,
|
||||
cn.cn_nameptr = dp->d_name;
|
||||
cn.cn_namelen = nlen;
|
||||
cn.cn_flags = ISLASTCN |
|
||||
NOFOLLOW | LOCKLEAF |
|
||||
MPSAFE;
|
||||
NOFOLLOW | LOCKLEAF;
|
||||
if (nlen == 2 &&
|
||||
dp->d_name[0] == '.' &&
|
||||
dp->d_name[1] == '.')
|
||||
@ -2647,10 +2646,7 @@ nfsvno_fhtovp(struct mount *mp, fhandle_t *fhp, struct sockaddr *nam,
|
||||
|
||||
*credp = NULL;
|
||||
exp->nes_numsecflavor = 0;
|
||||
if (VFS_NEEDSGIANT(mp))
|
||||
error = ESTALE;
|
||||
else
|
||||
error = VFS_FHTOVP(mp, &fhp->fh_fid, lktype, vpp);
|
||||
error = VFS_FHTOVP(mp, &fhp->fh_fid, lktype, vpp);
|
||||
if (error != 0)
|
||||
/* Make sure the server replies ESTALE to the client. */
|
||||
error = ESTALE;
|
||||
@ -2825,7 +2821,7 @@ nfsrv_v4rootexport(void *argp, struct ucred *cred, struct thread *p)
|
||||
/*
|
||||
* If fspec != NULL, this is the v4root path.
|
||||
*/
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_USERSPACE,
|
||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE,
|
||||
nfsexargp->fspec, p);
|
||||
if ((error = namei(&nd)) != 0)
|
||||
goto out;
|
||||
|
@ -84,7 +84,7 @@ procfs_doprocmap(PFS_FILL_ARGS)
|
||||
struct vnode *vp;
|
||||
char *fullpath, *freepath;
|
||||
struct ucred *cred;
|
||||
int error, vfslocked;
|
||||
int error;
|
||||
unsigned int last_timestamp;
|
||||
#ifdef COMPAT_FREEBSD32
|
||||
int wrap32 = 0;
|
||||
@ -189,9 +189,7 @@ procfs_doprocmap(PFS_FILL_ARGS)
|
||||
VM_OBJECT_UNLOCK(obj);
|
||||
if (vp != NULL) {
|
||||
vn_fullpath(td, vp, &fullpath, &freepath);
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
vrele(vp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
}
|
||||
} else {
|
||||
type = "none";
|
||||
|
@ -331,7 +331,6 @@ unionfs_nodeget(struct mount *mp, struct vnode *uppervp,
|
||||
void
|
||||
unionfs_noderem(struct vnode *vp, struct thread *td)
|
||||
{
|
||||
int vfslocked;
|
||||
int count;
|
||||
struct unionfs_node *unp, *unp_t1, *unp_t2;
|
||||
struct unionfs_node_hashhead *hd;
|
||||
@ -366,20 +365,12 @@ unionfs_noderem(struct vnode *vp, struct thread *td)
|
||||
if (lockmgr(vp->v_vnlock, LK_EXCLUSIVE, VI_MTX(vp)) != 0)
|
||||
panic("the lock for deletion is unacquirable.");
|
||||
|
||||
if (lvp != NULLVP) {
|
||||
vfslocked = VFS_LOCK_GIANT(lvp->v_mount);
|
||||
if (lvp != NULLVP)
|
||||
vrele(lvp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
}
|
||||
if (uvp != NULLVP) {
|
||||
vfslocked = VFS_LOCK_GIANT(uvp->v_mount);
|
||||
if (uvp != NULLVP)
|
||||
vrele(uvp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
}
|
||||
if (dvp != NULLVP) {
|
||||
vfslocked = VFS_LOCK_GIANT(dvp->v_mount);
|
||||
vrele(dvp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
unp->un_dvp = NULLVP;
|
||||
}
|
||||
if (unp->un_path != NULL) {
|
||||
|
@ -35,7 +35,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/mount.h> /* XXX Temporary for VFS_LOCK_GIANT */
|
||||
#include <sys/mount.h>
|
||||
|
||||
#include <geom/geom.h>
|
||||
#include <geom/geom_vfs.h>
|
||||
@ -94,7 +94,7 @@ g_vfs_done(struct bio *bip)
|
||||
struct g_consumer *cp;
|
||||
struct g_vfs_softc *sc;
|
||||
struct buf *bp;
|
||||
int vfslocked, destroy;
|
||||
int destroy;
|
||||
struct mount *mp;
|
||||
struct vnode *vp;
|
||||
struct cdev *cdevp;
|
||||
@ -158,9 +158,7 @@ g_vfs_done(struct bio *bip)
|
||||
if (destroy)
|
||||
g_post_event(g_vfs_destroy, cp, M_WAITOK, NULL);
|
||||
|
||||
vfslocked = VFS_LOCK_GIANT(((struct mount *)NULL));
|
||||
bufdone(bp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
}
|
||||
|
||||
void
|
||||
@ -169,7 +167,6 @@ g_vfs_strategy(struct bufobj *bo, struct buf *bp)
|
||||
struct g_vfs_softc *sc;
|
||||
struct g_consumer *cp;
|
||||
struct bio *bip;
|
||||
int vfslocked;
|
||||
|
||||
cp = bo->bo_private;
|
||||
sc = cp->geom->softc;
|
||||
@ -182,9 +179,7 @@ g_vfs_strategy(struct bufobj *bo, struct buf *bp)
|
||||
mtx_unlock(&sc->sc_mtx);
|
||||
bp->b_error = ENXIO;
|
||||
bp->b_ioflags |= BIO_ERROR;
|
||||
vfslocked = VFS_LOCK_GIANT(((struct mount *)NULL));
|
||||
bufdone(bp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return;
|
||||
}
|
||||
sc->sc_active++;
|
||||
@ -234,7 +229,6 @@ g_vfs_open(struct vnode *vp, struct g_consumer **cpp, const char *fsname, int wr
|
||||
struct g_consumer *cp;
|
||||
struct g_vfs_softc *sc;
|
||||
struct bufobj *bo;
|
||||
int vfslocked;
|
||||
int error;
|
||||
|
||||
g_topology_assert();
|
||||
@ -259,9 +253,7 @@ g_vfs_open(struct vnode *vp, struct g_consumer **cpp, const char *fsname, int wr
|
||||
g_wither_geom(gp, ENXIO);
|
||||
return (error);
|
||||
}
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
vnode_create_vobject(vp, pp->mediasize, curthread);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
*cpp = cp;
|
||||
cp->private = vp;
|
||||
bo->bo_ops = g_vfs_bufops;
|
||||
|
@ -2870,7 +2870,7 @@ g_journal_do_switch(struct g_class *classp)
|
||||
struct mount *mp;
|
||||
struct bintime bt;
|
||||
char *mountpoint;
|
||||
int error, save, vfslocked;
|
||||
int error, save;
|
||||
|
||||
DROP_GIANT();
|
||||
g_topology_lock();
|
||||
@ -2922,11 +2922,8 @@ g_journal_do_switch(struct g_class *classp)
|
||||
|
||||
mountpoint = mp->mnt_stat.f_mntonname;
|
||||
|
||||
vfslocked = VFS_LOCK_GIANT(mp);
|
||||
|
||||
error = vn_start_write(NULL, &mp, V_WAIT);
|
||||
if (error != 0) {
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
GJ_DEBUG(0, "vn_start_write(%s) failed (error=%d).",
|
||||
mountpoint, error);
|
||||
goto next;
|
||||
@ -2951,10 +2948,8 @@ g_journal_do_switch(struct g_class *classp)
|
||||
|
||||
vn_finished_write(mp);
|
||||
|
||||
if (error != 0) {
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
if (error != 0)
|
||||
goto next;
|
||||
}
|
||||
|
||||
/*
|
||||
* Send BIO_FLUSH before freezing the file system, so it can be
|
||||
@ -2966,7 +2961,6 @@ g_journal_do_switch(struct g_class *classp)
|
||||
|
||||
GJ_TIMER_START(1, &bt);
|
||||
error = vfs_write_suspend(mp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
GJ_TIMER_STOP(1, &bt, "Suspend time of %s", mountpoint);
|
||||
if (error != 0) {
|
||||
GJ_DEBUG(0, "Cannot suspend file system %s (error=%d).",
|
||||
|
@ -331,7 +331,7 @@ ibcs2_getdents(td, uap)
|
||||
struct iovec aiov;
|
||||
struct ibcs2_dirent idb;
|
||||
off_t off; /* true file offset */
|
||||
int buflen, error, eofflag, vfslocked;
|
||||
int buflen, error, eofflag;
|
||||
u_long *cookies = NULL, *cookiep;
|
||||
int ncookies;
|
||||
#define BSD_DIRENT(cp) ((struct dirent *)(cp))
|
||||
@ -345,9 +345,7 @@ ibcs2_getdents(td, uap)
|
||||
return (EBADF);
|
||||
}
|
||||
vp = fp->f_vnode;
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
if (vp->v_type != VDIR) { /* XXX vnode readdir op should do this */
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
fdrop(fp, td);
|
||||
return (EINVAL);
|
||||
}
|
||||
@ -464,7 +462,6 @@ ibcs2_getdents(td, uap)
|
||||
td->td_retval[0] = uap->nbytes - resid;
|
||||
out:
|
||||
VOP_UNLOCK(vp, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
fdrop(fp, td);
|
||||
if (cookies)
|
||||
free(cookies, M_TEMP);
|
||||
@ -490,7 +487,7 @@ ibcs2_read(td, uap)
|
||||
char name[14];
|
||||
} idb;
|
||||
off_t off; /* true file offset */
|
||||
int buflen, error, eofflag, size, vfslocked;
|
||||
int buflen, error, eofflag, size;
|
||||
u_long *cookies = NULL, *cookiep;
|
||||
int ncookies;
|
||||
|
||||
@ -506,9 +503,7 @@ ibcs2_read(td, uap)
|
||||
return (EBADF);
|
||||
}
|
||||
vp = fp->f_vnode;
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
if (vp->v_type != VDIR) {
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
fdrop(fp, td);
|
||||
return sys_read(td, (struct read_args *)uap);
|
||||
}
|
||||
@ -631,7 +626,6 @@ ibcs2_read(td, uap)
|
||||
td->td_retval[0] = uap->nbytes - resid;
|
||||
out:
|
||||
VOP_UNLOCK(vp, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
fdrop(fp, td);
|
||||
if (cookies)
|
||||
free(cookies, M_TEMP);
|
||||
|
@ -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 @@ __elfN(load_file)(struct proc *p, const char *file, u_long *addr,
|
||||
if (nd->ni_vp)
|
||||
vput(nd->ni_vp);
|
||||
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
free(tempdata, M_TEMP);
|
||||
|
||||
return (error);
|
||||
|
@ -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)) {
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
|
||||
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)
|
||||
|
@ -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 @@ do_execve(td, args, mac_p)
|
||||
if (error)
|
||||
goto exec_fail;
|
||||
|
||||
vfslocked = NDHASGIANT(&nd);
|
||||
binvp = nd.ni_vp;
|
||||
imgp->vp = binvp;
|
||||
} else {
|
||||
@ -449,7 +446,6 @@ do_execve(td, args, mac_p)
|
||||
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 @@ do_execve(td, args, mac_p)
|
||||
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 @@ do_execve(td, args, mac_p)
|
||||
/*
|
||||
* 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 @@ do_execve(td, args, mac_p)
|
||||
mac_execve_exit(imgp);
|
||||
mac_execve_interpreter_exit(interpvplabel);
|
||||
#endif
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
exec_free_args(args);
|
||||
|
||||
if (error && imgp->vmspace_destroyed) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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 @@ linker_hints_lookup(const char *path, int pathlen, const char *modname,
|
||||
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
|
||||
|
@ -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;
|
||||
|
@ -3123,11 +3123,10 @@ expand_name(const char *name, uid_t uid, pid_t pid, struct thread *td,
|
||||
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 @@ expand_name(const char *name, uid_t uid, pid_t pid, struct thread *td,
|
||||
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 @@ coredump(struct thread *td)
|
||||
free(name, M_TEMP);
|
||||
return (error);
|
||||
}
|
||||
vfslocked = NDHASGIANT(&nd);
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
vp = nd.ni_vp;
|
||||
|
||||
@ -3270,7 +3265,6 @@ coredump(struct thread *td)
|
||||
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 @@ coredump(struct thread *td)
|
||||
audit_proc_coredump(td, name, error);
|
||||
#endif
|
||||
free(name, M_TEMP);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -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 @@ 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 != 0 && lf != NULL)
|
||||
linker_file_unload(lf, LINKER_UNLOAD_FORCE);
|
||||
if (shdr != NULL)
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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 @@ kern_sendfile(struct thread *td, struct sendfile_args *uap,
|
||||
/*
|
||||
* 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 @@ kern_sendfile(struct thread *td, struct sendfile_args *uap,
|
||||
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 @@ kern_sendfile(struct thread *td, struct sendfile_args *uap,
|
||||
}
|
||||
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)
|
||||
|
@ -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 @@ uipc_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
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 @@ uipc_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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 @@ sys_extattrctl(td, uap)
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
@ -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) {
|
||||
/*
|
||||
|
@ -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 @@ lookup(struct nameidata *ndp)
|
||||
(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 @@ lookup(struct nameidata *ndp)
|
||||
}
|
||||
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 @@ lookup(struct nameidata *ndp)
|
||||
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 @@ lookup(struct nameidata *ndp)
|
||||
(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 @@ lookup(struct nameidata *ndp)
|
||||
}
|
||||
|
||||
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 @@ lookup(struct nameidata *ndp)
|
||||
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 @@ lookup(struct nameidata *ndp)
|
||||
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 @@ lookup(struct nameidata *ndp)
|
||||
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 @@ lookup(struct nameidata *ndp)
|
||||
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 @@ lookup(struct nameidata *ndp)
|
||||
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. */
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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 @@ vn_open_cred(struct nameidata *ndp, int *flagp, int cmode, u_int vn_open_flags,
|
||||
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 @@ vn_open_cred(struct nameidata *ndp, int *flagp, int cmode, u_int vn_open_flags,
|
||||
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 @@ vn_open_cred(struct nameidata *ndp, int *flagp, int cmode, u_int vn_open_flags,
|
||||
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 @@ vn_open_cred(struct nameidata *ndp, int *flagp, int cmode, u_int vn_open_flags,
|
||||
} 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 @@ vn_truncate(struct file *fp, off_t length, struct ucred *active_cred,
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,7 @@ int nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
struct mbuf **mrq);
|
||||
int nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
struct mbuf **mrq);
|
||||
int nfsrv_fhtovp(fhandle_t *, int, struct vnode **, int *,
|
||||
int nfsrv_fhtovp(fhandle_t *, int, struct vnode **,
|
||||
struct nfsrv_descript *, struct nfssvc_sock *, struct sockaddr *,
|
||||
int *);
|
||||
int nfsrv_setpublicfs(struct mount *, struct netexport *,
|
||||
|
@ -161,32 +161,6 @@ ndclear(struct nameidata *nd)
|
||||
nd->ni_strictrelative = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Takes two vfslocked integers and returns with at most one
|
||||
* reference to giant. The return value indicates whether giant
|
||||
* is held by either lock. This simplifies nfsrv ops by allowing
|
||||
* them to track only one vfslocked var.
|
||||
*/
|
||||
static __inline int
|
||||
nfsrv_lockedpair(int vfs1, int vfs2)
|
||||
{
|
||||
|
||||
if (vfs1 && vfs2)
|
||||
VFS_UNLOCK_GIANT(vfs2);
|
||||
|
||||
return (vfs1 | vfs2);
|
||||
}
|
||||
|
||||
static __inline int
|
||||
nfsrv_lockedpair_nd(int vfs1, struct nameidata *nd)
|
||||
{
|
||||
int vfs2;
|
||||
|
||||
vfs2 = NDHASGIANT(nd);
|
||||
|
||||
return nfsrv_lockedpair(vfs1, vfs2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Heuristic to detect sequential operation.
|
||||
*/
|
||||
@ -265,16 +239,14 @@ nfsrv3_access(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
struct vattr vattr, *vap = &vattr;
|
||||
u_long testmode, nfsmode;
|
||||
int v3 = (nfsd->nd_flag & ND_NFSV3);
|
||||
int vfslocked;
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
if (!v3)
|
||||
panic("nfsrv3_access: v3 proc called on a v2 connection");
|
||||
vfslocked = 0;
|
||||
fhp = &nfh.fh_generic;
|
||||
nfsm_srvmtofh(fhp);
|
||||
tl = nfsm_dissect_nonblock(u_int32_t *, NFSX_UNSIGNED);
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, &vfslocked, nfsd, slp, nam, &rdonly);
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly);
|
||||
if (error) {
|
||||
nfsm_reply(NFSX_UNSIGNED);
|
||||
nfsm_srvpostop_attr(1, NULL);
|
||||
@ -310,7 +282,6 @@ nfsrv3_access(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
nfsmout:
|
||||
if (vp)
|
||||
vput(vp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return(error);
|
||||
}
|
||||
|
||||
@ -334,13 +305,11 @@ nfsrv_getattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
caddr_t bpos;
|
||||
int error = 0, rdonly;
|
||||
struct mbuf *mb, *mreq;
|
||||
int vfslocked;
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
vfslocked = 0;
|
||||
fhp = &nfh.fh_generic;
|
||||
nfsm_srvmtofh(fhp);
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, &vfslocked, nfsd, slp, nam, &rdonly);
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly);
|
||||
if (error) {
|
||||
nfsm_reply(0);
|
||||
error = 0;
|
||||
@ -362,7 +331,6 @@ nfsrv_getattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
nfsmout:
|
||||
if (vp)
|
||||
vput(vp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return(error);
|
||||
}
|
||||
|
||||
@ -391,18 +359,14 @@ nfsrv_setattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
struct mbuf *mb, *mreq;
|
||||
struct timespec guard = { 0, 0 };
|
||||
struct mount *mp = NULL;
|
||||
int tvfslocked;
|
||||
int vfslocked;
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
vfslocked = 0;
|
||||
fhp = &nfh.fh_generic;
|
||||
nfsm_srvmtofh(fhp);
|
||||
if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) {
|
||||
error = ESTALE;
|
||||
goto out;
|
||||
}
|
||||
vfslocked = VFS_LOCK_GIANT(mp);
|
||||
(void) vn_start_write(NULL, &mp, V_WAIT);
|
||||
vfs_rel(mp); /* The write holds a ref. */
|
||||
VATTR_NULL(vap);
|
||||
@ -448,8 +412,7 @@ nfsrv_setattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
/*
|
||||
* Now that we have all the fields, lets do it.
|
||||
*/
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, &tvfslocked, nfsd, slp, nam, &rdonly);
|
||||
vfslocked = nfsrv_lockedpair(vfslocked, tvfslocked);
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly);
|
||||
if (error) {
|
||||
nfsm_reply(2 * NFSX_UNSIGNED);
|
||||
if (v3)
|
||||
@ -519,7 +482,6 @@ nfsrv_setattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
if (vp)
|
||||
vput(vp);
|
||||
vn_finished_write(mp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return(error);
|
||||
}
|
||||
|
||||
@ -544,12 +506,9 @@ nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
int v3 = (nfsd->nd_flag & ND_NFSV3), pubflag;
|
||||
struct mbuf *mb, *mreq;
|
||||
struct vattr va, dirattr, *vap = &va;
|
||||
int tvfslocked;
|
||||
int vfslocked;
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
ndclear(&nd);
|
||||
vfslocked = 0;
|
||||
|
||||
fhp = &nfh.fh_generic;
|
||||
nfsm_srvmtofh(fhp);
|
||||
@ -559,10 +518,9 @@ nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
|
||||
nd.ni_cnd.cn_cred = cred;
|
||||
nd.ni_cnd.cn_nameiop = LOOKUP;
|
||||
nd.ni_cnd.cn_flags = LOCKLEAF | SAVESTART | MPSAFE;
|
||||
nd.ni_cnd.cn_flags = LOCKLEAF | SAVESTART;
|
||||
error = nfs_namei(&nd, nfsd, fhp, len, slp, nam, &md, &dpos,
|
||||
&dirp, v3, &dirattr, &dirattr_ret, pubflag);
|
||||
vfslocked = NDHASGIANT(&nd);
|
||||
|
||||
/*
|
||||
* namei failure, only dirp to cleanup. Clear out garbarge from
|
||||
@ -609,14 +567,8 @@ nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
nfs_pub.np_index;
|
||||
ind.ni_startdir = nd.ni_vp;
|
||||
VREF(ind.ni_startdir);
|
||||
ind.ni_cnd.cn_flags &= ~GIANTHELD;
|
||||
tvfslocked = VFS_LOCK_GIANT(ind.ni_startdir->v_mount);
|
||||
if (tvfslocked)
|
||||
nd.ni_cnd.cn_flags |= GIANTHELD;
|
||||
error = lookup(&ind);
|
||||
ind.ni_dvp = NULL;
|
||||
vfslocked = nfsrv_lockedpair_nd(vfslocked, &ind);
|
||||
ind.ni_cnd.cn_flags &= ~GIANTHELD;
|
||||
|
||||
if (error == 0) {
|
||||
/*
|
||||
@ -703,7 +655,6 @@ nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
vrele(ndp->ni_startdir);
|
||||
}
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -731,10 +682,8 @@ nfsrv_readlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
nfsfh_t nfh;
|
||||
fhandle_t *fhp;
|
||||
struct uio io, *uiop = &io;
|
||||
int vfslocked;
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
vfslocked = 0;
|
||||
#ifndef nolint
|
||||
mp = NULL;
|
||||
#endif
|
||||
@ -770,7 +719,7 @@ nfsrv_readlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
uiop->uio_rw = UIO_READ;
|
||||
uiop->uio_segflg = UIO_SYSSPACE;
|
||||
uiop->uio_td = NULL;
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, &vfslocked, nfsd, slp, nam, &rdonly);
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly);
|
||||
if (error) {
|
||||
nfsm_reply(2 * NFSX_UNSIGNED);
|
||||
if (v3)
|
||||
@ -809,7 +758,6 @@ nfsrv_readlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
m_freem(mp3);
|
||||
if (vp)
|
||||
vput(vp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return(error);
|
||||
}
|
||||
|
||||
@ -843,11 +791,8 @@ nfsrv_read(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
struct nfsheur *nh;
|
||||
off_t off;
|
||||
int ioflag = 0;
|
||||
int vfslocked;
|
||||
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
vfslocked = 0;
|
||||
fhp = &nfh.fh_generic;
|
||||
nfsm_srvmtofh(fhp);
|
||||
if (v3) {
|
||||
@ -865,7 +810,7 @@ nfsrv_read(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
* as well.
|
||||
*/
|
||||
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, &vfslocked, nfsd, slp, nam, &rdonly);
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly);
|
||||
if (error) {
|
||||
vp = NULL;
|
||||
nfsm_reply(2 * NFSX_UNSIGNED);
|
||||
@ -1004,7 +949,6 @@ nfsrv_read(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
nfsmout:
|
||||
if (vp)
|
||||
vput(vp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return(error);
|
||||
}
|
||||
|
||||
@ -1040,11 +984,8 @@ nfsrv_write(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
struct uio io, *uiop = &io;
|
||||
off_t off;
|
||||
struct mount *mntp = NULL;
|
||||
int tvfslocked;
|
||||
int vfslocked;
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
vfslocked = 0;
|
||||
if (mrep == NULL) {
|
||||
*mrq = NULL;
|
||||
error = 0;
|
||||
@ -1056,7 +997,6 @@ nfsrv_write(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
error = ESTALE;
|
||||
goto ereply;
|
||||
}
|
||||
vfslocked = VFS_LOCK_GIANT(mntp);
|
||||
(void) vn_start_write(NULL, &mntp, V_WAIT);
|
||||
vfs_rel(mntp); /* The write holds a ref. */
|
||||
if (v3) {
|
||||
@ -1112,8 +1052,7 @@ nfsrv_write(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
error = 0;
|
||||
goto nfsmout;
|
||||
}
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, &tvfslocked, nfsd, slp, nam, &rdonly);
|
||||
vfslocked = nfsrv_lockedpair(vfslocked, tvfslocked);
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly);
|
||||
if (error) {
|
||||
vp = NULL;
|
||||
nfsm_reply(2 * NFSX_UNSIGNED);
|
||||
@ -1226,7 +1165,6 @@ nfsrv_write(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
if (vp)
|
||||
vput(vp);
|
||||
vn_finished_write(mntp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return(error);
|
||||
}
|
||||
|
||||
@ -1258,11 +1196,8 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
u_quad_t tempsize;
|
||||
struct timespec cverf;
|
||||
struct mount *mp = NULL;
|
||||
int tvfslocked;
|
||||
int vfslocked;
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
vfslocked = 0;
|
||||
#ifndef nolint
|
||||
rdev = 0;
|
||||
#endif
|
||||
@ -1274,14 +1209,13 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
error = ESTALE;
|
||||
goto ereply;
|
||||
}
|
||||
vfslocked = VFS_LOCK_GIANT(mp);
|
||||
(void) vn_start_write(NULL, &mp, V_WAIT);
|
||||
vfs_rel(mp); /* The write holds a ref. */
|
||||
nfsm_srvnamesiz(len);
|
||||
|
||||
nd.ni_cnd.cn_cred = cred;
|
||||
nd.ni_cnd.cn_nameiop = CREATE;
|
||||
nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | SAVESTART | MPSAFE;
|
||||
nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | SAVESTART;
|
||||
|
||||
/*
|
||||
* Call namei and do initial cleanup to get a few things
|
||||
@ -1294,7 +1228,6 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
*/
|
||||
error = nfs_namei(&nd, nfsd, fhp, len, slp, nam, &md, &dpos,
|
||||
&dirp, v3, &dirfor, &dirfor_ret, FALSE);
|
||||
vfslocked = nfsrv_lockedpair_nd(vfslocked, &nd);
|
||||
if (dirp && !v3) {
|
||||
vrele(dirp);
|
||||
dirp = NULL;
|
||||
@ -1430,13 +1363,8 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
nd.ni_cnd.cn_flags &= ~(LOCKPARENT);
|
||||
nd.ni_cnd.cn_thread = curthread;
|
||||
nd.ni_cnd.cn_cred = cred;
|
||||
tvfslocked = VFS_LOCK_GIANT(nd.ni_startdir->v_mount);
|
||||
if (tvfslocked)
|
||||
nd.ni_cnd.cn_flags |= GIANTHELD;
|
||||
error = lookup(&nd);
|
||||
nd.ni_dvp = NULL;
|
||||
vfslocked = nfsrv_lockedpair_nd(vfslocked, &nd);
|
||||
nd.ni_cnd.cn_flags &= ~GIANTHELD;
|
||||
if (error)
|
||||
goto ereply;
|
||||
|
||||
@ -1524,7 +1452,6 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
vrele(dirp);
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
vn_finished_write(mp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -1554,11 +1481,8 @@ nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
fhandle_t *fhp;
|
||||
struct mount *mp = NULL;
|
||||
int v3 = (nfsd->nd_flag & ND_NFSV3);
|
||||
int tvfslocked;
|
||||
int vfslocked;
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
vfslocked = 0;
|
||||
if (!v3)
|
||||
panic("nfsrv_mknod: v3 proc called on a v2 connection");
|
||||
ndclear(&nd);
|
||||
@ -1569,14 +1493,13 @@ nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
error = ESTALE;
|
||||
goto ereply;
|
||||
}
|
||||
vfslocked = VFS_LOCK_GIANT(mp);
|
||||
(void) vn_start_write(NULL, &mp, V_WAIT);
|
||||
vfs_rel(mp); /* The write holds a ref. */
|
||||
nfsm_srvnamesiz(len);
|
||||
|
||||
nd.ni_cnd.cn_cred = cred;
|
||||
nd.ni_cnd.cn_nameiop = CREATE;
|
||||
nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | SAVESTART | MPSAFE;
|
||||
nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | SAVESTART;
|
||||
|
||||
/*
|
||||
* Handle nfs_namei() call. If an error occurs, the nd structure
|
||||
@ -1586,7 +1509,6 @@ nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
|
||||
error = nfs_namei(&nd, nfsd, fhp, len, slp, nam, &md, &dpos,
|
||||
&dirp, v3, &dirfor, &dirfor_ret, FALSE);
|
||||
vfslocked = nfsrv_lockedpair_nd(vfslocked, &nd);
|
||||
if (error) {
|
||||
nfsm_reply(NFSX_WCCDATA(1));
|
||||
nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
|
||||
@ -1646,13 +1568,8 @@ nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
nd.ni_cnd.cn_flags &= ~(LOCKPARENT);
|
||||
nd.ni_cnd.cn_thread = td;
|
||||
nd.ni_cnd.cn_cred = td->td_ucred;
|
||||
tvfslocked = VFS_LOCK_GIANT(nd.ni_startdir->v_mount);
|
||||
if (tvfslocked)
|
||||
nd.ni_cnd.cn_flags |= GIANTHELD;
|
||||
error = lookup(&nd);
|
||||
nd.ni_dvp = NULL;
|
||||
vfslocked = nfsrv_lockedpair_nd(vfslocked, &nd);
|
||||
nd.ni_cnd.cn_flags &= ~GIANTHELD;
|
||||
|
||||
if (error)
|
||||
goto out;
|
||||
@ -1704,7 +1621,6 @@ nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
|
||||
}
|
||||
vn_finished_write(mp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (0);
|
||||
nfsmout:
|
||||
if (nd.ni_dvp) {
|
||||
@ -1721,7 +1637,6 @@ nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
vrele(nd.ni_startdir);
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
vn_finished_write(mp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -1746,11 +1661,9 @@ nfsrv_remove(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
nfsfh_t nfh;
|
||||
fhandle_t *fhp;
|
||||
struct mount *mp = NULL;
|
||||
int vfslocked;
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
ndclear(&nd);
|
||||
vfslocked = 0;
|
||||
|
||||
fhp = &nfh.fh_generic;
|
||||
nfsm_srvmtofh(fhp);
|
||||
@ -1758,17 +1671,15 @@ nfsrv_remove(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
error = ESTALE;
|
||||
goto ereply;
|
||||
}
|
||||
vfslocked = VFS_LOCK_GIANT(mp);
|
||||
(void) vn_start_write(NULL, &mp, V_WAIT);
|
||||
vfs_rel(mp); /* The write holds a ref. */
|
||||
nfsm_srvnamesiz(len);
|
||||
|
||||
nd.ni_cnd.cn_cred = cred;
|
||||
nd.ni_cnd.cn_nameiop = DELETE;
|
||||
nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | MPSAFE;
|
||||
nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
|
||||
error = nfs_namei(&nd, nfsd, fhp, len, slp, nam, &md, &dpos,
|
||||
&dirp, v3, &dirfor, &dirfor_ret, FALSE);
|
||||
vfslocked = nfsrv_lockedpair_nd(vfslocked, &nd);
|
||||
if (dirp && !v3) {
|
||||
vrele(dirp);
|
||||
dirp = NULL;
|
||||
@ -1830,7 +1741,6 @@ nfsrv_remove(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
if (nd.ni_vp)
|
||||
vput(nd.ni_vp);
|
||||
vn_finished_write(mp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return(error);
|
||||
}
|
||||
|
||||
@ -1858,10 +1768,8 @@ nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
fhandle_t *ffhp, *tfhp;
|
||||
uid_t saved_uid;
|
||||
struct mount *mp = NULL;
|
||||
int vfslocked;
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
vfslocked = 0;
|
||||
#ifndef nolint
|
||||
fvp = NULL;
|
||||
#endif
|
||||
@ -1880,7 +1788,6 @@ nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
error = ESTALE;
|
||||
goto out1;
|
||||
}
|
||||
vfslocked = VFS_LOCK_GIANT(mp);
|
||||
(void) vn_start_write(NULL, &mp, V_WAIT);
|
||||
vfs_rel(mp); /* The write holds a ref. */
|
||||
nfsm_srvnamesiz(len);
|
||||
@ -1891,10 +1798,9 @@ nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
saved_uid = cred->cr_uid;
|
||||
fromnd.ni_cnd.cn_cred = cred;
|
||||
fromnd.ni_cnd.cn_nameiop = DELETE;
|
||||
fromnd.ni_cnd.cn_flags = WANTPARENT | SAVESTART | MPSAFE;
|
||||
fromnd.ni_cnd.cn_flags = WANTPARENT | SAVESTART;
|
||||
error = nfs_namei(&fromnd, nfsd, ffhp, len, slp, nam, &md,
|
||||
&dpos, &fdirp, v3, &fdirfor, &fdirfor_ret, FALSE);
|
||||
vfslocked = nfsrv_lockedpair_nd(vfslocked, &fromnd);
|
||||
if (fdirp && !v3) {
|
||||
vrele(fdirp);
|
||||
fdirp = NULL;
|
||||
@ -1914,10 +1820,9 @@ nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
cred->cr_uid = saved_uid;
|
||||
tond.ni_cnd.cn_cred = cred;
|
||||
tond.ni_cnd.cn_nameiop = RENAME;
|
||||
tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART | MPSAFE;
|
||||
tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART;
|
||||
error = nfs_namei(&tond, nfsd, tfhp, len2, slp, nam, &md,
|
||||
&dpos, &tdirp, v3, &tdirfor, &tdirfor_ret, FALSE);
|
||||
vfslocked = nfsrv_lockedpair_nd(vfslocked, &tond);
|
||||
if (tdirp && !v3) {
|
||||
vrele(tdirp);
|
||||
tdirp = NULL;
|
||||
@ -2063,7 +1968,6 @@ nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
vrele(fromnd.ni_vp);
|
||||
|
||||
vn_finished_write(mp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -2088,12 +1992,9 @@ nfsrv_link(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
nfsfh_t nfh, dnfh;
|
||||
fhandle_t *fhp, *dfhp;
|
||||
struct mount *mp = NULL;
|
||||
int tvfslocked;
|
||||
int vfslocked;
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
ndclear(&nd);
|
||||
vfslocked = 0;
|
||||
|
||||
fhp = &nfh.fh_generic;
|
||||
dfhp = &dnfh.fh_generic;
|
||||
@ -2102,14 +2003,12 @@ nfsrv_link(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
error = ESTALE;
|
||||
goto ereply;
|
||||
}
|
||||
vfslocked = VFS_LOCK_GIANT(mp);
|
||||
(void) vn_start_write(NULL, &mp, V_WAIT);
|
||||
vfs_rel(mp); /* The write holds a ref. */
|
||||
nfsm_srvmtofh(dfhp);
|
||||
nfsm_srvnamesiz(len);
|
||||
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, &tvfslocked, nfsd, slp, nam, &rdonly);
|
||||
vfslocked = nfsrv_lockedpair(vfslocked, tvfslocked);
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly);
|
||||
if (error) {
|
||||
nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3));
|
||||
if (v3) {
|
||||
@ -2129,10 +2028,9 @@ nfsrv_link(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
VOP_UNLOCK(vp, 0);
|
||||
nd.ni_cnd.cn_cred = cred;
|
||||
nd.ni_cnd.cn_nameiop = CREATE;
|
||||
nd.ni_cnd.cn_flags = LOCKPARENT | MPSAFE | MPSAFE;
|
||||
nd.ni_cnd.cn_flags = LOCKPARENT;
|
||||
error = nfs_namei(&nd, nfsd, dfhp, len, slp, nam, &md, &dpos,
|
||||
&dirp, v3, &dirfor, &dirfor_ret, FALSE);
|
||||
vfslocked = nfsrv_lockedpair_nd(vfslocked, &nd);
|
||||
if (dirp && !v3) {
|
||||
vrele(dirp);
|
||||
dirp = NULL;
|
||||
@ -2210,7 +2108,6 @@ nfsrv_link(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
if (nd.ni_vp)
|
||||
vrele(nd.ni_vp);
|
||||
vn_finished_write(mp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return(error);
|
||||
}
|
||||
|
||||
@ -2239,12 +2136,9 @@ nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
nfsfh_t nfh;
|
||||
fhandle_t *fhp;
|
||||
struct mount *mp = NULL;
|
||||
int tvfslocked;
|
||||
int vfslocked;
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
ndclear(&nd);
|
||||
vfslocked = 0;
|
||||
|
||||
fhp = &nfh.fh_generic;
|
||||
nfsm_srvmtofh(fhp);
|
||||
@ -2252,16 +2146,14 @@ nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
error = ESTALE;
|
||||
goto out;
|
||||
}
|
||||
vfslocked = VFS_LOCK_GIANT(mp);
|
||||
(void) vn_start_write(NULL, &mp, V_WAIT);
|
||||
vfs_rel(mp); /* The write holds a ref. */
|
||||
nfsm_srvnamesiz(len);
|
||||
nd.ni_cnd.cn_cred = cred;
|
||||
nd.ni_cnd.cn_nameiop = CREATE;
|
||||
nd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART | MPSAFE;
|
||||
nd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART;
|
||||
error = nfs_namei(&nd, nfsd, fhp, len, slp, nam, &md, &dpos,
|
||||
&dirp, v3, &dirfor, &dirfor_ret, FALSE);
|
||||
vfslocked = nfsrv_lockedpair_nd(vfslocked, &nd);
|
||||
if (error == 0) {
|
||||
VATTR_NULL(vap);
|
||||
if (v3)
|
||||
@ -2327,13 +2219,8 @@ nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
nd.ni_cnd.cn_flags |= (NOFOLLOW | LOCKLEAF);
|
||||
nd.ni_cnd.cn_thread = curthread;
|
||||
nd.ni_cnd.cn_cred = cred;
|
||||
tvfslocked = VFS_LOCK_GIANT(nd.ni_startdir->v_mount);
|
||||
if (tvfslocked)
|
||||
nd.ni_cnd.cn_flags |= GIANTHELD;
|
||||
error = lookup(&nd);
|
||||
nd.ni_dvp = NULL;
|
||||
vfslocked = nfsrv_lockedpair_nd(vfslocked, &nd);
|
||||
nd.ni_cnd.cn_flags &= ~GIANTHELD;
|
||||
|
||||
if (error == 0) {
|
||||
bzero((caddr_t)fhp, sizeof(nfh));
|
||||
@ -2393,7 +2280,6 @@ nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
free(pathcp, M_TEMP);
|
||||
|
||||
vn_finished_write(mp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -2422,11 +2308,9 @@ nfsrv_mkdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
nfsfh_t nfh;
|
||||
fhandle_t *fhp;
|
||||
struct mount *mp = NULL;
|
||||
int vfslocked;
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
ndclear(&nd);
|
||||
vfslocked = 0;
|
||||
|
||||
fhp = &nfh.fh_generic;
|
||||
nfsm_srvmtofh(fhp);
|
||||
@ -2434,17 +2318,15 @@ nfsrv_mkdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
error = ESTALE;
|
||||
goto out;
|
||||
}
|
||||
vfslocked = VFS_LOCK_GIANT(mp);
|
||||
(void) vn_start_write(NULL, &mp, V_WAIT);
|
||||
vfs_rel(mp); /* The write holds a ref. */
|
||||
nfsm_srvnamesiz(len);
|
||||
nd.ni_cnd.cn_cred = cred;
|
||||
nd.ni_cnd.cn_nameiop = CREATE;
|
||||
nd.ni_cnd.cn_flags = LOCKPARENT | MPSAFE;
|
||||
nd.ni_cnd.cn_flags = LOCKPARENT;
|
||||
|
||||
error = nfs_namei(&nd, nfsd, fhp, len, slp, nam, &md, &dpos,
|
||||
&dirp, v3, &dirfor, &dirfor_ret, FALSE);
|
||||
vfslocked = nfsrv_lockedpair_nd(vfslocked, &nd);
|
||||
if (dirp && !v3) {
|
||||
vrele(dirp);
|
||||
dirp = NULL;
|
||||
@ -2556,7 +2438,6 @@ nfsrv_mkdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
if (dirp)
|
||||
vrele(dirp);
|
||||
vn_finished_write(mp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -2581,11 +2462,9 @@ nfsrv_rmdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
fhandle_t *fhp;
|
||||
struct nameidata nd;
|
||||
struct mount *mp = NULL;
|
||||
int vfslocked;
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
ndclear(&nd);
|
||||
vfslocked = 0;
|
||||
|
||||
fhp = &nfh.fh_generic;
|
||||
nfsm_srvmtofh(fhp);
|
||||
@ -2593,16 +2472,14 @@ nfsrv_rmdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
error = ESTALE;
|
||||
goto out;
|
||||
}
|
||||
vfslocked = VFS_LOCK_GIANT(mp);
|
||||
(void) vn_start_write(NULL, &mp, V_WAIT);
|
||||
vfs_rel(mp); /* The write holds a ref. */
|
||||
nfsm_srvnamesiz(len);
|
||||
nd.ni_cnd.cn_cred = cred;
|
||||
nd.ni_cnd.cn_nameiop = DELETE;
|
||||
nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | MPSAFE;
|
||||
nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
|
||||
error = nfs_namei(&nd, nfsd, fhp, len, slp, nam, &md, &dpos,
|
||||
&dirp, v3, &dirfor, &dirfor_ret, FALSE);
|
||||
vfslocked = nfsrv_lockedpair_nd(vfslocked, &nd);
|
||||
if (dirp && !v3) {
|
||||
vrele(dirp);
|
||||
dirp = NULL;
|
||||
@ -2680,7 +2557,6 @@ nfsrv_rmdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
vrele(dirp);
|
||||
|
||||
vn_finished_write(mp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return(error);
|
||||
}
|
||||
|
||||
@ -2749,10 +2625,9 @@ nfsrv_readdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
int v3 = (nfsd->nd_flag & ND_NFSV3);
|
||||
u_quad_t off, toff, verf;
|
||||
u_long *cookies = NULL, *cookiep; /* needs to be int64_t or off_t */
|
||||
int vfslocked, not_zfs;
|
||||
int not_zfs;
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
vfslocked = 0;
|
||||
fhp = &nfh.fh_generic;
|
||||
nfsm_srvmtofh(fhp);
|
||||
if (v3) {
|
||||
@ -2775,7 +2650,7 @@ nfsrv_readdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
if (siz > xfer)
|
||||
siz = xfer;
|
||||
fullsiz = siz;
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, &vfslocked, nfsd, slp, nam, &rdonly);
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly);
|
||||
if (!error && vp->v_type != VDIR) {
|
||||
error = ENOTDIR;
|
||||
vput(vp);
|
||||
@ -3015,7 +2890,6 @@ nfsrv_readdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
nfsmout:
|
||||
if (vp)
|
||||
vrele(vp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return(error);
|
||||
}
|
||||
|
||||
@ -3049,13 +2923,12 @@ nfsrv_readdirplus(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
u_quad_t off, toff, verf;
|
||||
u_long *cookies = NULL, *cookiep; /* needs to be int64_t or off_t */
|
||||
int v3 = (nfsd->nd_flag & ND_NFSV3);
|
||||
int usevget = 1, vfslocked;
|
||||
int usevget = 1;
|
||||
struct componentname cn;
|
||||
struct mount *mntp = NULL;
|
||||
int not_zfs;
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
vfslocked = 0;
|
||||
vp_locked = 0;
|
||||
if (!v3)
|
||||
panic("nfsrv_readdirplus: v3 proc called on a v2 connection");
|
||||
@ -3076,7 +2949,7 @@ nfsrv_readdirplus(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
if (siz > xfer)
|
||||
siz = xfer;
|
||||
fullsiz = siz;
|
||||
error = nfsrv_fhtovp(fhp, NFSRV_FLAG_BUSY, &vp, &vfslocked, nfsd, slp,
|
||||
error = nfsrv_fhtovp(fhp, NFSRV_FLAG_BUSY, &vp, nfsd, slp,
|
||||
nam, &rdonly);
|
||||
if (!error) {
|
||||
vp_locked = 1;
|
||||
@ -3245,7 +3118,7 @@ nfsrv_readdirplus(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
usevget = 0;
|
||||
cn.cn_nameiop = LOOKUP;
|
||||
cn.cn_flags = ISLASTCN | NOFOLLOW | \
|
||||
LOCKSHARED | LOCKLEAF | MPSAFE;
|
||||
LOCKSHARED | LOCKLEAF;
|
||||
cn.cn_lkflags = LK_SHARED | LK_RETRY;
|
||||
cn.cn_cred = cred;
|
||||
cn.cn_thread = curthread;
|
||||
@ -3393,7 +3266,6 @@ nfsrv_readdirplus(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
vrele(vp);
|
||||
if (mntp)
|
||||
vfs_unbusy(mntp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return(error);
|
||||
}
|
||||
|
||||
@ -3419,11 +3291,8 @@ nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
u_quad_t off;
|
||||
struct mount *mp = NULL;
|
||||
int v3 = (nfsd->nd_flag & ND_NFSV3);
|
||||
int tvfslocked;
|
||||
int vfslocked;
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
vfslocked = 0;
|
||||
if (!v3)
|
||||
panic("nfsrv_commit: v3 proc called on a v2 connection");
|
||||
fhp = &nfh.fh_generic;
|
||||
@ -3432,7 +3301,6 @@ nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
error = ESTALE;
|
||||
goto ereply;
|
||||
}
|
||||
vfslocked = VFS_LOCK_GIANT(mp);
|
||||
(void) vn_start_write(NULL, &mp, V_WAIT);
|
||||
vfs_rel(mp); /* The write holds a ref. */
|
||||
tl = nfsm_dissect_nonblock(u_int32_t *, 3 * NFSX_UNSIGNED);
|
||||
@ -3444,8 +3312,7 @@ nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
off = fxdr_hyper(tl);
|
||||
tl += 2;
|
||||
cnt = fxdr_unsigned(int, *tl);
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, &tvfslocked, nfsd, slp, nam, &rdonly);
|
||||
vfslocked = nfsrv_lockedpair(vfslocked, tvfslocked);
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly);
|
||||
if (error) {
|
||||
nfsm_reply(2 * NFSX_UNSIGNED);
|
||||
nfsm_srvwcc_data(for_ret, &bfor, aft_ret, &aft);
|
||||
@ -3561,7 +3428,6 @@ nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
if (vp)
|
||||
vput(vp);
|
||||
vn_finished_write(mp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return(error);
|
||||
}
|
||||
|
||||
@ -3588,13 +3454,11 @@ nfsrv_statfs(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
fhandle_t *fhp;
|
||||
struct statfs statfs;
|
||||
u_quad_t tval;
|
||||
int vfslocked;
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
vfslocked = 0;
|
||||
fhp = &nfh.fh_generic;
|
||||
nfsm_srvmtofh(fhp);
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, &vfslocked, nfsd, slp, nam, &rdonly);
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly);
|
||||
if (error) {
|
||||
nfsm_reply(NFSX_UNSIGNED);
|
||||
if (v3)
|
||||
@ -3654,7 +3518,6 @@ nfsrv_statfs(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
nfsmout:
|
||||
if (vp)
|
||||
vput(vp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return(error);
|
||||
}
|
||||
|
||||
@ -3680,15 +3543,13 @@ nfsrv_fsinfo(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
u_quad_t maxfsize;
|
||||
struct statfs sb;
|
||||
int v3 = (nfsd->nd_flag & ND_NFSV3);
|
||||
int vfslocked;
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
if (!v3)
|
||||
panic("nfsrv_fsinfo: v3 proc called on a v2 connection");
|
||||
fhp = &nfh.fh_generic;
|
||||
vfslocked = 0;
|
||||
nfsm_srvmtofh(fhp);
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, &vfslocked, nfsd, slp, nam, &rdonly);
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly);
|
||||
if (error) {
|
||||
nfsm_reply(NFSX_UNSIGNED);
|
||||
nfsm_srvpostop_attr(getret, &at);
|
||||
@ -3729,7 +3590,6 @@ nfsrv_fsinfo(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
nfsmout:
|
||||
if (vp)
|
||||
vput(vp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return(error);
|
||||
}
|
||||
|
||||
@ -3754,15 +3614,13 @@ nfsrv_pathconf(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
nfsfh_t nfh;
|
||||
fhandle_t *fhp;
|
||||
int v3 = (nfsd->nd_flag & ND_NFSV3);
|
||||
int vfslocked;
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
if (!v3)
|
||||
panic("nfsrv_pathconf: v3 proc called on a v2 connection");
|
||||
vfslocked = 0;
|
||||
fhp = &nfh.fh_generic;
|
||||
nfsm_srvmtofh(fhp);
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, &vfslocked, nfsd, slp, nam, &rdonly);
|
||||
error = nfsrv_fhtovp(fhp, 0, &vp, nfsd, slp, nam, &rdonly);
|
||||
if (error) {
|
||||
nfsm_reply(NFSX_UNSIGNED);
|
||||
nfsm_srvpostop_attr(getret, &at);
|
||||
@ -3802,7 +3660,6 @@ nfsrv_pathconf(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
nfsmout:
|
||||
if (vp)
|
||||
vput(vp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return(error);
|
||||
}
|
||||
|
||||
@ -3871,8 +3728,6 @@ nfsrv_access(struct vnode *vp, accmode_t accmode, struct ucred *cred,
|
||||
struct vattr vattr;
|
||||
int error;
|
||||
|
||||
VFS_ASSERT_GIANT(vp->v_mount);
|
||||
|
||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||
|
||||
if (accmode & VWRITE) {
|
||||
|
@ -594,11 +594,7 @@ nfs_namei(struct nameidata *ndp, struct nfsrv_descript *nfsd,
|
||||
int error, rdonly, linklen;
|
||||
struct componentname *cnp = &ndp->ni_cnd;
|
||||
int lockleaf = (cnp->cn_flags & LOCKLEAF) != 0;
|
||||
int dvfslocked;
|
||||
int vfslocked;
|
||||
|
||||
vfslocked = 0;
|
||||
dvfslocked = 0;
|
||||
*retdirp = NULL;
|
||||
cnp->cn_flags |= NOMACCHECK;
|
||||
cnp->cn_pnbuf = uma_zalloc(namei_zone, M_WAITOK);
|
||||
@ -645,10 +641,9 @@ nfs_namei(struct nameidata *ndp, struct nfsrv_descript *nfsd,
|
||||
/*
|
||||
* Extract and set starting directory.
|
||||
*/
|
||||
error = nfsrv_fhtovp(fhp, 0, &dp, &dvfslocked, nfsd, slp, nam, &rdonly);
|
||||
error = nfsrv_fhtovp(fhp, 0, &dp, nfsd, slp, nam, &rdonly);
|
||||
if (error)
|
||||
goto out;
|
||||
vfslocked = VFS_LOCK_GIANT(dp->v_mount);
|
||||
if (dp->v_type != VDIR) {
|
||||
vput(dp);
|
||||
error = ENOTDIR;
|
||||
@ -726,14 +721,9 @@ nfs_namei(struct nameidata *ndp, struct nfsrv_descript *nfsd,
|
||||
if (pubflag) {
|
||||
ndp->ni_rootdir = rootvnode;
|
||||
ndp->ni_loopcnt = 0;
|
||||
if (cnp->cn_pnbuf[0] == '/') {
|
||||
int tvfslocked;
|
||||
|
||||
tvfslocked = VFS_LOCK_GIANT(rootvnode->v_mount);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
if (cnp->cn_pnbuf[0] == '/')
|
||||
dp = rootvnode;
|
||||
vfslocked = tvfslocked;
|
||||
}
|
||||
} else {
|
||||
cnp->cn_flags |= NOCROSSMOUNT;
|
||||
}
|
||||
@ -758,11 +748,7 @@ nfs_namei(struct nameidata *ndp, struct nfsrv_descript *nfsd,
|
||||
* In either case ni_startdir will be dereferenced and NULLed
|
||||
* out.
|
||||
*/
|
||||
if (vfslocked)
|
||||
ndp->ni_cnd.cn_flags |= GIANTHELD;
|
||||
error = lookup(ndp);
|
||||
vfslocked = (ndp->ni_cnd.cn_flags & GIANTHELD) != 0;
|
||||
ndp->ni_cnd.cn_flags &= ~GIANTHELD;
|
||||
if (error)
|
||||
break;
|
||||
|
||||
@ -860,10 +846,6 @@ nfs_namei(struct nameidata *ndp, struct nfsrv_descript *nfsd,
|
||||
}
|
||||
if (!lockleaf)
|
||||
cnp->cn_flags &= ~LOCKLEAF;
|
||||
if (cnp->cn_flags & GIANTHELD) {
|
||||
mtx_unlock(&Giant);
|
||||
cnp->cn_flags &= ~GIANTHELD;
|
||||
}
|
||||
|
||||
/*
|
||||
* nfs_namei() guarentees that fields will not contain garbage
|
||||
@ -877,21 +859,9 @@ nfs_namei(struct nameidata *ndp, struct nfsrv_descript *nfsd,
|
||||
ndp->ni_dvp = NULL;
|
||||
ndp->ni_startdir = NULL;
|
||||
cnp->cn_flags &= ~HASBUF;
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
vfslocked = 0;
|
||||
} else if ((ndp->ni_cnd.cn_flags & (WANTPARENT|LOCKPARENT)) == 0) {
|
||||
ndp->ni_dvp = NULL;
|
||||
}
|
||||
/*
|
||||
* This differs from normal namei() in that even on failure we may
|
||||
* return with Giant held due to the dirp return. Make sure we only
|
||||
* have not recursed however. The calling code only expects to drop
|
||||
* one acquire.
|
||||
*/
|
||||
if (vfslocked || dvfslocked)
|
||||
ndp->ni_cnd.cn_flags |= GIANTHELD;
|
||||
if (vfslocked && dvfslocked)
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -1055,7 +1025,7 @@ nfsm_srvfattr(struct nfsrv_descript *nfsd, struct vattr *vap,
|
||||
* - if cred->cr_uid == 0 or MNT_EXPORTANON set it to credanon
|
||||
*/
|
||||
int
|
||||
nfsrv_fhtovp(fhandle_t *fhp, int flags, struct vnode **vpp, int *vfslockedp,
|
||||
nfsrv_fhtovp(fhandle_t *fhp, int flags, struct vnode **vpp,
|
||||
struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
||||
struct sockaddr *nam, int *rdonlyp)
|
||||
{
|
||||
@ -1067,13 +1037,11 @@ nfsrv_fhtovp(fhandle_t *fhp, int flags, struct vnode **vpp, int *vfslockedp,
|
||||
struct sockaddr_int *saddr;
|
||||
#endif
|
||||
int credflavor;
|
||||
int vfslocked;
|
||||
int numsecflavors, *secflavors;
|
||||
int authsys;
|
||||
int v3 = nfsd->nd_flag & ND_NFSV3;
|
||||
int mountreq;
|
||||
|
||||
*vfslockedp = 0;
|
||||
*vpp = NULL;
|
||||
|
||||
if (nfs_ispublicfh(fhp)) {
|
||||
@ -1085,7 +1053,6 @@ nfsrv_fhtovp(fhandle_t *fhp, int flags, struct vnode **vpp, int *vfslockedp,
|
||||
mp = vfs_busyfs(&fhp->fh_fsid);
|
||||
if (!mp)
|
||||
return (ESTALE);
|
||||
vfslocked = VFS_LOCK_GIANT(mp);
|
||||
error = VFS_CHECKEXP(mp, nam, &exflags, &credanon,
|
||||
&numsecflavors, &secflavors);
|
||||
if (error) {
|
||||
@ -1169,10 +1136,6 @@ nfsrv_fhtovp(fhandle_t *fhp, int flags, struct vnode **vpp, int *vfslockedp,
|
||||
if (credanon != NULL)
|
||||
crfree(credanon);
|
||||
|
||||
if (error)
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
else
|
||||
*vfslockedp = vfslocked;
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -1769,7 +1769,6 @@ nlm_convert_to_fhandle_t(fhandle_t *fhp, struct netobj *p)
|
||||
struct vfs_state {
|
||||
struct mount *vs_mp;
|
||||
struct vnode *vs_vp;
|
||||
int vs_vfslocked;
|
||||
int vs_vnlocked;
|
||||
};
|
||||
|
||||
@ -1786,7 +1785,6 @@ nlm_get_vfs_state(struct nlm_host *host, struct svc_req *rqstp,
|
||||
if (!vs->vs_mp) {
|
||||
return (ESTALE);
|
||||
}
|
||||
vs->vs_vfslocked = VFS_LOCK_GIANT(vs->vs_mp);
|
||||
|
||||
/* accmode == 0 means don't check, since it is an unlock. */
|
||||
if (accmode != 0) {
|
||||
@ -1862,7 +1860,6 @@ nlm_release_vfs_state(struct vfs_state *vs)
|
||||
}
|
||||
if (vs->vs_mp)
|
||||
vfs_rel(vs->vs_mp);
|
||||
VFS_UNLOCK_GIANT(vs->vs_vfslocked);
|
||||
}
|
||||
|
||||
static nlm4_stats
|
||||
|
@ -651,7 +651,6 @@ audit_arg_file(struct proc *p, struct file *fp)
|
||||
struct socket *so;
|
||||
struct inpcb *pcb;
|
||||
struct vnode *vp;
|
||||
int vfslocked;
|
||||
|
||||
ar = currecord();
|
||||
if (ar == NULL)
|
||||
@ -664,11 +663,9 @@ audit_arg_file(struct proc *p, struct file *fp)
|
||||
* XXXAUDIT: Only possibly to record as first vnode?
|
||||
*/
|
||||
vp = fp->f_vnode;
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
vn_lock(vp, LK_SHARED | LK_RETRY);
|
||||
audit_arg_vnode1(vp);
|
||||
VOP_UNLOCK(vp, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
break;
|
||||
|
||||
case DTYPE_SOCKET:
|
||||
@ -768,11 +765,6 @@ audit_arg_vnode(struct vnode *vp, struct vnode_au_info *vnp)
|
||||
struct vattr vattr;
|
||||
int error;
|
||||
|
||||
/*
|
||||
* Assume that if the caller is calling audit_arg_vnode() on a
|
||||
* non-MPSAFE vnode, then it will have acquired Giant.
|
||||
*/
|
||||
VFS_ASSERT_GIANT(vp->v_mount);
|
||||
ASSERT_VOP_LOCKED(vp, "audit_arg_vnode");
|
||||
|
||||
error = VOP_GETATTR(vp, &vattr, curthread->td_ucred);
|
||||
@ -889,7 +881,6 @@ audit_sysclose(struct thread *td, int fd)
|
||||
struct kaudit_record *ar;
|
||||
struct vnode *vp;
|
||||
struct file *fp;
|
||||
int vfslocked;
|
||||
|
||||
KASSERT(td != NULL, ("audit_sysclose: td == NULL"));
|
||||
|
||||
@ -903,10 +894,8 @@ audit_sysclose(struct thread *td, int fd)
|
||||
return;
|
||||
|
||||
vp = fp->f_vnode;
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
vn_lock(vp, LK_SHARED | LK_RETRY);
|
||||
audit_arg_vnode1(vp);
|
||||
VOP_UNLOCK(vp, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
fdrop(fp, td);
|
||||
}
|
||||
|
@ -749,7 +749,7 @@ sys_auditctl(struct thread *td, struct auditctl_args *uap)
|
||||
struct ucred *cred;
|
||||
struct vnode *vp;
|
||||
int error = 0;
|
||||
int flags, vfslocked;
|
||||
int flags;
|
||||
|
||||
if (jailed(td->td_ucred))
|
||||
return (ENOSYS);
|
||||
@ -770,20 +770,18 @@ sys_auditctl(struct thread *td, struct auditctl_args *uap)
|
||||
if (uap->path == NULL)
|
||||
return (EINVAL);
|
||||
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1,
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1,
|
||||
UIO_USERSPACE, uap->path, td);
|
||||
flags = AUDIT_OPEN_FLAGS;
|
||||
error = vn_open(&nd, &flags, 0, NULL);
|
||||
if (error)
|
||||
return (error);
|
||||
vfslocked = NDHASGIANT(&nd);
|
||||
vp = nd.ni_vp;
|
||||
#ifdef MAC
|
||||
error = mac_system_check_auditctl(td->td_ucred, vp);
|
||||
VOP_UNLOCK(vp, 0);
|
||||
if (error) {
|
||||
vn_close(vp, AUDIT_CLOSE_FLAGS, td->td_ucred, td);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
}
|
||||
#else
|
||||
@ -792,10 +790,8 @@ sys_auditctl(struct thread *td, struct auditctl_args *uap)
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
if (vp->v_type != VREG) {
|
||||
vn_close(vp, AUDIT_CLOSE_FLAGS, td->td_ucred, td);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (EINVAL);
|
||||
}
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
cred = td->td_ucred;
|
||||
crhold(cred);
|
||||
|
||||
|
@ -113,7 +113,7 @@ audit_record_write(struct vnode *vp, struct ucred *cred, void *data,
|
||||
static struct timeval last_fail;
|
||||
static int cur_lowspace_trigger;
|
||||
struct statfs *mnt_stat;
|
||||
int error, vfslocked;
|
||||
int error;
|
||||
static int cur_fail;
|
||||
struct vattr vattr;
|
||||
long temp;
|
||||
@ -124,7 +124,6 @@ audit_record_write(struct vnode *vp, struct ucred *cred, void *data,
|
||||
return;
|
||||
|
||||
mnt_stat = &vp->v_mount->mnt_stat;
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
|
||||
/*
|
||||
* First, gather statistics on the audit log file and file system so
|
||||
@ -258,7 +257,6 @@ audit_record_write(struct vnode *vp, struct ucred *cred, void *data,
|
||||
}
|
||||
}
|
||||
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return;
|
||||
|
||||
fail_enospc:
|
||||
@ -289,7 +287,6 @@ audit_record_write(struct vnode *vp, struct ucred *cred, void *data,
|
||||
panic("audit_worker: write error %d\n", error);
|
||||
} else if (ppsratecheck(&last_fail, &cur_fail, 1))
|
||||
printf("audit_worker: write error %d\n", error);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -451,7 +448,6 @@ audit_rotate_vnode(struct ucred *cred, struct vnode *vp)
|
||||
{
|
||||
struct ucred *old_audit_cred;
|
||||
struct vnode *old_audit_vp;
|
||||
int vfslocked;
|
||||
|
||||
KASSERT((cred != NULL && vp != NULL) || (cred == NULL && vp == NULL),
|
||||
("audit_rotate_vnode: cred %p vp %p", cred, vp));
|
||||
@ -473,10 +469,8 @@ audit_rotate_vnode(struct ucred *cred, struct vnode *vp)
|
||||
* If there was an old vnode/credential, close and free.
|
||||
*/
|
||||
if (old_audit_vp != NULL) {
|
||||
vfslocked = VFS_LOCK_GIANT(old_audit_vp->v_mount);
|
||||
vn_close(old_audit_vp, AUDIT_CLOSE_FLAGS, old_audit_cred,
|
||||
curthread);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
crfree(old_audit_cred);
|
||||
}
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ mac_proc_vm_revoke_recurse(struct thread *td, struct ucred *cred,
|
||||
struct vm_map *map)
|
||||
{
|
||||
vm_map_entry_t vme;
|
||||
int vfslocked, result;
|
||||
int result;
|
||||
vm_prot_t revokeperms;
|
||||
vm_object_t backing_object, object;
|
||||
vm_ooffset_t offset;
|
||||
@ -300,7 +300,6 @@ mac_proc_vm_revoke_recurse(struct thread *td, struct ucred *cred,
|
||||
if (object->type != OBJT_VNODE)
|
||||
continue;
|
||||
vp = (struct vnode *)object->handle;
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
result = vme->max_protection;
|
||||
mac_vnode_check_mmap_downgrade(cred, vp, &result);
|
||||
@ -310,10 +309,8 @@ mac_proc_vm_revoke_recurse(struct thread *td, struct ucred *cred,
|
||||
* but a policy needs to get removed.
|
||||
*/
|
||||
revokeperms = vme->max_protection & ~result;
|
||||
if (!revokeperms) {
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
if (!revokeperms)
|
||||
continue;
|
||||
}
|
||||
printf("pid %ld: revoking %s perms from %#lx:%ld "
|
||||
"(max %s/cur %s)\n", (long)td->td_proc->p_pid,
|
||||
prot2str(revokeperms), (u_long)vme->start,
|
||||
@ -369,7 +366,6 @@ mac_proc_vm_revoke_recurse(struct thread *td, struct ucred *cred,
|
||||
vme->protection & ~revokeperms);
|
||||
vm_map_simplify_entry(map, vme);
|
||||
}
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
}
|
||||
vm_map_unlock(map);
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ sys___mac_get_fd(struct thread *td, struct __mac_get_fd_args *uap)
|
||||
struct pipe *pipe;
|
||||
struct socket *so;
|
||||
short label_type;
|
||||
int vfslocked, error;
|
||||
int error;
|
||||
|
||||
error = copyin(uap->mac_p, &mac, sizeof(mac));
|
||||
if (error)
|
||||
@ -262,11 +262,9 @@ sys___mac_get_fd(struct thread *td, struct __mac_get_fd_args *uap)
|
||||
}
|
||||
vp = fp->f_vnode;
|
||||
intlabel = mac_vnode_label_alloc();
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
mac_vnode_copy_label(vp->v_label, intlabel);
|
||||
VOP_UNLOCK(vp, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
error = mac_vnode_externalize_label(intlabel, elements,
|
||||
buffer, mac.m_buflen);
|
||||
mac_vnode_label_free(intlabel);
|
||||
@ -322,7 +320,7 @@ sys___mac_get_file(struct thread *td, struct __mac_get_file_args *uap)
|
||||
struct nameidata nd;
|
||||
struct label *intlabel;
|
||||
struct mac mac;
|
||||
int vfslocked, error;
|
||||
int error;
|
||||
|
||||
if (!(mac_labeled & MPC_OBJECT_VNODE))
|
||||
return (EINVAL);
|
||||
@ -343,20 +341,18 @@ sys___mac_get_file(struct thread *td, struct __mac_get_file_args *uap)
|
||||
}
|
||||
|
||||
buffer = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK | M_ZERO);
|
||||
NDINIT(&nd, LOOKUP, MPSAFE | LOCKLEAF | FOLLOW, UIO_USERSPACE,
|
||||
NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW, UIO_USERSPACE,
|
||||
uap->path_p, td);
|
||||
error = namei(&nd);
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
intlabel = mac_vnode_label_alloc();
|
||||
vfslocked = NDHASGIANT(&nd);
|
||||
mac_vnode_copy_label(nd.ni_vp->v_label, intlabel);
|
||||
error = mac_vnode_externalize_label(intlabel, elements, buffer,
|
||||
mac.m_buflen);
|
||||
|
||||
NDFREE(&nd, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
mac_vnode_label_free(intlabel);
|
||||
if (error == 0)
|
||||
error = copyout(buffer, mac.m_string, strlen(buffer)+1);
|
||||
@ -375,7 +371,7 @@ sys___mac_get_link(struct thread *td, struct __mac_get_link_args *uap)
|
||||
struct nameidata nd;
|
||||
struct label *intlabel;
|
||||
struct mac mac;
|
||||
int vfslocked, error;
|
||||
int error;
|
||||
|
||||
if (!(mac_labeled & MPC_OBJECT_VNODE))
|
||||
return (EINVAL);
|
||||
@ -396,19 +392,17 @@ sys___mac_get_link(struct thread *td, struct __mac_get_link_args *uap)
|
||||
}
|
||||
|
||||
buffer = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK | M_ZERO);
|
||||
NDINIT(&nd, LOOKUP, MPSAFE | LOCKLEAF | NOFOLLOW, UIO_USERSPACE,
|
||||
NDINIT(&nd, LOOKUP, LOCKLEAF | NOFOLLOW, UIO_USERSPACE,
|
||||
uap->path_p, td);
|
||||
error = namei(&nd);
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
intlabel = mac_vnode_label_alloc();
|
||||
vfslocked = NDHASGIANT(&nd);
|
||||
mac_vnode_copy_label(nd.ni_vp->v_label, intlabel);
|
||||
error = mac_vnode_externalize_label(intlabel, elements, buffer,
|
||||
mac.m_buflen);
|
||||
NDFREE(&nd, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
mac_vnode_label_free(intlabel);
|
||||
|
||||
if (error == 0)
|
||||
@ -432,7 +426,7 @@ sys___mac_set_fd(struct thread *td, struct __mac_set_fd_args *uap)
|
||||
struct vnode *vp;
|
||||
struct mac mac;
|
||||
char *buffer;
|
||||
int error, vfslocked;
|
||||
int error;
|
||||
|
||||
error = copyin(uap->mac_p, &mac, sizeof(mac));
|
||||
if (error)
|
||||
@ -467,10 +461,8 @@ sys___mac_set_fd(struct thread *td, struct __mac_set_fd_args *uap)
|
||||
break;
|
||||
}
|
||||
vp = fp->f_vnode;
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
|
||||
if (error != 0) {
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
mac_vnode_label_free(intlabel);
|
||||
break;
|
||||
}
|
||||
@ -478,7 +470,6 @@ sys___mac_set_fd(struct thread *td, struct __mac_set_fd_args *uap)
|
||||
error = vn_setlabel(vp, intlabel, td->td_ucred);
|
||||
VOP_UNLOCK(vp, 0);
|
||||
vn_finished_write(mp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
mac_vnode_label_free(intlabel);
|
||||
break;
|
||||
|
||||
@ -532,7 +523,7 @@ sys___mac_set_file(struct thread *td, struct __mac_set_file_args *uap)
|
||||
struct mount *mp;
|
||||
struct mac mac;
|
||||
char *buffer;
|
||||
int vfslocked, error;
|
||||
int error;
|
||||
|
||||
if (!(mac_labeled & MPC_OBJECT_VNODE))
|
||||
return (EINVAL);
|
||||
@ -558,10 +549,9 @@ sys___mac_set_file(struct thread *td, struct __mac_set_file_args *uap)
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
NDINIT(&nd, LOOKUP, MPSAFE | LOCKLEAF | FOLLOW, UIO_USERSPACE,
|
||||
NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW, UIO_USERSPACE,
|
||||
uap->path_p, td);
|
||||
error = namei(&nd);
|
||||
vfslocked = NDHASGIANT(&nd);
|
||||
if (error == 0) {
|
||||
error = vn_start_write(nd.ni_vp, &mp, V_WAIT | PCATCH);
|
||||
if (error == 0) {
|
||||
@ -572,7 +562,6 @@ sys___mac_set_file(struct thread *td, struct __mac_set_file_args *uap)
|
||||
}
|
||||
|
||||
NDFREE(&nd, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
out:
|
||||
mac_vnode_label_free(intlabel);
|
||||
return (error);
|
||||
@ -586,7 +575,7 @@ sys___mac_set_link(struct thread *td, struct __mac_set_link_args *uap)
|
||||
struct mount *mp;
|
||||
struct mac mac;
|
||||
char *buffer;
|
||||
int vfslocked, error;
|
||||
int error;
|
||||
|
||||
if (!(mac_labeled & MPC_OBJECT_VNODE))
|
||||
return (EINVAL);
|
||||
@ -612,10 +601,9 @@ sys___mac_set_link(struct thread *td, struct __mac_set_link_args *uap)
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
NDINIT(&nd, LOOKUP, MPSAFE | LOCKLEAF | NOFOLLOW, UIO_USERSPACE,
|
||||
NDINIT(&nd, LOOKUP, LOCKLEAF | NOFOLLOW, UIO_USERSPACE,
|
||||
uap->path_p, td);
|
||||
error = namei(&nd);
|
||||
vfslocked = NDHASGIANT(&nd);
|
||||
if (error == 0) {
|
||||
error = vn_start_write(nd.ni_vp, &mp, V_WAIT | PCATCH);
|
||||
if (error == 0) {
|
||||
@ -626,7 +614,6 @@ sys___mac_set_link(struct thread *td, struct __mac_set_link_args *uap)
|
||||
}
|
||||
|
||||
NDFREE(&nd, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
out:
|
||||
mac_vnode_label_free(intlabel);
|
||||
return (error);
|
||||
|
@ -216,7 +216,7 @@ struct buf {
|
||||
#define B_RELBUF 0x00400000 /* Release VMIO buffer. */
|
||||
#define B_00800000 0x00800000 /* Available flag. */
|
||||
#define B_NOCOPY 0x01000000 /* Don't copy-on-write this buf. */
|
||||
#define B_NEEDSGIANT 0x02000000 /* Buffer's vnode needs giant. */
|
||||
#define B_02000000 0x02000000 /* Available flag. */
|
||||
#define B_PAGING 0x04000000 /* volatile paging I/O -- bypass VMIO */
|
||||
#define B_MANAGED 0x08000000 /* Managed by FS. */
|
||||
#define B_RAM 0x10000000 /* Read ahead mark (flag) */
|
||||
|
@ -111,7 +111,6 @@ struct bufobj {
|
||||
*/
|
||||
#define BO_ONWORKLST (1 << 0) /* On syncer work-list */
|
||||
#define BO_WWAIT (1 << 1) /* Wait for output to complete */
|
||||
#define BO_NEEDSGIANT (1 << 2) /* Require giant for child buffers. */
|
||||
|
||||
#define BO_MTX(bo) (&(bo)->bo_mtx)
|
||||
#define BO_LOCK(bo) mtx_lock(BO_MTX((bo)))
|
||||
|
@ -682,41 +682,6 @@ vfs_statfs_t __vfs_statfs;
|
||||
({if (*(MP)->mnt_op->vfs_reclaim_lowervp != NULL) \
|
||||
(*(MP)->mnt_op->vfs_reclaim_lowervp)((MP), (VP)); })
|
||||
|
||||
#define VFS_NEEDSGIANT_(MP) \
|
||||
((MP) != NULL && ((MP)->mnt_kern_flag & MNTK_MPSAFE) == 0)
|
||||
|
||||
#define VFS_NEEDSGIANT(MP) __extension__ \
|
||||
({ \
|
||||
struct mount *_mp; \
|
||||
_mp = (MP); \
|
||||
VFS_NEEDSGIANT_(_mp); \
|
||||
})
|
||||
|
||||
#define VFS_LOCK_GIANT(MP) __extension__ \
|
||||
({ \
|
||||
int _locked; \
|
||||
struct mount *_mp; \
|
||||
_mp = (MP); \
|
||||
if (VFS_NEEDSGIANT_(_mp)) { \
|
||||
mtx_lock(&Giant); \
|
||||
_locked = 1; \
|
||||
} else \
|
||||
_locked = 0; \
|
||||
_locked; \
|
||||
})
|
||||
#define VFS_UNLOCK_GIANT(locked) do \
|
||||
{ \
|
||||
if ((locked)) \
|
||||
mtx_unlock(&Giant); \
|
||||
} while (0)
|
||||
#define VFS_ASSERT_GIANT(MP) do \
|
||||
{ \
|
||||
struct mount *_mp; \
|
||||
_mp = (MP); \
|
||||
if (VFS_NEEDSGIANT_(_mp)) \
|
||||
mtx_assert(&Giant, MA_OWNED); \
|
||||
} while (0)
|
||||
|
||||
#define VFS_KNOTE_LOCKED(vp, hint) do \
|
||||
{ \
|
||||
if (((vp)->v_vflag & VV_NOKNOTE) == 0) \
|
||||
@ -735,7 +700,8 @@ vfs_statfs_t __vfs_statfs;
|
||||
* Version numbers.
|
||||
*/
|
||||
#define VFS_VERSION_00 0x19660120
|
||||
#define VFS_VERSION VFS_VERSION_00
|
||||
#define VFS_VERSION_01 0x20121030
|
||||
#define VFS_VERSION VFS_VERSION_01
|
||||
|
||||
#define VFS_SET(vfsops, fsname, flags) \
|
||||
static struct vfsconf fsname ## _vfsconf = { \
|
||||
|
@ -144,15 +144,11 @@ struct nameidata {
|
||||
#define ISOPEN 0x00200000 /* caller is opening; return a real vnode. */
|
||||
#define NOCROSSMOUNT 0x00400000 /* do not cross mount points */
|
||||
#define NOMACCHECK 0x00800000 /* do not perform MAC checks */
|
||||
#define MPSAFE 0x01000000 /* namei() must acquire Giant if needed. */
|
||||
#define GIANTHELD 0x02000000 /* namei() is holding giant. */
|
||||
#define AUDITVNODE1 0x04000000 /* audit the looked up vnode information */
|
||||
#define AUDITVNODE2 0x08000000 /* audit the looked up vnode information */
|
||||
#define TRAILINGSLASH 0x10000000 /* path ended in a slash */
|
||||
#define PARAMASK 0x1ffffe00 /* mask of parameter descriptors */
|
||||
|
||||
#define NDHASGIANT(NDP) (((NDP)->ni_cnd.cn_flags & GIANTHELD) != 0)
|
||||
|
||||
/*
|
||||
* Initialization of a nameidata structure.
|
||||
*/
|
||||
|
@ -2465,7 +2465,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
|
||||
long blkcnt, blksize;
|
||||
struct filedesc *fdp;
|
||||
struct file *fp, *vfp;
|
||||
int vfslocked, filetype, error;
|
||||
int filetype, error;
|
||||
static struct fileops *origops, bufferedops;
|
||||
|
||||
if (req->newlen > sizeof cmd)
|
||||
@ -2670,23 +2670,18 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
|
||||
#endif /* DEBUG */
|
||||
if ((error = ffs_vget(mp, (ino_t)cmd.value, LK_SHARED, &vp)))
|
||||
break;
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
AUDIT_ARG_VNODE1(vp);
|
||||
if ((error = change_dir(vp, td)) != 0) {
|
||||
vput(vp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
break;
|
||||
}
|
||||
VOP_UNLOCK(vp, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
fdp = td->td_proc->p_fd;
|
||||
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);
|
||||
break;
|
||||
|
||||
case FFS_SET_DOTDOT:
|
||||
@ -2759,7 +2754,6 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
|
||||
#endif /* DEBUG */
|
||||
if ((error = ffs_vget(mp, (ino_t)cmd.value, LK_EXCLUSIVE, &vp)))
|
||||
break;
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
AUDIT_ARG_VNODE1(vp);
|
||||
ip = VTOI(vp);
|
||||
if (ip->i_ump->um_fstype == UFS1)
|
||||
@ -2770,13 +2764,11 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
|
||||
sizeof(struct ufs2_dinode));
|
||||
if (error) {
|
||||
vput(vp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
break;
|
||||
}
|
||||
ip->i_flag |= IN_CHANGE | IN_MODIFIED;
|
||||
error = ffs_update(vp, 1);
|
||||
vput(vp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
break;
|
||||
|
||||
case FFS_SET_BUFOUTPUT:
|
||||
@ -2853,7 +2845,7 @@ buffered_write(fp, uio, active_cred, flags, td)
|
||||
struct inode *ip;
|
||||
struct buf *bp;
|
||||
struct fs *fs;
|
||||
int error, vfslocked;
|
||||
int error;
|
||||
daddr_t lbn;
|
||||
|
||||
/*
|
||||
@ -2868,7 +2860,6 @@ buffered_write(fp, uio, active_cred, flags, td)
|
||||
return (EINVAL);
|
||||
fs = ip->i_fs;
|
||||
foffset_lock_uio(fp, uio, flags);
|
||||
vfslocked = VFS_LOCK_GIANT(ip->i_vnode->v_mount);
|
||||
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
|
||||
#ifdef DEBUG
|
||||
if (fsckcmds) {
|
||||
@ -2896,7 +2887,6 @@ buffered_write(fp, uio, active_cred, flags, td)
|
||||
error = bwrite(bp);
|
||||
out:
|
||||
VOP_UNLOCK(devvp, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
foffset_unlock_uio(fp, uio, flags | FOF_NEXTOFF);
|
||||
return (error);
|
||||
}
|
||||
|
@ -1338,14 +1338,12 @@ softdep_flush(void)
|
||||
struct thread *td;
|
||||
int remaining;
|
||||
int progress;
|
||||
int vfslocked;
|
||||
|
||||
td = curthread;
|
||||
td->td_pflags |= TDP_NORUNNINGBUF;
|
||||
|
||||
for (;;) {
|
||||
kproc_suspend_check(softdepproc);
|
||||
vfslocked = VFS_LOCK_GIANT((struct mount *)NULL);
|
||||
ACQUIRE_LOCK(&lk);
|
||||
/*
|
||||
* If requested, try removing inode or removal dependencies.
|
||||
@ -1361,7 +1359,6 @@ softdep_flush(void)
|
||||
wakeup_one(&proc_waiting);
|
||||
}
|
||||
FREE_LOCK(&lk);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
remaining = progress = 0;
|
||||
mtx_lock(&mountlist_mtx);
|
||||
for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
|
||||
@ -1370,11 +1367,9 @@ softdep_flush(void)
|
||||
continue;
|
||||
if (vfs_busy(mp, MBF_NOWAIT | MBF_MNTLSTLOCK))
|
||||
continue;
|
||||
vfslocked = VFS_LOCK_GIANT(mp);
|
||||
progress += softdep_process_worklist(mp, 0);
|
||||
ump = VFSTOUFS(mp);
|
||||
remaining += ump->softdep_on_worklist;
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
mtx_lock(&mountlist_mtx);
|
||||
nmp = TAILQ_NEXT(mp, mnt_list);
|
||||
vfs_unbusy(mp);
|
||||
|
@ -497,7 +497,7 @@ quotaon(struct thread *td, struct mount *mp, int type, void *fname)
|
||||
struct vnode *vp, **vpp;
|
||||
struct vnode *mvp;
|
||||
struct dquot *dq;
|
||||
int error, flags, vfslocked;
|
||||
int error, flags;
|
||||
struct nameidata nd;
|
||||
|
||||
error = priv_check(td, PRIV_UFS_QUOTAON);
|
||||
@ -510,7 +510,7 @@ quotaon(struct thread *td, struct mount *mp, int type, void *fname)
|
||||
ump = VFSTOUFS(mp);
|
||||
dq = NODQUOT;
|
||||
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_USERSPACE, fname, td);
|
||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, fname, td);
|
||||
flags = FREAD | FWRITE;
|
||||
vfs_ref(mp);
|
||||
vfs_unbusy(mp);
|
||||
@ -519,7 +519,6 @@ quotaon(struct thread *td, struct mount *mp, int type, void *fname)
|
||||
vfs_rel(mp);
|
||||
return (error);
|
||||
}
|
||||
vfslocked = NDHASGIANT(&nd);
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
vp = nd.ni_vp;
|
||||
error = vfs_busy(mp, MBF_NOWAIT);
|
||||
@ -533,7 +532,6 @@ quotaon(struct thread *td, struct mount *mp, int type, void *fname)
|
||||
if (error != 0) {
|
||||
VOP_UNLOCK(vp, 0);
|
||||
(void) vn_close(vp, FREAD|FWRITE, td->td_ucred, td);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -542,7 +540,6 @@ quotaon(struct thread *td, struct mount *mp, int type, void *fname)
|
||||
UFS_UNLOCK(ump);
|
||||
VOP_UNLOCK(vp, 0);
|
||||
(void) vn_close(vp, FREAD|FWRITE, td->td_ucred, td);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
vfs_unbusy(mp);
|
||||
return (EALREADY);
|
||||
}
|
||||
@ -554,7 +551,6 @@ quotaon(struct thread *td, struct mount *mp, int type, void *fname)
|
||||
ump->um_qflags[type] &= ~(QTF_OPENING|QTF_CLOSING);
|
||||
UFS_UNLOCK(ump);
|
||||
(void) vn_close(vp, FREAD|FWRITE, td->td_ucred, td);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
vfs_unbusy(mp);
|
||||
return (error);
|
||||
}
|
||||
@ -571,7 +567,6 @@ quotaon(struct thread *td, struct mount *mp, int type, void *fname)
|
||||
vp->v_vflag |= VV_SYSTEM;
|
||||
VOP_UNLOCK(vp, 0);
|
||||
*vpp = vp;
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
/*
|
||||
* Save the credential of the process that turned on quotas.
|
||||
* Set up the time limits for this quota.
|
||||
@ -643,7 +638,6 @@ quotaoff1(struct thread *td, struct mount *mp, int type)
|
||||
struct dquot *dq;
|
||||
struct inode *ip;
|
||||
struct ucred *cr;
|
||||
int vfslocked;
|
||||
int error;
|
||||
|
||||
ump = VFSTOUFS(mp);
|
||||
@ -689,12 +683,10 @@ quotaoff1(struct thread *td, struct mount *mp, int type)
|
||||
ump->um_cred[type] = NOCRED;
|
||||
UFS_UNLOCK(ump);
|
||||
|
||||
vfslocked = VFS_LOCK_GIANT(qvp->v_mount);
|
||||
vn_lock(qvp, LK_EXCLUSIVE | LK_RETRY);
|
||||
qvp->v_vflag &= ~VV_SYSTEM;
|
||||
VOP_UNLOCK(qvp, 0);
|
||||
error = vn_close(qvp, FREAD|FWRITE, td->td_ucred, td);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
crfree(cr);
|
||||
|
||||
return (error);
|
||||
@ -1246,7 +1238,7 @@ dqget(struct vnode *vp, u_long id, struct ufsmount *ump, int type,
|
||||
struct vnode *dqvp;
|
||||
struct iovec aiov;
|
||||
struct uio auio;
|
||||
int vfslocked, dqvplocked, error;
|
||||
int dqvplocked, error;
|
||||
|
||||
#ifdef DEBUG_VFS_LOCKS
|
||||
if (vp != NULLVP)
|
||||
@ -1292,12 +1284,10 @@ hfound: DQI_LOCK(dq);
|
||||
error = EIO;
|
||||
}
|
||||
*dqp = dq;
|
||||
vfslocked = VFS_LOCK_GIANT(dqvp->v_mount);
|
||||
if (dqvplocked)
|
||||
vput(dqvp);
|
||||
else
|
||||
vrele(dqvp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -1350,12 +1340,10 @@ hfound: DQI_LOCK(dq);
|
||||
DQH_UNLOCK();
|
||||
tablefull("dquot");
|
||||
*dqp = NODQUOT;
|
||||
vfslocked = VFS_LOCK_GIANT(dqvp->v_mount);
|
||||
if (dqvplocked)
|
||||
vput(dqvp);
|
||||
else
|
||||
vrele(dqvp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (EUSERS);
|
||||
}
|
||||
if (dq->dq_cnt || (dq->dq_flags & DQ_MOD))
|
||||
@ -1398,7 +1386,6 @@ hfound: DQI_LOCK(dq);
|
||||
auio.uio_rw = UIO_READ;
|
||||
auio.uio_td = (struct thread *)0;
|
||||
|
||||
vfslocked = VFS_LOCK_GIANT(dqvp->v_mount);
|
||||
error = VOP_READ(dqvp, &auio, 0, ump->um_cred[type]);
|
||||
if (auio.uio_resid == recsize && error == 0) {
|
||||
bzero(&dq->dq_dqb, sizeof(dq->dq_dqb));
|
||||
@ -1412,7 +1399,6 @@ hfound: DQI_LOCK(dq);
|
||||
vput(dqvp);
|
||||
else
|
||||
vrele(dqvp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
/*
|
||||
* I/O error in reading quota file, release
|
||||
* quota structure and reflect problem to caller.
|
||||
@ -1525,7 +1511,7 @@ dqsync(struct vnode *vp, struct dquot *dq)
|
||||
struct vnode *dqvp;
|
||||
struct iovec aiov;
|
||||
struct uio auio;
|
||||
int vfslocked, error;
|
||||
int error;
|
||||
struct mount *mp;
|
||||
struct ufsmount *ump;
|
||||
|
||||
@ -1546,12 +1532,10 @@ dqsync(struct vnode *vp, struct dquot *dq)
|
||||
vref(dqvp);
|
||||
UFS_UNLOCK(ump);
|
||||
|
||||
vfslocked = VFS_LOCK_GIANT(dqvp->v_mount);
|
||||
DQI_LOCK(dq);
|
||||
if ((dq->dq_flags & DQ_MOD) == 0) {
|
||||
DQI_UNLOCK(dq);
|
||||
vrele(dqvp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (0);
|
||||
}
|
||||
DQI_UNLOCK(dq);
|
||||
@ -1560,7 +1544,6 @@ dqsync(struct vnode *vp, struct dquot *dq)
|
||||
if (vp != dqvp)
|
||||
vn_lock(dqvp, LK_EXCLUSIVE | LK_RETRY);
|
||||
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
DQI_LOCK(dq);
|
||||
DQI_WAIT(dq, PINOD+2, "dqsync");
|
||||
if ((dq->dq_flags & DQ_MOD) == 0)
|
||||
@ -1591,9 +1574,7 @@ dqsync(struct vnode *vp, struct dquot *dq)
|
||||
auio.uio_segflg = UIO_SYSSPACE;
|
||||
auio.uio_rw = UIO_WRITE;
|
||||
auio.uio_td = (struct thread *)0;
|
||||
vfslocked = VFS_LOCK_GIANT(dqvp->v_mount);
|
||||
error = VOP_WRITE(dqvp, &auio, 0, dq->dq_ump->um_cred[dq->dq_type]);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
if (auio.uio_resid && error == 0)
|
||||
error = EIO;
|
||||
|
||||
@ -1602,13 +1583,11 @@ dqsync(struct vnode *vp, struct dquot *dq)
|
||||
dq->dq_flags &= ~DQ_MOD;
|
||||
out:
|
||||
DQI_UNLOCK(dq);
|
||||
vfslocked = VFS_LOCK_GIANT(dqvp->v_mount);
|
||||
if (vp != dqvp)
|
||||
vput(dqvp);
|
||||
else
|
||||
vrele(dqvp);
|
||||
vn_finished_secondary_write(mp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -102,8 +102,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <vm/vm_pager.h>
|
||||
#include <vm/vm_extern.h>
|
||||
|
||||
#include <sys/mount.h> /* XXX Temporary for VFS_LOCK_GIANT() */
|
||||
|
||||
#define PFBAK 4
|
||||
#define PFFOR 4
|
||||
#define PAGEORDER_SIZE (PFBAK+PFFOR)
|
||||
@ -135,7 +133,6 @@ struct faultstate {
|
||||
vm_map_entry_t entry;
|
||||
int lookup_still_valid;
|
||||
struct vnode *vp;
|
||||
int vfslocked;
|
||||
};
|
||||
|
||||
static void vm_fault_cache_behind(const struct faultstate *fs, int distance);
|
||||
@ -182,8 +179,6 @@ unlock_and_deallocate(struct faultstate *fs)
|
||||
vput(fs->vp);
|
||||
fs->vp = NULL;
|
||||
}
|
||||
VFS_UNLOCK_GIANT(fs->vfslocked);
|
||||
fs->vfslocked = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -255,7 +250,6 @@ vm_fault_hold(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type,
|
||||
growstack = TRUE;
|
||||
PCPU_INC(cnt.v_vm_faults);
|
||||
fs.vp = NULL;
|
||||
fs.vfslocked = 0;
|
||||
faultcount = reqpage = 0;
|
||||
|
||||
RetryFault:;
|
||||
@ -513,7 +507,6 @@ RetryFault:;
|
||||
*/
|
||||
unlock_map(&fs);
|
||||
|
||||
vnode_lock:
|
||||
if (fs.object->type == OBJT_VNODE) {
|
||||
vp = fs.object->handle;
|
||||
if (vp == fs.vp)
|
||||
@ -524,25 +517,12 @@ RetryFault:;
|
||||
}
|
||||
locked = VOP_ISLOCKED(vp);
|
||||
|
||||
if (VFS_NEEDSGIANT(vp->v_mount) && !fs.vfslocked) {
|
||||
fs.vfslocked = 1;
|
||||
if (!mtx_trylock(&Giant)) {
|
||||
VM_OBJECT_UNLOCK(fs.object);
|
||||
mtx_lock(&Giant);
|
||||
VM_OBJECT_LOCK(fs.object);
|
||||
goto vnode_lock;
|
||||
}
|
||||
}
|
||||
if (locked != LK_EXCLUSIVE)
|
||||
locked = LK_SHARED;
|
||||
/* Do not sleep for vnode lock while fs.m is busy */
|
||||
error = vget(vp, locked | LK_CANRECURSE |
|
||||
LK_NOWAIT, curthread);
|
||||
if (error != 0) {
|
||||
int vfslocked;
|
||||
|
||||
vfslocked = fs.vfslocked;
|
||||
fs.vfslocked = 0; /* Keep Giant */
|
||||
vhold(vp);
|
||||
release_page(&fs);
|
||||
unlock_and_deallocate(&fs);
|
||||
@ -550,7 +530,6 @@ RetryFault:;
|
||||
LK_CANRECURSE, curthread);
|
||||
vdrop(vp);
|
||||
fs.vp = vp;
|
||||
fs.vfslocked = vfslocked;
|
||||
KASSERT(error == 0,
|
||||
("vm_fault: vget failed"));
|
||||
goto RetryFault;
|
||||
|
@ -1256,7 +1256,7 @@ vm_mmap_vnode(struct thread *td, vm_size_t objsize,
|
||||
vm_offset_t foff;
|
||||
struct mount *mp;
|
||||
struct ucred *cred;
|
||||
int error, flags, locktype, vfslocked;
|
||||
int error, flags, locktype;
|
||||
|
||||
mp = vp->v_mount;
|
||||
cred = td->td_ucred;
|
||||
@ -1264,11 +1264,8 @@ vm_mmap_vnode(struct thread *td, vm_size_t objsize,
|
||||
locktype = LK_EXCLUSIVE;
|
||||
else
|
||||
locktype = LK_SHARED;
|
||||
vfslocked = VFS_LOCK_GIANT(mp);
|
||||
if ((error = vget(vp, locktype, td)) != 0) {
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
if ((error = vget(vp, locktype, td)) != 0)
|
||||
return (error);
|
||||
}
|
||||
foff = *foffp;
|
||||
flags = *flagsp;
|
||||
obj = vp->v_object;
|
||||
@ -1288,10 +1285,8 @@ vm_mmap_vnode(struct thread *td, vm_size_t objsize,
|
||||
* underlying fs.
|
||||
*/
|
||||
error = vget(vp, locktype, td);
|
||||
if (error != 0) {
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
}
|
||||
}
|
||||
if (locktype == LK_EXCLUSIVE) {
|
||||
*writecounted = TRUE;
|
||||
@ -1344,7 +1339,6 @@ vm_mmap_vnode(struct thread *td, vm_size_t objsize,
|
||||
|
||||
done:
|
||||
vput(vp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -427,7 +427,6 @@ vm_object_vndeallocate(vm_object_t object)
|
||||
{
|
||||
struct vnode *vp = (struct vnode *) object->handle;
|
||||
|
||||
VFS_ASSERT_GIANT(vp->v_mount);
|
||||
VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
|
||||
KASSERT(object->type == OBJT_VNODE,
|
||||
("vm_object_vndeallocate: not a vnode object"));
|
||||
@ -480,38 +479,11 @@ vm_object_deallocate(vm_object_t object)
|
||||
vm_object_t temp;
|
||||
|
||||
while (object != NULL) {
|
||||
int vfslocked;
|
||||
|
||||
vfslocked = 0;
|
||||
restart:
|
||||
VM_OBJECT_LOCK(object);
|
||||
if (object->type == OBJT_VNODE) {
|
||||
struct vnode *vp = (struct vnode *) object->handle;
|
||||
|
||||
/*
|
||||
* Conditionally acquire Giant for a vnode-backed
|
||||
* object. We have to be careful since the type of
|
||||
* a vnode object can change while the object is
|
||||
* unlocked.
|
||||
*/
|
||||
if (VFS_NEEDSGIANT(vp->v_mount) && !vfslocked) {
|
||||
vfslocked = 1;
|
||||
if (!mtx_trylock(&Giant)) {
|
||||
VM_OBJECT_UNLOCK(object);
|
||||
mtx_lock(&Giant);
|
||||
goto restart;
|
||||
}
|
||||
}
|
||||
vm_object_vndeallocate(object);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
return;
|
||||
} else
|
||||
/*
|
||||
* This is to handle the case that the object
|
||||
* changed type while we dropped its lock to
|
||||
* obtain Giant.
|
||||
*/
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
}
|
||||
|
||||
KASSERT(object->ref_count != 0,
|
||||
("vm_object_deallocate: object deallocated too many times: %d", object->type));
|
||||
@ -987,11 +959,9 @@ vm_object_sync(vm_object_t object, vm_ooffset_t offset, vm_size_t size,
|
||||
*/
|
||||
if (object->type == OBJT_VNODE &&
|
||||
(object->flags & OBJ_MIGHTBEDIRTY) != 0) {
|
||||
int vfslocked;
|
||||
vp = object->handle;
|
||||
VM_OBJECT_UNLOCK(object);
|
||||
(void) vn_start_write(vp, &mp, V_WAIT);
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
if (syncio && !invalidate && offset == 0 &&
|
||||
OFF_TO_IDX(size) == object->size) {
|
||||
@ -1015,7 +985,6 @@ vm_object_sync(vm_object_t object, vm_ooffset_t offset, vm_size_t size,
|
||||
if (fsync_after)
|
||||
error = VOP_FSYNC(vp, MNT_WAIT, curthread);
|
||||
VOP_UNLOCK(vp, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
vn_finished_write(mp);
|
||||
if (error != 0)
|
||||
res = FALSE;
|
||||
|
@ -569,7 +569,6 @@ vm_pageout_launder(int queue, int tries, vm_paddr_t low, vm_paddr_t high)
|
||||
vm_object_t object;
|
||||
vm_paddr_t pa;
|
||||
vm_page_t m, m_tmp, next;
|
||||
int vfslocked;
|
||||
|
||||
vm_page_lock_queues();
|
||||
TAILQ_FOREACH_SAFE(m, &vm_page_queues[queue].pl, pageq, next) {
|
||||
@ -609,13 +608,11 @@ vm_pageout_launder(int queue, int tries, vm_paddr_t low, vm_paddr_t high)
|
||||
vm_object_reference_locked(object);
|
||||
VM_OBJECT_UNLOCK(object);
|
||||
(void)vn_start_write(vp, &mp, V_WAIT);
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
VM_OBJECT_LOCK(object);
|
||||
vm_object_page_clean(object, 0, 0, OBJPC_SYNC);
|
||||
VM_OBJECT_UNLOCK(object);
|
||||
VOP_UNLOCK(vp, 0);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
vm_object_deallocate(object);
|
||||
vn_finished_write(mp);
|
||||
return (TRUE);
|
||||
@ -1127,7 +1124,7 @@ vm_pageout_scan(int pass)
|
||||
* pressure where there are insufficient clean pages
|
||||
* on the inactive queue, we may have to go all out.
|
||||
*/
|
||||
int swap_pageouts_ok, vfslocked = 0;
|
||||
int swap_pageouts_ok;
|
||||
struct vnode *vp = NULL;
|
||||
struct mount *mp = NULL;
|
||||
|
||||
@ -1191,7 +1188,6 @@ vm_pageout_scan(int pass)
|
||||
("vp %p with NULL v_mount", vp));
|
||||
vm_object_reference_locked(object);
|
||||
VM_OBJECT_UNLOCK(object);
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
if (vget(vp, LK_EXCLUSIVE | LK_TIMELOCK,
|
||||
curthread)) {
|
||||
VM_OBJECT_LOCK(object);
|
||||
@ -1270,7 +1266,6 @@ vm_pageout_scan(int pass)
|
||||
}
|
||||
if (vp != NULL)
|
||||
vput(vp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
vm_object_deallocate(object);
|
||||
vn_finished_write(mp);
|
||||
}
|
||||
|
@ -298,7 +298,6 @@ vnode_pager_haspage(object, pindex, before, after)
|
||||
int poff;
|
||||
int bsize;
|
||||
int pagesperblock, blocksperpage;
|
||||
int vfslocked;
|
||||
|
||||
VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
|
||||
/*
|
||||
@ -324,9 +323,7 @@ vnode_pager_haspage(object, pindex, before, after)
|
||||
reqblock = pindex * blocksperpage;
|
||||
}
|
||||
VM_OBJECT_UNLOCK(object);
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
err = VOP_BMAP(vp, reqblock, NULL, &bn, after, before);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
VM_OBJECT_LOCK(object);
|
||||
if (err)
|
||||
return TRUE;
|
||||
@ -670,15 +667,12 @@ vnode_pager_getpages(object, m, count, reqpage)
|
||||
int rtval;
|
||||
struct vnode *vp;
|
||||
int bytes = count * PAGE_SIZE;
|
||||
int vfslocked;
|
||||
|
||||
vp = object->handle;
|
||||
VM_OBJECT_UNLOCK(object);
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
rtval = VOP_GETPAGES(vp, m, bytes, reqpage, 0);
|
||||
KASSERT(rtval != EOPNOTSUPP,
|
||||
("vnode_pager: FS getpages not implemented\n"));
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
VM_OBJECT_LOCK(object);
|
||||
return rtval;
|
||||
}
|
||||
@ -1237,7 +1231,6 @@ vnode_pager_release_writecount(vm_object_t object, vm_offset_t start,
|
||||
struct vnode *vp;
|
||||
struct mount *mp;
|
||||
vm_offset_t inc;
|
||||
int vfslocked;
|
||||
|
||||
VM_OBJECT_LOCK(object);
|
||||
|
||||
@ -1264,7 +1257,6 @@ vnode_pager_release_writecount(vm_object_t object, vm_offset_t start,
|
||||
vp = object->handle;
|
||||
vhold(vp);
|
||||
VM_OBJECT_UNLOCK(object);
|
||||
vfslocked = VFS_LOCK_GIANT(vp->v_mount);
|
||||
mp = NULL;
|
||||
vn_start_write(vp, &mp, V_WAIT);
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
@ -1280,5 +1272,4 @@ vnode_pager_release_writecount(vm_object_t object, vm_offset_t start,
|
||||
vdrop(vp);
|
||||
if (mp != NULL)
|
||||
vn_finished_write(mp);
|
||||
VFS_UNLOCK_GIANT(vfslocked);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user