diff options
Diffstat (limited to 'sys/kern/vfs_vnops.c')
-rw-r--r-- | sys/kern/vfs_vnops.c | 64 |
1 files changed, 7 insertions, 57 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 49535cc..402a9d0 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -125,16 +125,12 @@ vn_open_cred(struct nameidata *ndp, int *flagp, int cmode, u_int vn_open_flags, struct vattr vat; struct vattr *vap = &vat; int fmode, error; - int vfslocked, mpsafe; - mpsafe = ndp->ni_cnd.cn_flags & MPSAFE; restart: - vfslocked = 0; fmode = *flagp; if (fmode & O_CREAT) { ndp->ni_cnd.cn_nameiop = CREATE; - ndp->ni_cnd.cn_flags = ISOPEN | LOCKPARENT | LOCKLEAF | - MPSAFE; + ndp->ni_cnd.cn_flags = ISOPEN | LOCKPARENT | LOCKLEAF; if ((fmode & O_EXCL) == 0 && (fmode & O_NOFOLLOW) == 0) ndp->ni_cnd.cn_flags |= FOLLOW; if (!(vn_open_flags & VN_OPEN_NOAUDIT)) @@ -142,9 +138,6 @@ restart: bwillwrite(); if ((error = namei(ndp)) != 0) return (error); - vfslocked = NDHASGIANT(ndp); - if (!mpsafe) - ndp->ni_cnd.cn_flags &= ~MPSAFE; if (ndp->ni_vp == NULL) { VATTR_NULL(vap); vap->va_type = VREG; @@ -154,7 +147,6 @@ restart: if (vn_start_write(ndp->ni_dvp, &mp, V_NOWAIT) != 0) { NDFREE(ndp, NDF_ONLY_PNBUF); vput(ndp->ni_dvp); - VFS_UNLOCK_GIANT(vfslocked); if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0) return (error); @@ -170,7 +162,6 @@ restart: vput(ndp->ni_dvp); vn_finished_write(mp); if (error) { - VFS_UNLOCK_GIANT(vfslocked); NDFREE(ndp, NDF_ONLY_PNBUF); return (error); } @@ -192,30 +183,23 @@ restart: } else { ndp->ni_cnd.cn_nameiop = LOOKUP; ndp->ni_cnd.cn_flags = ISOPEN | - ((fmode & O_NOFOLLOW) ? NOFOLLOW : FOLLOW) | - LOCKLEAF | MPSAFE; + ((fmode & O_NOFOLLOW) ? NOFOLLOW : FOLLOW) | LOCKLEAF; if (!(fmode & FWRITE)) ndp->ni_cnd.cn_flags |= LOCKSHARED; if (!(vn_open_flags & VN_OPEN_NOAUDIT)) ndp->ni_cnd.cn_flags |= AUDITVNODE1; if ((error = namei(ndp)) != 0) return (error); - if (!mpsafe) - ndp->ni_cnd.cn_flags &= ~MPSAFE; - vfslocked = NDHASGIANT(ndp); vp = ndp->ni_vp; } error = vn_open_vnode(vp, fmode, cred, td, fp); if (error) goto bad; *flagp = fmode; - if (!mpsafe) - VFS_UNLOCK_GIANT(vfslocked); return (0); bad: NDFREE(ndp, NDF_ONLY_PNBUF); vput(vp); - VFS_UNLOCK_GIANT(vfslocked); *flagp = fmode; ndp->ni_vp = NULL; return (error); @@ -234,7 +218,6 @@ vn_open_vnode(struct vnode *vp, int fmode, struct ucred *cred, struct flock lf; int error, have_flock, lock_flags, type; - VFS_ASSERT_GIANT(vp->v_mount); if (vp->v_type == VLNK) return (EMLINK); if (vp->v_type == VSOCK) @@ -367,8 +350,6 @@ vn_close(vp, flags, file_cred, td) else lock_flags = LK_EXCLUSIVE; - VFS_ASSERT_GIANT(vp->v_mount); - vn_start_write(vp, &mp, V_WAIT); vn_lock(vp, lock_flags | LK_RETRY); if (flags & FWRITE) { @@ -441,8 +422,6 @@ vn_rdwr(enum uio_rw rw, struct vnode *vp, void *base, int len, off_t offset, void *rl_cookie; int error, lock_flags; - VFS_ASSERT_GIANT(vp->v_mount); - auio.uio_iov = &aiov; auio.uio_iovcnt = 1; aiov.iov_base = base; @@ -542,8 +521,6 @@ vn_rdwr_inchunks(rw, vp, base, len, offset, segflg, ioflg, active_cred, int error = 0; ssize_t iaresid; - VFS_ASSERT_GIANT(vp->v_mount); - do { int chunk; @@ -692,7 +669,7 @@ vn_read(fp, uio, active_cred, flags, td) struct vnode *vp; struct mtx *mtxp; int error, ioflag; - int advice, vfslocked; + int advice; off_t offset, start, end; KASSERT(uio->uio_td == td, ("uio_td %p is not td %p", @@ -705,7 +682,6 @@ vn_read(fp, uio, active_cred, flags, td) if (fp->f_flag & O_DIRECT) ioflag |= IO_DIRECT; advice = get_advice(fp, uio); - vfslocked = VFS_LOCK_GIANT(vp->v_mount); vn_lock(vp, LK_SHARED | LK_RETRY); switch (advice) { @@ -761,7 +737,6 @@ vn_read(fp, uio, active_cred, flags, td) mtx_unlock(mtxp); error = VOP_ADVISE(vp, start, end, POSIX_FADV_DONTNEED); } - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -780,14 +755,13 @@ vn_write(fp, uio, active_cred, flags, td) struct mount *mp; struct mtx *mtxp; int error, ioflag, lock_flags; - int advice, vfslocked; + int advice; off_t offset, start, end; KASSERT(uio->uio_td == td, ("uio_td %p is not td %p", uio->uio_td, td)); KASSERT(flags & FOF_OFFSET, ("No FOF_OFFSET")); vp = fp->f_vnode; - vfslocked = VFS_LOCK_GIANT(vp->v_mount); if (vp->v_type == VREG) bwillwrite(); ioflag = IO_UNIT; @@ -887,7 +861,6 @@ vn_write(fp, uio, active_cred, flags, td) } unlock: - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -1155,7 +1128,6 @@ vn_truncate(struct file *fp, off_t length, struct ucred *active_cred, struct mount *mp; struct vnode *vp; void *rl_cookie; - int vfslocked; int error; vp = fp->f_vnode; @@ -1165,7 +1137,6 @@ vn_truncate(struct file *fp, off_t length, struct ucred *active_cred, * might happen partly before and partly after the truncation. */ rl_cookie = vn_rangelock_wlock(vp, 0, OFF_MAX); - vfslocked = VFS_LOCK_GIANT(vp->v_mount); error = vn_start_write(vp, &mp, V_WAIT | PCATCH); if (error) goto out1; @@ -1189,7 +1160,6 @@ out: VOP_UNLOCK(vp, 0); vn_finished_write(mp); out1: - VFS_UNLOCK_GIANT(vfslocked); vn_rangelock_unlock(vp, rl_cookie); return (error); } @@ -1205,14 +1175,11 @@ vn_statfile(fp, sb, active_cred, td) struct thread *td; { struct vnode *vp = fp->f_vnode; - int vfslocked; int error; - vfslocked = VFS_LOCK_GIANT(vp->v_mount); vn_lock(vp, LK_SHARED | LK_RETRY); error = vn_stat(vp, sb, active_cred, fp->f_cred, td); VOP_UNLOCK(vp, 0); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -1340,10 +1307,8 @@ vn_ioctl(fp, com, data, active_cred, td) { struct vnode *vp = fp->f_vnode; struct vattr vattr; - int vfslocked; int error; - vfslocked = VFS_LOCK_GIANT(vp->v_mount); error = ENOTTY; switch (vp->v_type) { case VREG: @@ -1365,7 +1330,6 @@ vn_ioctl(fp, com, data, active_cred, td) default: break; } - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -1380,11 +1344,9 @@ vn_poll(fp, events, active_cred, td) struct thread *td; { struct vnode *vp; - int vfslocked; int error; vp = fp->f_vnode; - vfslocked = VFS_LOCK_GIANT(vp->v_mount); #ifdef MAC vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); error = mac_vnode_check_poll(active_cred, fp->f_cred, vp); @@ -1393,7 +1355,6 @@ vn_poll(fp, events, active_cred, td) #endif error = VOP_POLL(vp, events, fp->f_cred, td); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -1442,13 +1403,11 @@ vn_closefile(fp, td) { struct vnode *vp; struct flock lf; - int vfslocked; int error; vp = fp->f_vnode; fp->f_ops = &badfileops; - vfslocked = VFS_LOCK_GIANT(vp->v_mount); if (fp->f_type == DTYPE_VNODE && fp->f_flag & FHASLOCK) vref(vp); @@ -1462,7 +1421,6 @@ vn_closefile(fp, td) (void) VOP_ADVLOCK(vp, fp, F_UNLCK, &lf, F_FLOCK); vrele(vp); } - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -1702,14 +1660,10 @@ vfs_write_resume(mp) static int vn_kqfilter(struct file *fp, struct knote *kn) { - int vfslocked; int error; - vfslocked = VFS_LOCK_GIANT(fp->f_vnode->v_mount); error = VOP_KQFILTER(fp->f_vnode, kn); - VFS_UNLOCK_GIANT(vfslocked); - - return error; + return (error); } /* @@ -1885,17 +1839,15 @@ vn_chmod(struct file *fp, mode_t mode, struct ucred *active_cred, struct thread *td) { struct vnode *vp; - int error, vfslocked; + int error; vp = fp->f_vnode; - vfslocked = VFS_LOCK_GIANT(vp->v_mount); #ifdef AUDIT vn_lock(vp, LK_SHARED | LK_RETRY); AUDIT_ARG_VNODE1(vp); VOP_UNLOCK(vp, 0); #endif error = setfmode(td, active_cred, vp, mode); - VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -1904,17 +1856,15 @@ vn_chown(struct file *fp, uid_t uid, gid_t gid, struct ucred *active_cred, struct thread *td) { struct vnode *vp; - int error, vfslocked; + int error; vp = fp->f_vnode; - vfslocked = VFS_LOCK_GIANT(vp->v_mount); #ifdef AUDIT vn_lock(vp, LK_SHARED | LK_RETRY); AUDIT_ARG_VNODE1(vp); VOP_UNLOCK(vp, 0); #endif error = setfown(td, active_cred, vp, uid, gid); - VFS_UNLOCK_GIANT(vfslocked); return (error); } |