Changeset View
Changeset View
Standalone View
Standalone View
sys/fs/nullfs/null_vnops.c
Show First 20 Lines • Show All 325 Lines • ▼ Show 20 Lines | if (descp->vdesc_vpp_offset != VDESC_NO_OFFSET && | ||||
if (*vppp) | if (*vppp) | ||||
error = null_nodeget(old_vps[0]->v_mount, **vppp, *vppp); | error = null_nodeget(old_vps[0]->v_mount, **vppp, *vppp); | ||||
} | } | ||||
out: | out: | ||||
return (error); | return (error); | ||||
} | } | ||||
static int | |||||
null_add_writecount(struct vop_add_writecount_args *ap) | |||||
{ | |||||
struct vnode *lvp, *vp; | |||||
int error; | |||||
vp = ap->a_vp; | |||||
lvp = NULLVPTOLOWERVP(vp); | |||||
KASSERT(vp->v_writecount + ap->a_inc >= 0, ("wrong writecount inc")); | |||||
if (vp->v_writecount > 0 && vp->v_writecount + ap->a_inc == 0) | |||||
error = VOP_ADD_WRITECOUNT(lvp, -1); | |||||
else if (vp->v_writecount == 0 && vp->v_writecount + ap->a_inc > 0) | |||||
error = VOP_ADD_WRITECOUNT(lvp, 1); | |||||
else | |||||
error = 0; | |||||
if (error == 0) | |||||
vp->v_writecount += ap->a_inc; | |||||
return (error); | |||||
} | |||||
/* | /* | ||||
* We have to carry on the locking protocol on the null layer vnodes | * We have to carry on the locking protocol on the null layer vnodes | ||||
* as we progress through the tree. We also have to enforce read-only | * as we progress through the tree. We also have to enforce read-only | ||||
* if this layer is mounted read-only. | * if this layer is mounted read-only. | ||||
*/ | */ | ||||
static int | static int | ||||
null_lookup(struct vop_lookup_args *ap) | null_lookup(struct vop_lookup_args *ap) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 437 Lines • ▼ Show 20 Lines | null_reclaim(struct vop_reclaim_args *ap) | ||||
*/ | */ | ||||
lockmgr(&vp->v_lock, LK_EXCLUSIVE, NULL); | lockmgr(&vp->v_lock, LK_EXCLUSIVE, NULL); | ||||
VI_LOCK(vp); | VI_LOCK(vp); | ||||
vp->v_data = NULL; | vp->v_data = NULL; | ||||
vp->v_object = NULL; | vp->v_object = NULL; | ||||
vp->v_vnlock = &vp->v_lock; | vp->v_vnlock = &vp->v_lock; | ||||
VI_UNLOCK(vp); | VI_UNLOCK(vp); | ||||
/* | |||||
* If we were opened for write, we leased one write reference | |||||
* to the lower vnode. If this is a reclamation due to the | |||||
* forced unmount, undo the reference now. | |||||
*/ | |||||
if (vp->v_writecount > 0) | |||||
VOP_ADD_WRITECOUNT(lowervp, -1); | |||||
if ((xp->null_flags & NULLV_NOUNLOCK) != 0) | if ((xp->null_flags & NULLV_NOUNLOCK) != 0) | ||||
vunref(lowervp); | vunref(lowervp); | ||||
else | else | ||||
vput(lowervp); | vput(lowervp); | ||||
free(xp, M_NULLFSNODE); | free(xp, M_NULLFSNODE); | ||||
return (0); | return (0); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | struct vop_vector null_vnodeops = { | ||||
.vop_remove = null_remove, | .vop_remove = null_remove, | ||||
.vop_rename = null_rename, | .vop_rename = null_rename, | ||||
.vop_rmdir = null_rmdir, | .vop_rmdir = null_rmdir, | ||||
.vop_setattr = null_setattr, | .vop_setattr = null_setattr, | ||||
.vop_strategy = VOP_EOPNOTSUPP, | .vop_strategy = VOP_EOPNOTSUPP, | ||||
.vop_unlock = null_unlock, | .vop_unlock = null_unlock, | ||||
.vop_vptocnp = null_vptocnp, | .vop_vptocnp = null_vptocnp, | ||||
.vop_vptofh = null_vptofh, | .vop_vptofh = null_vptofh, | ||||
.vop_add_writecount = null_add_writecount, | |||||
}; | }; |