diff options
Diffstat (limited to 'sys/kern/vfs_syscalls.c')
-rw-r--r-- | sys/kern/vfs_syscalls.c | 277 |
1 files changed, 47 insertions, 230 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index a1b26ce83808..4abd503f9e2c 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -134,7 +134,7 @@ sys_sync(td, uap) struct sync_args *uap; { struct mount *mp, *nmp; - int save, vfslocked; + int save; mtx_lock(&mountlist_mtx); for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { @@ -142,7 +142,6 @@ sys_sync(td, uap) nmp = TAILQ_NEXT(mp, mnt_list); continue; } - vfslocked = VFS_LOCK_GIANT(mp); if ((mp->mnt_flag & MNT_RDONLY) == 0 && vn_start_write(NULL, &mp, V_NOWAIT) == 0) { save = curthread_pflags_set(TDP_SYNCIO); @@ -151,7 +150,6 @@ sys_sync(td, uap) curthread_pflags_restore(save); vn_finished_write(mp); } - VFS_UNLOCK_GIANT(vfslocked); mtx_lock(&mountlist_mtx); nmp = TAILQ_NEXT(mp, mnt_list); vfs_unbusy(mp); @@ -182,7 +180,6 @@ sys_quotactl(td, uap) } */ *uap; { struct mount *mp; - int vfslocked; int error; struct nameidata nd; @@ -190,21 +187,18 @@ sys_quotactl(td, uap) AUDIT_ARG_UID(uap->uid); if (!prison_allow(td->td_ucred, PR_ALLOW_QUOTAS)) return (EPERM); - NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1, + NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1, UIO_USERSPACE, uap->path, td); if ((error = namei(&nd)) != 0) return (error); - vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); mp = nd.ni_vp->v_mount; vfs_ref(mp); vput(nd.ni_vp); error = vfs_busy(mp, 0); vfs_rel(mp); - if (error) { - VFS_UNLOCK_GIANT(vfslocked); + if (error) return (error); - } error = VFS_QUOTACTL(mp, uap->cmd, uap->uid, uap->arg); /* @@ -220,7 +214,6 @@ sys_quotactl(td, uap) */ if ((uap->cmd >> SUBCMDSHIFT) != Q_QUOTAON) vfs_unbusy(mp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -297,26 +290,22 @@ kern_statfs(struct thread *td, char *path, enum uio_seg pathseg, { struct mount *mp; struct statfs *sp, sb; - int vfslocked; int error; struct nameidata nd; - NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | MPSAFE | + NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | AUDITVNODE1, pathseg, path, td); error = namei(&nd); if (error) return (error); - vfslocked = NDHASGIANT(&nd); mp = nd.ni_vp->v_mount; vfs_ref(mp); NDFREE(&nd, NDF_ONLY_PNBUF); vput(nd.ni_vp); error = vfs_busy(mp, 0); vfs_rel(mp); - if (error) { - VFS_UNLOCK_GIANT(vfslocked); + if (error) return (error); - } #ifdef MAC error = mac_mount_check_stat(td->td_ucred, mp); if (error) @@ -341,7 +330,6 @@ kern_statfs(struct thread *td, char *path, enum uio_seg pathseg, *buf = *sp; out: vfs_unbusy(mp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -377,7 +365,6 @@ kern_fstatfs(struct thread *td, int fd, struct statfs *buf) struct file *fp; struct mount *mp; struct statfs *sp, sb; - int vfslocked; struct vnode *vp; int error; @@ -386,7 +373,6 @@ kern_fstatfs(struct thread *td, int fd, struct statfs *buf) if (error) return (error); vp = fp->f_vnode; - vfslocked = VFS_LOCK_GIANT(vp->v_mount); vn_lock(vp, LK_SHARED | LK_RETRY); #ifdef AUDIT AUDIT_ARG_VNODE1(vp); @@ -402,10 +388,8 @@ kern_fstatfs(struct thread *td, int fd, struct statfs *buf) } error = vfs_busy(mp, 0); vfs_rel(mp); - if (error) { - VFS_UNLOCK_GIANT(vfslocked); + if (error) return (error); - } #ifdef MAC error = mac_mount_check_stat(td->td_ucred, mp); if (error) @@ -431,7 +415,6 @@ kern_fstatfs(struct thread *td, int fd, struct statfs *buf) out: if (mp) vfs_unbusy(mp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -471,7 +454,6 @@ kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize, struct mount *mp, *nmp; struct statfs *sfsp, *sp, sb; size_t count, maxcount; - int vfslocked; int error; maxcount = bufsize / sizeof(struct statfs); @@ -508,7 +490,6 @@ kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize, nmp = TAILQ_NEXT(mp, mnt_list); continue; } - vfslocked = VFS_LOCK_GIANT(mp); if (sfsp && count < maxcount) { sp = &mp->mnt_stat; /* @@ -526,7 +507,6 @@ kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize, if (((flags & (MNT_LAZY|MNT_NOWAIT)) == 0 || (flags & MNT_WAIT)) && (error = VFS_STATFS(mp, sp))) { - VFS_UNLOCK_GIANT(vfslocked); mtx_lock(&mountlist_mtx); nmp = TAILQ_NEXT(mp, mnt_list); vfs_unbusy(mp); @@ -544,13 +524,11 @@ kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize, error = copyout(sp, sfsp, sizeof(*sp)); if (error) { vfs_unbusy(mp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } } sfsp++; } - VFS_UNLOCK_GIANT(vfslocked); count++; mtx_lock(&mountlist_mtx); nmp = TAILQ_NEXT(mp, mnt_list); @@ -751,7 +729,6 @@ sys_fchdir(td, uap) struct vnode *vp, *tdp, *vpold; struct mount *mp; struct file *fp; - int vfslocked; int error; AUDIT_ARG_FD(uap->fd); @@ -760,40 +737,29 @@ sys_fchdir(td, uap) vp = fp->f_vnode; VREF(vp); fdrop(fp, td); - vfslocked = VFS_LOCK_GIANT(vp->v_mount); vn_lock(vp, LK_SHARED | LK_RETRY); AUDIT_ARG_VNODE1(vp); error = change_dir(vp, td); while (!error && (mp = vp->v_mountedhere) != NULL) { - int tvfslocked; if (vfs_busy(mp, 0)) continue; - tvfslocked = VFS_LOCK_GIANT(mp); error = VFS_ROOT(mp, LK_SHARED, &tdp); vfs_unbusy(mp); - if (error) { - VFS_UNLOCK_GIANT(tvfslocked); + if (error) break; - } vput(vp); - VFS_UNLOCK_GIANT(vfslocked); vp = tdp; - vfslocked = tvfslocked; } if (error) { vput(vp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } VOP_UNLOCK(vp, 0); - VFS_UNLOCK_GIANT(vfslocked); FILEDESC_XLOCK(fdp); vpold = fdp->fd_cdir; fdp->fd_cdir = vp; FILEDESC_XUNLOCK(fdp); - vfslocked = VFS_LOCK_GIANT(vpold->v_mount); vrele(vpold); - VFS_UNLOCK_GIANT(vfslocked); return (0); } @@ -823,29 +789,23 @@ kern_chdir(struct thread *td, char *path, enum uio_seg pathseg) int error; struct nameidata nd; struct vnode *vp; - int vfslocked; - NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | AUDITVNODE1 | - MPSAFE, pathseg, path, td); + NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | AUDITVNODE1, + pathseg, path, td); if ((error = namei(&nd)) != 0) return (error); - vfslocked = NDHASGIANT(&nd); if ((error = change_dir(nd.ni_vp, td)) != 0) { vput(nd.ni_vp); - VFS_UNLOCK_GIANT(vfslocked); NDFREE(&nd, NDF_ONLY_PNBUF); return (error); } VOP_UNLOCK(nd.ni_vp, 0); - VFS_UNLOCK_GIANT(vfslocked); NDFREE(&nd, NDF_ONLY_PNBUF); FILEDESC_XLOCK(fdp); vp = fdp->fd_cdir; fdp->fd_cdir = nd.ni_vp; FILEDESC_XUNLOCK(fdp); - vfslocked = VFS_LOCK_GIANT(vp->v_mount); vrele(vp); - VFS_UNLOCK_GIANT(vfslocked); return (0); } @@ -907,17 +867,15 @@ sys_chroot(td, uap) { int error; struct nameidata nd; - int vfslocked; error = priv_check(td, PRIV_VFS_CHROOT); if (error) return (error); - NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | MPSAFE | + NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | AUDITVNODE1, UIO_USERSPACE, uap->path, td); error = namei(&nd); if (error) goto error; - vfslocked = NDHASGIANT(&nd); if ((error = change_dir(nd.ni_vp, td)) != 0) goto e_vunlock; #ifdef MAC @@ -927,12 +885,10 @@ sys_chroot(td, uap) VOP_UNLOCK(nd.ni_vp, 0); error = change_root(nd.ni_vp, td); vrele(nd.ni_vp); - VFS_UNLOCK_GIANT(vfslocked); NDFREE(&nd, NDF_ONLY_PNBUF); return (error); e_vunlock: vput(nd.ni_vp); - VFS_UNLOCK_GIANT(vfslocked); error: NDFREE(&nd, NDF_ONLY_PNBUF); return (error); @@ -973,10 +929,8 @@ change_root(vp, td) { struct filedesc *fdp; struct vnode *oldvp; - int vfslocked; int error; - VFS_ASSERT_GIANT(vp->v_mount); fdp = td->td_proc->p_fd; FILEDESC_XLOCK(fdp); if (chroot_allow_open_directories == 0 || @@ -995,9 +949,7 @@ change_root(vp, td) VREF(fdp->fd_jdir); } FILEDESC_XUNLOCK(fdp); - vfslocked = VFS_LOCK_GIANT(oldvp->v_mount); vrele(oldvp); - VFS_UNLOCK_GIANT(vfslocked); return (0); } @@ -1093,7 +1045,6 @@ kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg, int cmode; int indx = -1, error; struct nameidata nd; - int vfslocked; cap_rights_t rights_needed = CAP_LOOKUP; AUDIT_ARG_FFLAGS(flags); @@ -1126,7 +1077,7 @@ kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg, /* Set the flags early so the finit in devfs can pick them up. */ fp->f_flag = flags & FMASK; cmode = ((mode &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT; - NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | AUDITVNODE1 | MPSAFE, pathseg, + NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | AUDITVNODE1, pathseg, path, fd, rights_needed, td); td->td_dupfd = -1; /* XXX check for fdopen */ error = vn_open(&nd, &flags, cmode, fp); @@ -1160,7 +1111,6 @@ kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg, goto bad_unlocked; } td->td_dupfd = 0; - vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); vp = nd.ni_vp; @@ -1187,7 +1137,6 @@ kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg, if (error) goto bad; } - VFS_UNLOCK_GIANT(vfslocked); success: /* * If we haven't already installed the FD (for dupfdopen), do so now. @@ -1217,7 +1166,6 @@ success: td->td_retval[0] = indx; return (0); bad: - VFS_UNLOCK_GIANT(vfslocked); bad_unlocked: KASSERT(indx == -1, ("indx=%d, should be -1", indx)); fdrop(fp, td); @@ -1305,7 +1253,6 @@ kern_mknodat(struct thread *td, int fd, char *path, enum uio_seg pathseg, int error; int whiteout = 0; struct nameidata nd; - int vfslocked; AUDIT_ARG_MODE(mode); AUDIT_ARG_DEV(dev); @@ -1333,11 +1280,10 @@ kern_mknodat(struct thread *td, int fd, char *path, enum uio_seg pathseg, restart: bwillwrite(); NDINIT_ATRIGHTS(&nd, CREATE, - LOCKPARENT | SAVENAME | MPSAFE | AUDITVNODE1, pathseg, path, fd, + LOCKPARENT | SAVENAME | AUDITVNODE1, pathseg, path, fd, CAP_MKNOD, td); if ((error = namei(&nd)) != 0) return (error); - vfslocked = NDHASGIANT(&nd); vp = nd.ni_vp; if (vp != NULL) { NDFREE(&nd, NDF_ONLY_PNBUF); @@ -1346,7 +1292,6 @@ restart: else vput(nd.ni_dvp); vrele(vp); - VFS_UNLOCK_GIANT(vfslocked); return (EEXIST); } else { VATTR_NULL(&vattr); @@ -1375,7 +1320,6 @@ restart: if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) { NDFREE(&nd, NDF_ONLY_PNBUF); vput(nd.ni_dvp); - VFS_UNLOCK_GIANT(vfslocked); if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0) return (error); goto restart; @@ -1398,7 +1342,6 @@ restart: NDFREE(&nd, NDF_ONLY_PNBUF); vput(nd.ni_dvp); vn_finished_write(mp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -1453,17 +1396,15 @@ kern_mkfifoat(struct thread *td, int fd, char *path, enum uio_seg pathseg, struct vattr vattr; int error; struct nameidata nd; - int vfslocked; AUDIT_ARG_MODE(mode); restart: bwillwrite(); NDINIT_ATRIGHTS(&nd, CREATE, - LOCKPARENT | SAVENAME | MPSAFE | AUDITVNODE1, pathseg, path, fd, + LOCKPARENT | SAVENAME | AUDITVNODE1, pathseg, path, fd, CAP_MKFIFO, td); if ((error = namei(&nd)) != 0) return (error); - vfslocked = NDHASGIANT(&nd); if (nd.ni_vp != NULL) { NDFREE(&nd, NDF_ONLY_PNBUF); if (nd.ni_vp == nd.ni_dvp) @@ -1471,13 +1412,11 @@ restart: else vput(nd.ni_dvp); vrele(nd.ni_vp); - VFS_UNLOCK_GIANT(vfslocked); return (EEXIST); } if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) { NDFREE(&nd, NDF_ONLY_PNBUF); vput(nd.ni_dvp); - VFS_UNLOCK_GIANT(vfslocked); if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0) return (error); goto restart; @@ -1499,7 +1438,6 @@ out: #endif vput(nd.ni_dvp); vn_finished_write(mp); - VFS_UNLOCK_GIANT(vfslocked); NDFREE(&nd, NDF_ONLY_PNBUF); return (error); } @@ -1600,33 +1538,27 @@ kern_linkat(struct thread *td, int fd1, int fd2, char *path1, char *path2, struct vnode *vp; struct mount *mp; struct nameidata nd; - int vfslocked; - int lvfslocked; int error; bwillwrite(); - NDINIT_AT(&nd, LOOKUP, follow | MPSAFE | AUDITVNODE1, segflg, path1, + NDINIT_AT(&nd, LOOKUP, follow | AUDITVNODE1, segflg, path1, fd1, td); if ((error = namei(&nd)) != 0) return (error); - vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); vp = nd.ni_vp; if (vp->v_type == VDIR) { vrele(vp); - VFS_UNLOCK_GIANT(vfslocked); return (EPERM); /* POSIX */ } if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) { vrele(vp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } - NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | MPSAFE | + NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | AUDITVNODE2, segflg, path2, fd2, CAP_CREATE, td); if ((error = namei(&nd)) == 0) { - lvfslocked = NDHASGIANT(&nd); if (nd.ni_vp != NULL) { if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); @@ -1648,11 +1580,9 @@ kern_linkat(struct thread *td, int fd1, int fd2, char *path1, char *path2, vput(nd.ni_dvp); } NDFREE(&nd, NDF_ONLY_PNBUF); - VFS_UNLOCK_GIANT(lvfslocked); } vrele(vp); vn_finished_write(mp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -1708,7 +1638,6 @@ kern_symlinkat(struct thread *td, char *path1, int fd, char *path2, char *syspath; int error; struct nameidata nd; - int vfslocked; if (segflg == UIO_SYSSPACE) { syspath = path1; @@ -1720,11 +1649,10 @@ kern_symlinkat(struct thread *td, char *path1, int fd, char *path2, AUDIT_ARG_TEXT(syspath); restart: bwillwrite(); - NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | MPSAFE | + NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | AUDITVNODE1, segflg, path2, fd, CAP_CREATE, td); if ((error = namei(&nd)) != 0) goto out; - vfslocked = NDHASGIANT(&nd); if (nd.ni_vp) { NDFREE(&nd, NDF_ONLY_PNBUF); if (nd.ni_vp == nd.ni_dvp) @@ -1732,14 +1660,12 @@ restart: else vput(nd.ni_dvp); vrele(nd.ni_vp); - VFS_UNLOCK_GIANT(vfslocked); error = EEXIST; goto out; } if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) { NDFREE(&nd, NDF_ONLY_PNBUF); vput(nd.ni_dvp); - VFS_UNLOCK_GIANT(vfslocked); if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0) goto out; goto restart; @@ -1762,7 +1688,6 @@ out2: NDFREE(&nd, NDF_ONLY_PNBUF); vput(nd.ni_dvp); vn_finished_write(mp); - VFS_UNLOCK_GIANT(vfslocked); out: if (segflg != UIO_SYSSPACE) uma_zfree(namei_zone, syspath); @@ -1782,16 +1707,14 @@ sys_undelete(td, uap) int error; struct mount *mp; struct nameidata nd; - int vfslocked; restart: bwillwrite(); - NDINIT(&nd, DELETE, LOCKPARENT | DOWHITEOUT | MPSAFE | AUDITVNODE1, + NDINIT(&nd, DELETE, LOCKPARENT | DOWHITEOUT | AUDITVNODE1, UIO_USERSPACE, uap->path, td); error = namei(&nd); if (error) return (error); - vfslocked = NDHASGIANT(&nd); if (nd.ni_vp != NULLVP || !(nd.ni_cnd.cn_flags & ISWHITEOUT)) { NDFREE(&nd, NDF_ONLY_PNBUF); @@ -1801,13 +1724,11 @@ restart: vput(nd.ni_dvp); if (nd.ni_vp) vrele(nd.ni_vp); - VFS_UNLOCK_GIANT(vfslocked); return (EEXIST); } if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) { NDFREE(&nd, NDF_ONLY_PNBUF); vput(nd.ni_dvp); - VFS_UNLOCK_GIANT(vfslocked); if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0) return (error); goto restart; @@ -1816,7 +1737,6 @@ restart: NDFREE(&nd, NDF_ONLY_PNBUF); vput(nd.ni_dvp); vn_finished_write(mp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -1878,15 +1798,13 @@ kern_unlinkat(struct thread *td, int fd, char *path, enum uio_seg pathseg, int error; struct nameidata nd; struct stat sb; - int vfslocked; restart: bwillwrite(); - NDINIT_ATRIGHTS(&nd, DELETE, LOCKPARENT | LOCKLEAF | MPSAFE | + NDINIT_ATRIGHTS(&nd, DELETE, LOCKPARENT | LOCKLEAF | AUDITVNODE1, pathseg, path, fd, CAP_DELETE, td); if ((error = namei(&nd)) != 0) return (error == EINVAL ? EPERM : error); - vfslocked = NDHASGIANT(&nd); vp = nd.ni_vp; if (vp->v_type == VDIR && oldinum == 0) { error = EPERM; /* POSIX */ @@ -1911,7 +1829,6 @@ restart: vrele(vp); else vput(vp); - VFS_UNLOCK_GIANT(vfslocked); if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0) return (error); @@ -1935,7 +1852,6 @@ out: vrele(vp); else vput(vp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -1966,7 +1882,6 @@ sys_lseek(td, uap) struct vattr vattr; off_t foffset, offset, size; int error, noneg; - int vfslocked; AUDIT_ARG_FD(uap->fd); if ((error = fget(td, uap->fd, CAP_SEEK, &fp)) != 0) @@ -1977,7 +1892,6 @@ sys_lseek(td, uap) } vp = fp->f_vnode; foffset = foffset_lock(fp, 0); - vfslocked = VFS_LOCK_GIANT(vp->v_mount); noneg = (vp->v_type != VCHR); offset = uap->offset; switch (uap->whence) { @@ -2032,7 +1946,6 @@ sys_lseek(td, uap) *(off_t *)(td->td_retval) = offset; drop: fdrop(fp, td); - VFS_UNLOCK_GIANT(vfslocked); foffset_unlock(fp, offset, error != 0 ? FOF_NOUPDATE : 0); return (error); } @@ -2172,7 +2085,6 @@ kern_accessat(struct thread *td, int fd, char *path, enum uio_seg pathseg, struct ucred *cred, *tmpcred; struct vnode *vp; struct nameidata nd; - int vfslocked; int error; /* @@ -2188,17 +2100,15 @@ kern_accessat(struct thread *td, int fd, char *path, enum uio_seg pathseg, } else cred = tmpcred = td->td_ucred; AUDIT_ARG_VALUE(amode); - NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | MPSAFE | + NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | AUDITVNODE1, pathseg, path, fd, CAP_FSTAT, td); if ((error = namei(&nd)) != 0) goto out1; - vfslocked = NDHASGIANT(&nd); vp = nd.ni_vp; error = vn_access(vp, amode, tmpcred, td); NDFREE(&nd, NDF_ONLY_PNBUF); vput(vp); - VFS_UNLOCK_GIANT(vfslocked); out1: if (!(flag & AT_EACCESS)) { td->td_ucred = cred; @@ -2393,18 +2303,17 @@ kern_statat_vnhook(struct thread *td, int flag, int fd, char *path, { struct nameidata nd; struct stat sb; - int error, vfslocked; + int error; if (flag & ~AT_SYMLINK_NOFOLLOW) return (EINVAL); NDINIT_ATRIGHTS(&nd, LOOKUP, ((flag & AT_SYMLINK_NOFOLLOW) ? NOFOLLOW : - FOLLOW) | LOCKSHARED | LOCKLEAF | AUDITVNODE1 | MPSAFE, pathseg, + FOLLOW) | LOCKSHARED | LOCKLEAF | AUDITVNODE1, pathseg, path, fd, CAP_FSTAT, td); if ((error = namei(&nd)) != 0) return (error); - vfslocked = NDHASGIANT(&nd); error = vn_stat(nd.ni_vp, &sb, td->td_ucred, NOCRED, td); if (!error) { SDT_PROBE(vfs, , stat, mode, path, sb.st_mode, 0, 0, 0); @@ -2415,7 +2324,6 @@ kern_statat_vnhook(struct thread *td, int flag, int fd, char *path, } NDFREE(&nd, NDF_ONLY_PNBUF); vput(nd.ni_vp); - VFS_UNLOCK_GIANT(vfslocked); if (error) return (error); *sbp = sb; @@ -2586,13 +2494,12 @@ kern_pathconf(struct thread *td, char *path, enum uio_seg pathseg, int name, u_long flags) { struct nameidata nd; - int error, vfslocked; + int error; - NDINIT(&nd, LOOKUP, LOCKSHARED | LOCKLEAF | MPSAFE | AUDITVNODE1 | - flags, pathseg, path, td); + NDINIT(&nd, LOOKUP, LOCKSHARED | LOCKLEAF | AUDITVNODE1 | flags, + pathseg, path, td); if ((error = namei(&nd)) != 0) return (error); - vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); /* If asynchronous I/O is available, it works for all files. */ @@ -2601,7 +2508,6 @@ kern_pathconf(struct thread *td, char *path, enum uio_seg pathseg, int name, else error = VOP_PATHCONF(nd.ni_vp, name, td->td_retval); vput(nd.ni_vp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -2662,24 +2568,21 @@ kern_readlinkat(struct thread *td, int fd, char *path, enum uio_seg pathseg, struct uio auio; int error; struct nameidata nd; - int vfslocked; if (count > IOSIZE_MAX) return (EINVAL); - NDINIT_AT(&nd, LOOKUP, NOFOLLOW | LOCKSHARED | LOCKLEAF | MPSAFE | + NDINIT_AT(&nd, LOOKUP, NOFOLLOW | LOCKSHARED | LOCKLEAF | AUDITVNODE1, pathseg, path, fd, td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - vfslocked = NDHASGIANT(&nd); vp = nd.ni_vp; #ifdef MAC error = mac_vnode_check_readlink(td->td_ucred, vp); if (error) { vput(vp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } #endif @@ -2698,7 +2601,6 @@ kern_readlinkat(struct thread *td, int fd, char *path, enum uio_seg pathseg, error = VOP_READLINK(vp, &auio, td->td_ucred); } vput(vp); - VFS_UNLOCK_GIANT(vfslocked); td->td_retval[0] = count - auio.uio_resid; return (error); } @@ -2766,18 +2668,15 @@ sys_chflags(td, uap) { int error; struct nameidata nd; - int vfslocked; AUDIT_ARG_FFLAGS(uap->flags); - NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE | AUDITVNODE1, UIO_USERSPACE, + NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->path, td); if ((error = namei(&nd)) != 0) return (error); NDFREE(&nd, NDF_ONLY_PNBUF); - vfslocked = NDHASGIANT(&nd); error = setfflags(td, nd.ni_vp, uap->flags); vrele(nd.ni_vp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -2794,18 +2693,15 @@ sys_lchflags(td, uap) { int error; struct nameidata nd; - int vfslocked; AUDIT_ARG_FFLAGS(uap->flags); - NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE | AUDITVNODE1, UIO_USERSPACE, + NDINIT(&nd, LOOKUP, NOFOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->path, td); if ((error = namei(&nd)) != 0) return (error); - vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); error = setfflags(td, nd.ni_vp, uap->flags); vrele(nd.ni_vp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -2827,7 +2723,6 @@ sys_fchflags(td, uap) } */ *uap; { struct file *fp; - int vfslocked; int error; AUDIT_ARG_FD(uap->fd); @@ -2835,14 +2730,12 @@ sys_fchflags(td, uap) if ((error = getvnode(td->td_proc->p_fd, uap->fd, CAP_FCHFLAGS, &fp)) != 0) return (error); - vfslocked = VFS_LOCK_GIANT(fp->f_vnode->v_mount); #ifdef AUDIT vn_lock(fp->f_vnode, LK_SHARED | LK_RETRY); AUDIT_ARG_VNODE1(fp->f_vnode); VOP_UNLOCK(fp->f_vnode, 0); #endif error = setfflags(td, fp->f_vnode, uap->flags); - VFS_UNLOCK_GIANT(vfslocked); fdrop(fp, td); return (error); } @@ -2955,20 +2848,17 @@ kern_fchmodat(struct thread *td, int fd, char *path, enum uio_seg pathseg, { int error; struct nameidata nd; - int vfslocked; int follow; AUDIT_ARG_MODE(mode); follow = (flag & AT_SYMLINK_NOFOLLOW) ? NOFOLLOW : FOLLOW; - NDINIT_ATRIGHTS(&nd, LOOKUP, follow | MPSAFE | AUDITVNODE1, pathseg, + NDINIT_ATRIGHTS(&nd, LOOKUP, follow | AUDITVNODE1, pathseg, path, fd, CAP_FCHMOD, td); if ((error = namei(&nd)) != 0) return (error); - vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); error = setfmode(td, td->td_ucred, nd.ni_vp, mode); vrele(nd.ni_vp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -3088,20 +2978,18 @@ kern_fchownat(struct thread *td, int fd, char *path, enum uio_seg pathseg, int uid, int gid, int flag) { struct nameidata nd; - int error, vfslocked, follow; + int error, follow; AUDIT_ARG_OWNER(uid, gid); follow = (flag & AT_SYMLINK_NOFOLLOW) ? NOFOLLOW : FOLLOW; - NDINIT_ATRIGHTS(&nd, LOOKUP, follow | MPSAFE | AUDITVNODE1, pathseg, + NDINIT_ATRIGHTS(&nd, LOOKUP, follow | AUDITVNODE1, pathseg, path, fd, CAP_FCHOWN, td); if ((error = namei(&nd)) != 0) return (error); - vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); error = setfown(td, td->td_ucred, nd.ni_vp, uid, gid); vrele(nd.ni_vp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -3296,20 +3184,18 @@ kern_utimesat(struct thread *td, int fd, char *path, enum uio_seg pathseg, { struct nameidata nd; struct timespec ts[2]; - int error, vfslocked; + int error; if ((error = getutimes(tptr, tptrseg, ts)) != 0) return (error); - NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | MPSAFE | AUDITVNODE1, pathseg, + NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | AUDITVNODE1, pathseg, path, fd, CAP_FUTIMES, td); if ((error = namei(&nd)) != 0) return (error); - vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); error = setutimes(td, nd.ni_vp, ts, 2, tptr == NULL); vrele(nd.ni_vp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -3342,18 +3228,15 @@ kern_lutimes(struct thread *td, char *path, enum uio_seg pathseg, struct timespec ts[2]; int error; struct nameidata nd; - int vfslocked; if ((error = getutimes(tptr, tptrseg, ts)) != 0) return (error); - NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE | AUDITVNODE1, pathseg, path, td); + NDINIT(&nd, LOOKUP, NOFOLLOW | AUDITVNODE1, pathseg, path, td); if ((error = namei(&nd)) != 0) return (error); - vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); error = setutimes(td, nd.ni_vp, ts, 2, tptr == NULL); vrele(nd.ni_vp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -3384,7 +3267,6 @@ kern_futimes(struct thread *td, int fd, struct timeval *tptr, { struct timespec ts[2]; struct file *fp; - int vfslocked; int error; AUDIT_ARG_FD(fd); @@ -3393,14 +3275,12 @@ kern_futimes(struct thread *td, int fd, struct timeval *tptr, if ((error = getvnode(td->td_proc->p_fd, fd, CAP_FUTIMES, &fp)) != 0) return (error); - vfslocked = VFS_LOCK_GIANT(fp->f_vnode->v_mount); #ifdef AUDIT vn_lock(fp->f_vnode, LK_SHARED | LK_RETRY); AUDIT_ARG_VNODE1(fp->f_vnode); VOP_UNLOCK(fp->f_vnode, 0); #endif error = setutimes(td, fp->f_vnode, ts, 2, tptr == NULL); - VFS_UNLOCK_GIANT(vfslocked); fdrop(fp, td); return (error); } @@ -3436,20 +3316,18 @@ kern_truncate(struct thread *td, char *path, enum uio_seg pathseg, off_t length) void *rl_cookie; struct vattr vattr; struct nameidata nd; - int error, vfslocked; + int error; if (length < 0) return(EINVAL); - NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE | AUDITVNODE1, pathseg, path, td); + NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, pathseg, path, td); if ((error = namei(&nd)) != 0) return (error); - vfslocked = NDHASGIANT(&nd); vp = nd.ni_vp; rl_cookie = vn_rangelock_wlock(vp, 0, OFF_MAX); if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) { vn_rangelock_unlock(vp, rl_cookie); vrele(vp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } NDFREE(&nd, NDF_ONLY_PNBUF); @@ -3470,7 +3348,6 @@ kern_truncate(struct thread *td, char *path, enum uio_seg pathseg, off_t length) vn_finished_write(mp); vn_rangelock_unlock(vp, rl_cookie); vrele(vp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -3543,7 +3420,6 @@ sys_fsync(td, uap) struct vnode *vp; struct mount *mp; struct file *fp; - int vfslocked; int error, lock_flags; AUDIT_ARG_FD(uap->fd); @@ -3551,7 +3427,6 @@ sys_fsync(td, uap) &fp)) != 0) return (error); vp = fp->f_vnode; - vfslocked = VFS_LOCK_GIANT(vp->v_mount); if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) goto drop; if (MNT_SHARED_WRITES(mp) || @@ -3572,7 +3447,6 @@ sys_fsync(td, uap) VOP_UNLOCK(vp, 0); vn_finished_write(mp); drop: - VFS_UNLOCK_GIANT(vfslocked); fdrop(fp, td); return (error); } @@ -3629,23 +3503,19 @@ kern_renameat(struct thread *td, int oldfd, char *old, int newfd, char *new, struct mount *mp = NULL; struct vnode *tvp, *fvp, *tdvp; struct nameidata fromnd, tond; - int tvfslocked; - int fvfslocked; int error; bwillwrite(); #ifdef MAC NDINIT_ATRIGHTS(&fromnd, DELETE, LOCKPARENT | LOCKLEAF | SAVESTART | - MPSAFE | AUDITVNODE1, pathseg, old, oldfd, CAP_DELETE, td); + AUDITVNODE1, pathseg, old, oldfd, CAP_DELETE, td); #else - NDINIT_ATRIGHTS(&fromnd, DELETE, WANTPARENT | SAVESTART | MPSAFE | + NDINIT_ATRIGHTS(&fromnd, DELETE, WANTPARENT | SAVESTART | AUDITVNODE1, pathseg, old, oldfd, CAP_DELETE, td); #endif if ((error = namei(&fromnd)) != 0) return (error); - fvfslocked = NDHASGIANT(&fromnd); - tvfslocked = 0; #ifdef MAC error = mac_vnode_check_rename_from(td->td_ucred, fromnd.ni_dvp, fromnd.ni_vp, &fromnd.ni_cnd); @@ -3663,7 +3533,7 @@ kern_renameat(struct thread *td, int oldfd, char *old, int newfd, char *new, goto out1; } NDINIT_ATRIGHTS(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | - SAVESTART | MPSAFE | AUDITVNODE2, pathseg, new, newfd, CAP_CREATE, + SAVESTART | AUDITVNODE2, pathseg, new, newfd, CAP_CREATE, td); if (fromnd.ni_vp->v_type == VDIR) tond.ni_cnd.cn_flags |= WILLBEDIR; @@ -3677,7 +3547,6 @@ kern_renameat(struct thread *td, int oldfd, char *old, int newfd, char *new, vn_finished_write(mp); goto out1; } - tvfslocked = NDHASGIANT(&tond); tdvp = tond.ni_dvp; tvp = tond.ni_vp; if (tvp != NULL) { @@ -3727,8 +3596,6 @@ out: out1: if (fromnd.ni_startdir) vrele(fromnd.ni_startdir); - VFS_UNLOCK_GIANT(fvfslocked); - VFS_UNLOCK_GIANT(tvfslocked); if (error == -1) return (0); return (error); @@ -3785,17 +3652,15 @@ kern_mkdirat(struct thread *td, int fd, char *path, enum uio_seg segflg, struct vattr vattr; int error; struct nameidata nd; - int vfslocked; AUDIT_ARG_MODE(mode); restart: bwillwrite(); - NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | MPSAFE | + NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | AUDITVNODE1, segflg, path, fd, CAP_MKDIR, td); nd.ni_cnd.cn_flags |= WILLBEDIR; if ((error = namei(&nd)) != 0) return (error); - vfslocked = NDHASGIANT(&nd); vp = nd.ni_vp; if (vp != NULL) { NDFREE(&nd, NDF_ONLY_PNBUF); @@ -3809,13 +3674,11 @@ restart: else vput(nd.ni_dvp); vrele(vp); - VFS_UNLOCK_GIANT(vfslocked); return (EEXIST); } if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) { NDFREE(&nd, NDF_ONLY_PNBUF); vput(nd.ni_dvp); - VFS_UNLOCK_GIANT(vfslocked); if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0) return (error); goto restart; @@ -3838,7 +3701,6 @@ out: if (!error) vput(nd.ni_vp); vn_finished_write(mp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -3875,15 +3737,13 @@ kern_rmdirat(struct thread *td, int fd, char *path, enum uio_seg pathseg) struct vnode *vp; int error; struct nameidata nd; - int vfslocked; restart: bwillwrite(); - NDINIT_ATRIGHTS(&nd, DELETE, LOCKPARENT | LOCKLEAF | MPSAFE | + NDINIT_ATRIGHTS(&nd, DELETE, LOCKPARENT | LOCKLEAF | AUDITVNODE1, pathseg, path, fd, CAP_RMDIR, td); if ((error = namei(&nd)) != 0) return (error); - vfslocked = NDHASGIANT(&nd); vp = nd.ni_vp; if (vp->v_type != VDIR) { error = ENOTDIR; @@ -3916,7 +3776,6 @@ restart: vrele(nd.ni_dvp); else vput(nd.ni_dvp); - VFS_UNLOCK_GIANT(vfslocked); if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0) return (error); goto restart; @@ -3930,7 +3789,6 @@ out: vrele(nd.ni_dvp); else vput(nd.ni_dvp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -3968,7 +3826,7 @@ kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap, struct iovec aiov, kiov; struct dirent *dp, *edp; caddr_t dirbuf; - int error, eofflag, readcnt, vfslocked; + int error, eofflag, readcnt; long loff; off_t foffset; @@ -3985,9 +3843,7 @@ kern_ogetdirentries(struct thread *td, struct ogetdirentries_args *uap, vp = fp->f_vnode; foffset = foffset_lock(fp, 0); unionread: - vfslocked = VFS_LOCK_GIANT(vp->v_mount); if (vp->v_type != VDIR) { - VFS_UNLOCK_GIANT(vfslocked); foffset_unlock(fp, foffset, 0); fdrop(fp, td); return (EINVAL); @@ -4006,7 +3862,6 @@ unionread: error = mac_vnode_check_readdir(td->td_ucred, vp); if (error) { VOP_UNLOCK(vp, 0); - VFS_UNLOCK_GIANT(vfslocked); foffset_unlock(fp, foffset, FOF_NOUPDATE); fdrop(fp, td); return (error); @@ -4065,7 +3920,6 @@ unionread: } if (error) { VOP_UNLOCK(vp, 0); - VFS_UNLOCK_GIANT(vfslocked); foffset_unlock(fp, foffset, 0); fdrop(fp, td); return (error); @@ -4080,11 +3934,9 @@ unionread: fp->f_data = vp; foffset = 0; vput(tvp); - VFS_UNLOCK_GIANT(vfslocked); goto unionread; } VOP_UNLOCK(vp, 0); - VFS_UNLOCK_GIANT(vfslocked); foffset_unlock(fp, foffset, 0); fdrop(fp, td); td->td_retval[0] = uap->count - auio.uio_resid; @@ -4135,7 +3987,6 @@ kern_getdirentries(struct thread *td, int fd, char *buf, u_int count, struct file *fp; struct uio auio; struct iovec aiov; - int vfslocked; long loff; int error, eofflag; off_t foffset; @@ -4154,9 +4005,7 @@ kern_getdirentries(struct thread *td, int fd, char *buf, u_int count, vp = fp->f_vnode; foffset = foffset_lock(fp, 0); unionread: - vfslocked = VFS_LOCK_GIANT(vp->v_mount); if (vp->v_type != VDIR) { - VFS_UNLOCK_GIANT(vfslocked); error = EINVAL; goto fail; } @@ -4179,7 +4028,6 @@ unionread: foffset = auio.uio_offset; if (error) { VOP_UNLOCK(vp, 0); - VFS_UNLOCK_GIANT(vfslocked); goto fail; } if (count == auio.uio_resid && @@ -4192,11 +4040,9 @@ unionread: fp->f_data = vp; foffset = 0; vput(tvp); - VFS_UNLOCK_GIANT(vfslocked); goto unionread; } VOP_UNLOCK(vp, 0); - VFS_UNLOCK_GIANT(vfslocked); *basep = loff; if (residp != NULL) *residp = auio.uio_resid; @@ -4276,13 +4122,11 @@ sys_revoke(td, uap) struct vattr vattr; int error; struct nameidata nd; - int vfslocked; - NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1, + NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1, UIO_USERSPACE, uap->path, td); if ((error = namei(&nd)) != 0) return (error); - vfslocked = NDHASGIANT(&nd); vp = nd.ni_vp; NDFREE(&nd, NDF_ONLY_PNBUF); if (vp->v_type != VCHR || vp->v_rdev == NULL) { @@ -4306,7 +4150,6 @@ sys_revoke(td, uap) VOP_REVOKE(vp, REVOKEALL); out: vput(vp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -4382,25 +4225,22 @@ sys_lgetfh(td, uap) struct nameidata nd; fhandle_t fh; register struct vnode *vp; - int vfslocked; int error; error = priv_check(td, PRIV_VFS_GETFH); if (error) return (error); - NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1, + NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | AUDITVNODE1, UIO_USERSPACE, uap->fname, td); error = namei(&nd); if (error) return (error); - vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); vp = nd.ni_vp; bzero(&fh, sizeof(fh)); fh.fh_fsid = vp->v_mount->mnt_stat.f_fsid; error = VOP_VPTOFH(vp, &fh.fh_fid); vput(vp); - VFS_UNLOCK_GIANT(vfslocked); if (error) return (error); error = copyout(&fh, uap->fhp, sizeof (fh)); @@ -4421,25 +4261,22 @@ sys_getfh(td, uap) struct nameidata nd; fhandle_t fh; register struct vnode *vp; - int vfslocked; int error; error = priv_check(td, PRIV_VFS_GETFH); if (error) return (error); - NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1, + NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1, UIO_USERSPACE, uap->fname, td); error = namei(&nd); if (error) return (error); - vfslocked = NDHASGIANT(&nd); NDFREE(&nd, NDF_ONLY_PNBUF); vp = nd.ni_vp; bzero(&fh, sizeof(fh)); fh.fh_fsid = vp->v_mount->mnt_stat.f_fsid; error = VOP_VPTOFH(vp, &fh.fh_fid); vput(vp); - VFS_UNLOCK_GIANT(vfslocked); if (error) return (error); error = copyout(&fh, uap->fhp, sizeof (fh)); @@ -4472,7 +4309,6 @@ sys_fhopen(td, uap) struct fhandle fhp; struct file *fp; int fmode, error; - int vfslocked; int indx; error = priv_check(td, PRIV_VFS_FHOPEN); @@ -4490,19 +4326,15 @@ sys_fhopen(td, uap) mp = vfs_busyfs(&fhp.fh_fsid); if (mp == NULL) return (ESTALE); - vfslocked = VFS_LOCK_GIANT(mp); /* now give me my vnode, it gets returned to me locked */ error = VFS_FHTOVP(mp, &fhp.fh_fid, LK_EXCLUSIVE, &vp); vfs_unbusy(mp); - if (error) { - VFS_UNLOCK_GIANT(vfslocked); + if (error) return (error); - } error = falloc_noinstall(td, &fp); if (error) { vput(vp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } /* @@ -4539,7 +4371,6 @@ sys_fhopen(td, uap) error = finstall(td, fp, &indx, fmode); bad: - VFS_UNLOCK_GIANT(vfslocked); fdrop(fp, td); td->td_retval[0] = indx; return (error); @@ -4581,7 +4412,6 @@ kern_fhstat(struct thread *td, struct fhandle fh, struct stat *sb) { struct mount *mp; struct vnode *vp; - int vfslocked; int error; error = priv_check(td, PRIV_VFS_FHSTAT); @@ -4589,16 +4419,12 @@ kern_fhstat(struct thread *td, struct fhandle fh, struct stat *sb) return (error); if ((mp = vfs_busyfs(&fh.fh_fsid)) == NULL) return (ESTALE); - vfslocked = VFS_LOCK_GIANT(mp); error = VFS_FHTOVP(mp, &fh.fh_fid, LK_EXCLUSIVE, &vp); vfs_unbusy(mp); - if (error) { - VFS_UNLOCK_GIANT(vfslocked); + if (error) return (error); - } error = vn_stat(vp, sb, td->td_ucred, NOCRED, td); vput(vp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -4638,7 +4464,6 @@ kern_fhstatfs(struct thread *td, fhandle_t fh, struct statfs *buf) struct statfs *sp; struct mount *mp; struct vnode *vp; - int vfslocked; int error; error = priv_check(td, PRIV_VFS_FHSTATFS); @@ -4646,11 +4471,9 @@ kern_fhstatfs(struct thread *td, fhandle_t fh, struct statfs *buf) return (error); if ((mp = vfs_busyfs(&fh.fh_fsid)) == NULL) return (ESTALE); - vfslocked = VFS_LOCK_GIANT(mp); error = VFS_FHTOVP(mp, &fh.fh_fid, LK_EXCLUSIVE, &vp); if (error) { vfs_unbusy(mp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } vput(vp); @@ -4674,7 +4497,6 @@ kern_fhstatfs(struct thread *td, fhandle_t fh, struct statfs *buf) *buf = *sp; out: vfs_unbusy(mp); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -4729,17 +4551,13 @@ kern_posix_fallocate(struct thread *td, int fd, off_t offset, off_t len) ooffset = offset; bwillwrite(); - vfslocked = VFS_LOCK_GIANT(vp->v_mount); mp = NULL; error = vn_start_write(vp, &mp, V_WAIT | PCATCH); - if (error != 0) { - VFS_UNLOCK_GIANT(vfslocked); + if (error != 0) break; - } error = vn_lock(vp, LK_EXCLUSIVE); if (error != 0) { vn_finished_write(mp); - VFS_UNLOCK_GIANT(vfslocked); break; } #ifdef MAC @@ -4749,7 +4567,6 @@ kern_posix_fallocate(struct thread *td, int fd, off_t offset, off_t len) error = VOP_ALLOCATE(vp, &offset, &len); VOP_UNLOCK(vp, 0); vn_finished_write(mp); - VFS_UNLOCK_GIANT(vfslocked); if (olen + ooffset != offset + len) { panic("offset + len changed from %jx/%jx to %jx/%jx", |