mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-21 15:45:02 +00:00
vfs: introduce V_PCATCH to stop abusing PCATCH
This commit is contained in:
parent
9e4f35ac25
commit
a75d1ddd74
@ -226,7 +226,7 @@ zfs_vop_fsync(vnode_t *vp)
|
||||
struct mount *mp;
|
||||
int error;
|
||||
|
||||
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0)
|
||||
if ((error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH)) != 0)
|
||||
goto drop;
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
error = VOP_FSYNC(vp, MNT_WAIT, curthread);
|
||||
|
@ -516,7 +516,7 @@ fdesc_setattr(struct vop_setattr_args *ap)
|
||||
return (error);
|
||||
}
|
||||
vp = fp->f_vnode;
|
||||
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) == 0) {
|
||||
if ((error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH)) == 0) {
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
error = VOP_SETATTR(vp, ap->a_vap, ap->a_cred);
|
||||
VOP_UNLOCK(vp);
|
||||
|
@ -8426,10 +8426,10 @@ nfsrv_copymr(vnode_t vp, vnode_t fvp, vnode_t dvp, struct nfsdevice *ds,
|
||||
* NFS mount and they are not suspendable at this time.
|
||||
*/
|
||||
if (ret == 0)
|
||||
ret = vn_start_write(vp, &mp, V_WAIT | PCATCH);
|
||||
ret = vn_start_write(vp, &mp, V_WAIT | V_PCATCH);
|
||||
if (ret == 0) {
|
||||
tvmp = dvp->v_mount;
|
||||
ret = vn_start_write(NULL, &tvmp, V_WAIT | PCATCH);
|
||||
ret = vn_start_write(NULL, &tvmp, V_WAIT | V_PCATCH);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -907,7 +907,7 @@ unionfs_mkshadowdir(struct unionfs_mount *ump, struct vnode *udvp,
|
||||
goto unionfs_mkshadowdir_abort;
|
||||
}
|
||||
|
||||
if ((error = vn_start_write(udvp, &mp, V_WAIT | PCATCH)))
|
||||
if ((error = vn_start_write(udvp, &mp, V_WAIT | V_PCATCH)))
|
||||
goto unionfs_mkshadowdir_abort;
|
||||
unionfs_create_uppervattr_core(ump, &lva, &va, td);
|
||||
|
||||
@ -962,7 +962,7 @@ unionfs_mkwhiteout(struct vnode *dvp, struct componentname *cnp,
|
||||
return (EEXIST);
|
||||
}
|
||||
|
||||
if ((error = vn_start_write(dvp, &mp, V_WAIT | PCATCH)))
|
||||
if ((error = vn_start_write(dvp, &mp, V_WAIT | V_PCATCH)))
|
||||
goto unionfs_mkwhiteout_free_out;
|
||||
error = VOP_WHITEOUT(dvp, &nd.ni_cnd, CREATE);
|
||||
|
||||
@ -1160,7 +1160,7 @@ unionfs_copyfile(struct unionfs_node *unp, int docopy, struct ucred *cred,
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
if ((error = vn_start_write(udvp, &mp, V_WAIT | PCATCH)) != 0)
|
||||
if ((error = vn_start_write(udvp, &mp, V_WAIT | V_PCATCH)) != 0)
|
||||
return (error);
|
||||
error = unionfs_vn_create_on_upper(&uvp, udvp, unp, &uva, td);
|
||||
if (error != 0) {
|
||||
|
@ -611,7 +611,7 @@ uipc_bindat(int fd, struct socket *so, struct sockaddr *nam, struct thread *td)
|
||||
error = EADDRINUSE;
|
||||
goto error;
|
||||
}
|
||||
error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH);
|
||||
error = vn_start_write(NULL, &mp, V_XSLEEP | V_PCATCH);
|
||||
if (error)
|
||||
goto error;
|
||||
goto restart;
|
||||
|
@ -236,7 +236,7 @@ vacl_set_acl(struct thread *td, struct vnode *vp, acl_type_t type,
|
||||
error = acl_copyin(aclp, inkernelacl, type);
|
||||
if (error != 0)
|
||||
goto out;
|
||||
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
|
||||
error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH);
|
||||
if (error != 0)
|
||||
goto out;
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
@ -300,7 +300,7 @@ vacl_delete(struct thread *td, struct vnode *vp, acl_type_t type)
|
||||
int error;
|
||||
|
||||
AUDIT_ARG_VALUE(type);
|
||||
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
|
||||
error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
|
@ -724,7 +724,7 @@ aio_fsync_vnode(struct thread *td, struct vnode *vp, int op)
|
||||
int error;
|
||||
|
||||
for (;;) {
|
||||
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
|
||||
error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH);
|
||||
if (error != 0)
|
||||
break;
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
|
@ -125,7 +125,7 @@ sys_extattrctl(struct thread *td, struct extattrctl_args *uap)
|
||||
goto out;
|
||||
}
|
||||
VOP_UNLOCK(nd.ni_vp);
|
||||
error = vn_start_write(nd.ni_vp, &mp_writable, V_WAIT | PCATCH);
|
||||
error = vn_start_write(nd.ni_vp, &mp_writable, V_WAIT | V_PCATCH);
|
||||
NDFREE(&nd, NDF_NO_VP_UNLOCK);
|
||||
if (error)
|
||||
goto out;
|
||||
@ -182,7 +182,7 @@ extattr_set_vp(struct vnode *vp, int attrnamespace, const char *attrname,
|
||||
if (nbytes > IOSIZE_MAX)
|
||||
return (EINVAL);
|
||||
|
||||
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
|
||||
error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH);
|
||||
if (error)
|
||||
return (error);
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
@ -497,7 +497,7 @@ extattr_delete_vp(struct vnode *vp, int attrnamespace, const char *attrname,
|
||||
struct mount *mp;
|
||||
int error;
|
||||
|
||||
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
|
||||
error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH);
|
||||
if (error)
|
||||
return (error);
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
|
@ -1389,7 +1389,7 @@ kern_mknodat(struct thread *td, int fd, const char *path, enum uio_seg pathseg,
|
||||
if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) {
|
||||
NDFREE_PNBUF(&nd);
|
||||
vput(nd.ni_dvp);
|
||||
if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0)
|
||||
if ((error = vn_start_write(NULL, &mp, V_XSLEEP | V_PCATCH)) != 0)
|
||||
return (error);
|
||||
goto restart;
|
||||
}
|
||||
@ -1476,7 +1476,7 @@ kern_mkfifoat(struct thread *td, int fd, const char *path,
|
||||
if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) {
|
||||
NDFREE_PNBUF(&nd);
|
||||
vput(nd.ni_dvp);
|
||||
if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0)
|
||||
if ((error = vn_start_write(NULL, &mp, V_XSLEEP | V_PCATCH)) != 0)
|
||||
return (error);
|
||||
goto restart;
|
||||
}
|
||||
@ -1660,7 +1660,7 @@ kern_linkat_vp(struct thread *td, struct vnode *vp, int fd, const char *path,
|
||||
vput(nd.ni_dvp);
|
||||
NDFREE_PNBUF(&nd);
|
||||
error = vn_start_write(NULL, &mp,
|
||||
V_XSLEEP | PCATCH);
|
||||
V_XSLEEP | V_PCATCH);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
return (EAGAIN);
|
||||
@ -1755,7 +1755,7 @@ kern_symlinkat(struct thread *td, const char *path1, int fd, const char *path2,
|
||||
if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) {
|
||||
NDFREE_PNBUF(&nd);
|
||||
vput(nd.ni_dvp);
|
||||
if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0)
|
||||
if ((error = vn_start_write(NULL, &mp, V_XSLEEP | V_PCATCH)) != 0)
|
||||
goto out;
|
||||
goto restart;
|
||||
}
|
||||
@ -1820,7 +1820,7 @@ sys_undelete(struct thread *td, struct undelete_args *uap)
|
||||
if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) {
|
||||
NDFREE_PNBUF(&nd);
|
||||
vput(nd.ni_dvp);
|
||||
if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0)
|
||||
if ((error = vn_start_write(NULL, &mp, V_XSLEEP | V_PCATCH)) != 0)
|
||||
return (error);
|
||||
goto restart;
|
||||
}
|
||||
@ -1953,7 +1953,7 @@ kern_funlinkat(struct thread *td, int dfd, const char *path, int fd,
|
||||
else
|
||||
vput(vp);
|
||||
if ((error = vn_start_write(NULL, &mp,
|
||||
V_XSLEEP | PCATCH)) != 0) {
|
||||
V_XSLEEP | V_PCATCH)) != 0) {
|
||||
goto fdout;
|
||||
}
|
||||
goto restart;
|
||||
@ -2729,7 +2729,7 @@ setfflags(struct thread *td, struct vnode *vp, u_long flags)
|
||||
return (error);
|
||||
}
|
||||
|
||||
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0)
|
||||
if ((error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH)) != 0)
|
||||
return (error);
|
||||
VATTR_NULL(&vattr);
|
||||
vattr.va_flags = flags;
|
||||
@ -2860,7 +2860,7 @@ setfmode(struct thread *td, struct ucred *cred, struct vnode *vp, int mode)
|
||||
struct vattr vattr;
|
||||
int error;
|
||||
|
||||
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0)
|
||||
if ((error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH)) != 0)
|
||||
return (error);
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
VATTR_NULL(&vattr);
|
||||
@ -2985,7 +2985,7 @@ setfown(struct thread *td, struct ucred *cred, struct vnode *vp, uid_t uid,
|
||||
struct vattr vattr;
|
||||
int error;
|
||||
|
||||
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0)
|
||||
if ((error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH)) != 0)
|
||||
return (error);
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
VATTR_NULL(&vattr);
|
||||
@ -3199,7 +3199,7 @@ setutimes(struct thread *td, struct vnode *vp, const struct timespec *ts,
|
||||
vattr.va_birthtime.tv_sec = VNOVAL;
|
||||
vattr.va_birthtime.tv_nsec = 0;
|
||||
|
||||
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0)
|
||||
if ((error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH)) != 0)
|
||||
return (error);
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
if (numtimes < 3 && VOP_GETATTR(vp, &vattr, td->td_ucred) == 0 &&
|
||||
@ -3471,7 +3471,7 @@ kern_truncate(struct thread *td, const char *path, enum uio_seg pathseg,
|
||||
vp = nd.ni_vp;
|
||||
NDFREE_PNBUF(&nd);
|
||||
rl_cookie = vn_rangelock_wlock(vp, 0, OFF_MAX);
|
||||
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) {
|
||||
if ((error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH)) != 0) {
|
||||
vn_rangelock_unlock(vp, rl_cookie);
|
||||
vrele(vp);
|
||||
return (error);
|
||||
@ -3554,7 +3554,7 @@ kern_fsync(struct thread *td, int fd, bool fullsync)
|
||||
/* XXXKIB: compete outstanding aio writes */;
|
||||
#endif
|
||||
retry:
|
||||
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
|
||||
error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH);
|
||||
if (error != 0)
|
||||
goto drop;
|
||||
vn_lock(vp, vn_lktype_write(mp, vp) | LK_RETRY);
|
||||
@ -3716,7 +3716,7 @@ kern_renameat(struct thread *td, int oldfd, const char *old, int newfd,
|
||||
vrele(tond.ni_startdir);
|
||||
if (fromnd.ni_startdir != NULL)
|
||||
vrele(fromnd.ni_startdir);
|
||||
error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH);
|
||||
error = vn_start_write(NULL, &mp, V_XSLEEP | V_PCATCH);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
goto again;
|
||||
@ -3839,7 +3839,7 @@ kern_mkdirat(struct thread *td, int fd, const char *path, enum uio_seg segflg,
|
||||
if (vn_start_write(nd.ni_dvp, &mp, V_NOWAIT) != 0) {
|
||||
NDFREE_PNBUF(&nd);
|
||||
vput(nd.ni_dvp);
|
||||
if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0)
|
||||
if ((error = vn_start_write(NULL, &mp, V_XSLEEP | V_PCATCH)) != 0)
|
||||
return (error);
|
||||
goto restart;
|
||||
}
|
||||
@ -3948,7 +3948,7 @@ kern_frmdirat(struct thread *td, int dfd, const char *path, int fd,
|
||||
vrele(nd.ni_dvp);
|
||||
else
|
||||
vput(nd.ni_dvp);
|
||||
if ((error = vn_start_write(NULL, &mp, V_XSLEEP | PCATCH)) != 0)
|
||||
if ((error = vn_start_write(NULL, &mp, V_XSLEEP | V_PCATCH)) != 0)
|
||||
goto fdout;
|
||||
goto restart;
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ vn_open_cred(struct nameidata *ndp, int *flagp, int cmode, u_int vn_open_flags,
|
||||
NDFREE_PNBUF(ndp);
|
||||
vput(ndp->ni_dvp);
|
||||
if ((error = vn_start_write(NULL, &mp,
|
||||
V_XSLEEP | PCATCH)) != 0)
|
||||
V_XSLEEP | V_PCATCH)) != 0)
|
||||
return (error);
|
||||
NDREINIT(ndp);
|
||||
goto restart;
|
||||
@ -654,7 +654,7 @@ vn_rdwr(enum uio_rw rw, struct vnode *vp, void *base, int len, off_t offset,
|
||||
mp = NULL;
|
||||
if (rw == UIO_WRITE) {
|
||||
if (vp->v_type != VCHR &&
|
||||
(error = vn_start_write(vp, &mp, V_WAIT | PCATCH))
|
||||
(error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH))
|
||||
!= 0)
|
||||
goto out;
|
||||
lock_flags = vn_lktype_write(mp, vp);
|
||||
@ -1155,7 +1155,7 @@ vn_write(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags,
|
||||
mp = NULL;
|
||||
need_finished_write = false;
|
||||
if (vp->v_type != VCHR) {
|
||||
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
|
||||
error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH);
|
||||
if (error != 0)
|
||||
goto unlock;
|
||||
need_finished_write = true;
|
||||
@ -1619,7 +1619,7 @@ 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);
|
||||
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
|
||||
error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH);
|
||||
if (error)
|
||||
goto out1;
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
|
||||
@ -1877,7 +1877,7 @@ vn_start_write_refed(struct mount *mp, int flags, bool mplocked)
|
||||
mp->mnt_susp_owner != curthread) {
|
||||
mflags = 0;
|
||||
if ((mp->mnt_vfc->vfc_flags & VFCF_SBDRY) != 0) {
|
||||
if (flags & PCATCH)
|
||||
if (flags & V_PCATCH)
|
||||
mflags |= PCATCH;
|
||||
}
|
||||
mflags |= (PUSER - 1);
|
||||
@ -1908,6 +1908,9 @@ vn_start_write(struct vnode *vp, struct mount **mpp, int flags)
|
||||
struct mount *mp;
|
||||
int error;
|
||||
|
||||
KASSERT((flags & ~V_VALID_FLAGS) == 0,
|
||||
("%s: invalid flags passed %d\n", __func__, flags));
|
||||
|
||||
error = 0;
|
||||
/*
|
||||
* If a vnode is provided, get and return the mount point that
|
||||
@ -1950,6 +1953,9 @@ vn_start_secondary_write(struct vnode *vp, struct mount **mpp, int flags)
|
||||
struct mount *mp;
|
||||
int error, mflags;
|
||||
|
||||
KASSERT((flags & ~V_VALID_FLAGS) == 0,
|
||||
("%s: invalid flags passed %d\n", __func__, flags));
|
||||
|
||||
retry:
|
||||
if (vp != NULL) {
|
||||
if ((error = VOP_GETWRITEMOUNT(vp, mpp)) != 0) {
|
||||
@ -1992,7 +1998,7 @@ vn_start_secondary_write(struct vnode *vp, struct mount **mpp, int flags)
|
||||
*/
|
||||
mflags = 0;
|
||||
if ((mp->mnt_vfc->vfc_flags & VFCF_SBDRY) != 0) {
|
||||
if (flags & PCATCH)
|
||||
if (flags & V_PCATCH)
|
||||
mflags |= PCATCH;
|
||||
}
|
||||
mflags |= (PUSER - 1) | PDROP;
|
||||
@ -3473,7 +3479,7 @@ vn_fallocate(struct file *fp, off_t offset, off_t len, struct thread *td)
|
||||
|
||||
bwillwrite();
|
||||
mp = NULL;
|
||||
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
|
||||
error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH);
|
||||
if (error != 0)
|
||||
break;
|
||||
error = vn_lock(vp, LK_EXCLUSIVE);
|
||||
@ -3541,7 +3547,7 @@ vn_deallocate_impl(struct vnode *vp, off_t *offset, off_t *length, int flags,
|
||||
if ((ioflag & IO_NODELOCKED) == 0) {
|
||||
bwillwrite();
|
||||
if ((error = vn_start_write(vp, &mp,
|
||||
V_WAIT | PCATCH)) != 0)
|
||||
V_WAIT | V_PCATCH)) != 0)
|
||||
goto out;
|
||||
vn_lock(vp, vn_lktype_write(mp, vp) | LK_RETRY);
|
||||
}
|
||||
|
@ -430,7 +430,7 @@ sys___mac_set_fd(struct thread *td, struct __mac_set_fd_args *uap)
|
||||
break;
|
||||
}
|
||||
vp = fp->f_vnode;
|
||||
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
|
||||
error = vn_start_write(vp, &mp, V_WAIT | V_PCATCH);
|
||||
if (error != 0) {
|
||||
mac_vnode_label_free(intlabel);
|
||||
break;
|
||||
@ -536,7 +536,7 @@ kern___mac_set_path(struct thread *td, const char *path_p, struct mac *mac_p,
|
||||
NDINIT(&nd, LOOKUP, LOCKLEAF | follow, UIO_USERSPACE, path_p);
|
||||
error = namei(&nd);
|
||||
if (error == 0) {
|
||||
error = vn_start_write(nd.ni_vp, &mp, V_WAIT | PCATCH);
|
||||
error = vn_start_write(nd.ni_vp, &mp, V_WAIT | V_PCATCH);
|
||||
if (error == 0) {
|
||||
error = vn_setlabel(nd.ni_vp, intlabel,
|
||||
td->td_ucred);
|
||||
|
@ -431,6 +431,8 @@ extern int vttoif_tab[];
|
||||
#define V_WAIT 0x0001 /* vn_start_write: sleep for suspend */
|
||||
#define V_NOWAIT 0x0002 /* vn_start_write: don't sleep for suspend */
|
||||
#define V_XSLEEP 0x0004 /* vn_start_write: just return after sleep */
|
||||
#define V_PCATCH 0x0008 /* vn_start_write: make the sleep interruptible */
|
||||
#define V_VALID_FLAGS (V_WAIT | V_NOWAIT | V_XSLEEP | V_PCATCH)
|
||||
|
||||
#define VR_START_WRITE 0x0001 /* vfs_write_resume: start write atomically */
|
||||
#define VR_NO_SUSPCLR 0x0002 /* vfs_write_resume: do not clear suspension */
|
||||
|
Loading…
Reference in New Issue
Block a user