vfs: add v_irflag accessors
Reviewed by: kib (previous version) Differential Revision: https://reviews.freebsd.org/D27793
This commit is contained in:
parent
51bf55fa6c
commit
3e506a67bb
@ -263,16 +263,14 @@ null_nodeget(mp, lowervp, vpp)
|
|||||||
* some time after construction, which is typical case.
|
* some time after construction, which is typical case.
|
||||||
* null_open rechecks.
|
* null_open rechecks.
|
||||||
*/
|
*/
|
||||||
if ((lowervp->v_irflag & VIRF_PGREAD) != 0) {
|
if ((vn_irflag_read(lowervp) & VIRF_PGREAD) != 0) {
|
||||||
MPASS(lowervp->v_object != NULL);
|
MPASS(lowervp->v_object != NULL);
|
||||||
if ((vp->v_irflag & VIRF_PGREAD) == 0) {
|
if ((vn_irflag_read(vp) & VIRF_PGREAD) == 0) {
|
||||||
if (vp->v_object == NULL)
|
if (vp->v_object == NULL)
|
||||||
vp->v_object = lowervp->v_object;
|
vp->v_object = lowervp->v_object;
|
||||||
else
|
else
|
||||||
MPASS(vp->v_object == lowervp->v_object);
|
MPASS(vp->v_object == lowervp->v_object);
|
||||||
VI_LOCK(vp);
|
vn_irflag_set_cond(vp, VIRF_PGREAD);
|
||||||
vp->v_irflag |= VIRF_PGREAD;
|
|
||||||
VI_UNLOCK(vp);
|
|
||||||
} else {
|
} else {
|
||||||
MPASS(vp->v_object != NULL);
|
MPASS(vp->v_object != NULL);
|
||||||
}
|
}
|
||||||
|
@ -458,12 +458,10 @@ null_open(struct vop_open_args *ap)
|
|||||||
retval = null_bypass(&ap->a_gen);
|
retval = null_bypass(&ap->a_gen);
|
||||||
if (retval == 0) {
|
if (retval == 0) {
|
||||||
vp->v_object = ldvp->v_object;
|
vp->v_object = ldvp->v_object;
|
||||||
if ((ldvp->v_irflag & VIRF_PGREAD) != 0) {
|
if ((vn_irflag_read(ldvp) & VIRF_PGREAD) != 0) {
|
||||||
MPASS(vp->v_object != NULL);
|
MPASS(vp->v_object != NULL);
|
||||||
if ((vp->v_irflag & VIRF_PGREAD) == 0) {
|
if ((vn_irflag_read(vp) & VIRF_PGREAD) == 0) {
|
||||||
VI_LOCK(vp);
|
vn_irflag_set_cond(vp, VIRF_PGREAD);
|
||||||
vp->v_irflag |= VIRF_PGREAD;
|
|
||||||
VI_UNLOCK(vp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -698,7 +698,7 @@ tmpfs_alloc_vp(struct mount *mp, struct tmpfs_node *node, int lkflag,
|
|||||||
vp->v_object = object;
|
vp->v_object = object;
|
||||||
object->un_pager.swp.swp_tmpfs = vp;
|
object->un_pager.swp.swp_tmpfs = vp;
|
||||||
vm_object_set_flag(object, OBJ_TMPFS);
|
vm_object_set_flag(object, OBJ_TMPFS);
|
||||||
vp->v_irflag |= VIRF_PGREAD;
|
vn_irflag_set_locked(vp, VIRF_PGREAD);
|
||||||
VI_UNLOCK(vp);
|
VI_UNLOCK(vp);
|
||||||
VM_OBJECT_WUNLOCK(object);
|
VM_OBJECT_WUNLOCK(object);
|
||||||
break;
|
break;
|
||||||
|
@ -600,7 +600,7 @@ tmpfs_read_pgcache(struct vop_read_pgcache_args *v)
|
|||||||
int error;
|
int error;
|
||||||
|
|
||||||
vp = v->a_vp;
|
vp = v->a_vp;
|
||||||
VNPASS((vp->v_irflag & VIRF_PGREAD) != 0, vp);
|
VNPASS((vn_irflag_read(vp) & VIRF_PGREAD) != 0, vp);
|
||||||
|
|
||||||
if (v->a_uio->uio_offset < 0)
|
if (v->a_uio->uio_offset < 0)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
|
@ -1717,6 +1717,7 @@ getnewvnode(const char *tag, struct mount *mp, struct vop_vector *vops,
|
|||||||
KASSERT(vp->v_pollinfo == NULL, ("stale v_pollinfo %p", vp));
|
KASSERT(vp->v_pollinfo == NULL, ("stale v_pollinfo %p", vp));
|
||||||
vp->v_type = VNON;
|
vp->v_type = VNON;
|
||||||
vp->v_op = vops;
|
vp->v_op = vops;
|
||||||
|
vp->v_irflag = 0;
|
||||||
v_init_counters(vp);
|
v_init_counters(vp);
|
||||||
vp->v_bufobj.bo_ops = &buf_ops_bio;
|
vp->v_bufobj.bo_ops = &buf_ops_bio;
|
||||||
#ifdef DIAGNOSTIC
|
#ifdef DIAGNOSTIC
|
||||||
@ -1821,7 +1822,6 @@ freevnode(struct vnode *vp)
|
|||||||
vp->v_rdev = NULL;
|
vp->v_rdev = NULL;
|
||||||
vp->v_fifoinfo = NULL;
|
vp->v_fifoinfo = NULL;
|
||||||
vp->v_lasta = vp->v_clen = vp->v_cstart = vp->v_lastw = 0;
|
vp->v_lasta = vp->v_clen = vp->v_cstart = vp->v_lastw = 0;
|
||||||
vp->v_irflag = 0;
|
|
||||||
vp->v_iflag = 0;
|
vp->v_iflag = 0;
|
||||||
vp->v_vflag = 0;
|
vp->v_vflag = 0;
|
||||||
bo->bo_flag = 0;
|
bo->bo_flag = 0;
|
||||||
@ -3868,14 +3868,14 @@ vgonel(struct vnode *vp)
|
|||||||
/*
|
/*
|
||||||
* Don't vgonel if we're already doomed.
|
* Don't vgonel if we're already doomed.
|
||||||
*/
|
*/
|
||||||
if (vp->v_irflag & VIRF_DOOMED)
|
if (VN_IS_DOOMED(vp))
|
||||||
return;
|
return;
|
||||||
/*
|
/*
|
||||||
* Paired with freevnode.
|
* Paired with freevnode.
|
||||||
*/
|
*/
|
||||||
vn_seqc_write_begin_locked(vp);
|
vn_seqc_write_begin_locked(vp);
|
||||||
vunlazy_gone(vp);
|
vunlazy_gone(vp);
|
||||||
vp->v_irflag |= VIRF_DOOMED;
|
vn_irflag_set_locked(vp, VIRF_DOOMED);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check to see if the vnode is in use. If so, we have to
|
* Check to see if the vnode is in use. If so, we have to
|
||||||
@ -4001,6 +4001,7 @@ vn_printf(struct vnode *vp, const char *fmt, ...)
|
|||||||
char buf[256], buf2[16];
|
char buf[256], buf2[16];
|
||||||
u_long flags;
|
u_long flags;
|
||||||
u_int holdcnt;
|
u_int holdcnt;
|
||||||
|
short irflag;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vprintf(fmt, ap);
|
vprintf(fmt, ap);
|
||||||
@ -4036,11 +4037,12 @@ vn_printf(struct vnode *vp, const char *fmt, ...)
|
|||||||
|
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
buf[1] = '\0';
|
buf[1] = '\0';
|
||||||
if (vp->v_irflag & VIRF_DOOMED)
|
irflag = vn_irflag_read(vp);
|
||||||
|
if (irflag & VIRF_DOOMED)
|
||||||
strlcat(buf, "|VIRF_DOOMED", sizeof(buf));
|
strlcat(buf, "|VIRF_DOOMED", sizeof(buf));
|
||||||
if (vp->v_irflag & VIRF_PGREAD)
|
if (irflag & VIRF_PGREAD)
|
||||||
strlcat(buf, "|VIRF_PGREAD", sizeof(buf));
|
strlcat(buf, "|VIRF_PGREAD", sizeof(buf));
|
||||||
flags = vp->v_irflag & ~(VIRF_DOOMED | VIRF_PGREAD);
|
flags = irflag & ~(VIRF_DOOMED | VIRF_PGREAD);
|
||||||
if (flags != 0) {
|
if (flags != 0) {
|
||||||
snprintf(buf2, sizeof(buf2), "|VIRF(0x%lx)", flags);
|
snprintf(buf2, sizeof(buf2), "|VIRF(0x%lx)", flags);
|
||||||
strlcat(buf, buf2, sizeof(buf));
|
strlcat(buf, buf2, sizeof(buf));
|
||||||
@ -6794,3 +6796,66 @@ vn_seqc_write_end(struct vnode *vp)
|
|||||||
vn_seqc_write_end_locked(vp);
|
vn_seqc_write_end_locked(vp);
|
||||||
VI_UNLOCK(vp);
|
VI_UNLOCK(vp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
vn_irflag_set_locked(struct vnode *vp, short toset)
|
||||||
|
{
|
||||||
|
short flags;
|
||||||
|
|
||||||
|
ASSERT_VI_LOCKED(vp, __func__);
|
||||||
|
flags = vn_irflag_read(vp);
|
||||||
|
VNASSERT((flags & toset) == 0, vp,
|
||||||
|
("%s: some of the passed flags already set (have %d, passed %d)\n",
|
||||||
|
__func__, flags, toset));
|
||||||
|
atomic_store_short(&vp->v_irflag, flags | toset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
vn_irflag_set(struct vnode *vp, short toset)
|
||||||
|
{
|
||||||
|
|
||||||
|
VI_LOCK(vp);
|
||||||
|
vn_irflag_set_locked(vp, toset);
|
||||||
|
VI_UNLOCK(vp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
vn_irflag_set_cond_locked(struct vnode *vp, short toset)
|
||||||
|
{
|
||||||
|
short flags;
|
||||||
|
|
||||||
|
ASSERT_VI_LOCKED(vp, __func__);
|
||||||
|
flags = vn_irflag_read(vp);
|
||||||
|
atomic_store_short(&vp->v_irflag, flags | toset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
vn_irflag_set_cond(struct vnode *vp, short toset)
|
||||||
|
{
|
||||||
|
|
||||||
|
VI_LOCK(vp);
|
||||||
|
vn_irflag_set_cond_locked(vp, toset);
|
||||||
|
VI_UNLOCK(vp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
vn_irflag_unset_locked(struct vnode *vp, short tounset)
|
||||||
|
{
|
||||||
|
short flags;
|
||||||
|
|
||||||
|
ASSERT_VI_LOCKED(vp, __func__);
|
||||||
|
flags = vn_irflag_read(vp);
|
||||||
|
VNASSERT((flags & tounset) == tounset, vp,
|
||||||
|
("%s: some of the passed flags not set (have %d, passed %d)\n",
|
||||||
|
__func__, flags, tounset));
|
||||||
|
atomic_store_short(&vp->v_irflag, flags & ~tounset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
vn_irflag_unset(struct vnode *vp, short tounset)
|
||||||
|
{
|
||||||
|
|
||||||
|
VI_LOCK(vp);
|
||||||
|
vn_irflag_unset_locked(vp, tounset);
|
||||||
|
VI_UNLOCK(vp);
|
||||||
|
}
|
||||||
|
@ -991,7 +991,7 @@ vn_read(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags,
|
|||||||
* allows us to avoid unneeded work outright.
|
* allows us to avoid unneeded work outright.
|
||||||
*/
|
*/
|
||||||
if (vn_io_pgcache_read_enable && !mac_vnode_check_read_enabled() &&
|
if (vn_io_pgcache_read_enable && !mac_vnode_check_read_enabled() &&
|
||||||
(vp->v_irflag & (VIRF_DOOMED | VIRF_PGREAD)) == VIRF_PGREAD) {
|
(vn_irflag_read(vp) & (VIRF_DOOMED | VIRF_PGREAD)) == VIRF_PGREAD) {
|
||||||
error = VOP_READ_PGCACHE(vp, uio, ioflag, fp->f_cred);
|
error = VOP_READ_PGCACHE(vp, uio, ioflag, fp->f_cred);
|
||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
fp->f_nextoff[UIO_READ] = uio->uio_offset;
|
fp->f_nextoff[UIO_READ] = uio->uio_offset;
|
||||||
|
@ -797,6 +797,14 @@ void vn_seqc_write_end(struct vnode *vp);
|
|||||||
#define vn_rangelock_trywlock(vp, start, end) \
|
#define vn_rangelock_trywlock(vp, start, end) \
|
||||||
rangelock_trywlock(&(vp)->v_rl, (start), (end), VI_MTX(vp))
|
rangelock_trywlock(&(vp)->v_rl, (start), (end), VI_MTX(vp))
|
||||||
|
|
||||||
|
#define vn_irflag_read(vp) atomic_load_short(&(vp)->v_irflag)
|
||||||
|
void vn_irflag_set_locked(struct vnode *vp, short toset);
|
||||||
|
void vn_irflag_set(struct vnode *vp, short toset);
|
||||||
|
void vn_irflag_set_cond_locked(struct vnode *vp, short toset);
|
||||||
|
void vn_irflag_set_cond(struct vnode *vp, short toset);
|
||||||
|
void vn_irflag_unset_locked(struct vnode *vp, short tounset);
|
||||||
|
void vn_irflag_unset(struct vnode *vp, short tounset);
|
||||||
|
|
||||||
int vfs_cache_lookup(struct vop_lookup_args *ap);
|
int vfs_cache_lookup(struct vop_lookup_args *ap);
|
||||||
int vfs_cache_root(struct mount *mp, int flags, struct vnode **vpp);
|
int vfs_cache_root(struct mount *mp, int flags, struct vnode **vpp);
|
||||||
void vfs_timestamp(struct timespec *);
|
void vfs_timestamp(struct timespec *);
|
||||||
@ -979,7 +987,7 @@ do { \
|
|||||||
#define VOP_UNSET_TEXT_CHECKED(vp) VOP_UNSET_TEXT((vp))
|
#define VOP_UNSET_TEXT_CHECKED(vp) VOP_UNSET_TEXT((vp))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define VN_IS_DOOMED(vp) __predict_false((vp)->v_irflag & VIRF_DOOMED)
|
#define VN_IS_DOOMED(vp) __predict_false((vn_irflag_read(vp) & VIRF_DOOMED) != 0)
|
||||||
|
|
||||||
void vput(struct vnode *vp);
|
void vput(struct vnode *vp);
|
||||||
void vrele(struct vnode *vp);
|
void vrele(struct vnode *vp);
|
||||||
|
@ -283,10 +283,8 @@ ufs_open(struct vop_open_args *ap)
|
|||||||
|
|
||||||
ip = VTOI(vp);
|
ip = VTOI(vp);
|
||||||
vnode_create_vobject(vp, DIP(ip, i_size), ap->a_td);
|
vnode_create_vobject(vp, DIP(ip, i_size), ap->a_td);
|
||||||
if (vp->v_type == VREG && (vp->v_irflag & VIRF_PGREAD) == 0) {
|
if (vp->v_type == VREG && (vn_irflag_read(vp) & VIRF_PGREAD) == 0) {
|
||||||
VI_LOCK(vp);
|
vn_irflag_set_cond(vp, VIRF_PGREAD);
|
||||||
vp->v_irflag |= VIRF_PGREAD;
|
|
||||||
VI_UNLOCK(vp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2947,7 +2945,7 @@ ufs_read_pgcache(struct vop_read_pgcache_args *ap)
|
|||||||
|
|
||||||
uio = ap->a_uio;
|
uio = ap->a_uio;
|
||||||
vp = ap->a_vp;
|
vp = ap->a_vp;
|
||||||
VNPASS((vp->v_irflag & VIRF_PGREAD) != 0, vp);
|
VNPASS((vn_irflag_read(vp) & VIRF_PGREAD) != 0, vp);
|
||||||
|
|
||||||
if (uio->uio_resid > ptoa(io_hold_cnt) || uio->uio_offset < 0 ||
|
if (uio->uio_resid > ptoa(io_hold_cnt) || uio->uio_offset < 0 ||
|
||||||
(ap->a_ioflag & IO_DIRECT) != 0)
|
(ap->a_ioflag & IO_DIRECT) != 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user