summaryrefslogtreecommitdiffstats
path: root/sys/fs/unionfs
diff options
context:
space:
mode:
authorjeff <jeff@FreeBSD.org>2002-09-25 02:32:42 +0000
committerjeff <jeff@FreeBSD.org>2002-09-25 02:32:42 +0000
commitf7e588347b3192f4351b4e27c498cc085021b6e4 (patch)
tree8197cc22dc1ce7991152741f8cdeab9111066188 /sys/fs/unionfs
parent55a297392dfe0205c2d76aca3bd3de47ea4877b3 (diff)
downloadFreeBSD-src-f7e588347b3192f4351b4e27c498cc085021b6e4.zip
FreeBSD-src-f7e588347b3192f4351b4e27c498cc085021b6e4.tar.gz
- Use vrefcnt() where it is safe to do so instead of doing direct and
unlocked accesses to v_usecount. - Lock access to the buf lists in the various sync routines. interlock locking could be avoided almost entirely in leaf filesystems if the fsync function had a generic helper.
Diffstat (limited to 'sys/fs/unionfs')
-rw-r--r--sys/fs/unionfs/union_subr.c18
-rw-r--r--sys/fs/unionfs/union_vnops.c22
2 files changed, 20 insertions, 20 deletions
diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c
index b17dac8..cc06e77 100644
--- a/sys/fs/unionfs/union_subr.c
+++ b/sys/fs/unionfs/union_subr.c
@@ -486,16 +486,16 @@ loop:
*/
UDEBUG(("Modify existing un %p vn %p upper %p(refs %d) -> %p(refs %d)\n",
un, un->un_vnode, un->un_uppervp,
- (un->un_uppervp ? un->un_uppervp->v_usecount : -99),
+ (un->un_uppervp ? vrefcnt(un->un_uppervp) : -99),
uppervp,
- (uppervp ? uppervp->v_usecount : -99)
+ (uppervp ? vrefcnt(uppervp) : -99)
));
if (uppervp != un->un_uppervp) {
- KASSERT(uppervp == NULL || uppervp->v_usecount > 0, ("union_allocvp: too few refs %d (at least 1 required) on uppervp", uppervp->v_usecount));
+ KASSERT(uppervp == NULL || vrefcnt(uppervp) > 0, ("union_allocvp: too few refs %d (at least 1 required) on uppervp", vrefcnt(uppervp)));
union_newupper(un, uppervp);
} else if (uppervp) {
- KASSERT(uppervp->v_usecount > 1, ("union_allocvp: too few refs %d (at least 2 required) on uppervp", uppervp->v_usecount));
+ KASSERT(vrefcnt(uppervp) > 1, ("union_allocvp: too few refs %d (at least 2 required) on uppervp", vrefcnt(uppervp)));
vrele(uppervp);
}
@@ -776,7 +776,7 @@ union_copyup(un, docopy, cred, td)
lvp = un->un_lowervp;
- KASSERT(uvp->v_usecount > 0, ("copy: uvp refcount 0: %d", uvp->v_usecount));
+ KASSERT(vrefcnt(uvp) > 0, ("copy: uvp refcount 0: %d", vrefcnt(uvp)));
if (docopy) {
/*
* XX - should not ignore errors
@@ -798,9 +798,9 @@ union_copyup(un, docopy, cred, td)
VOP_UNLOCK(uvp, 0, td);
vn_finished_write(mp);
union_newupper(un, uvp);
- KASSERT(uvp->v_usecount > 0, ("copy: uvp refcount 0: %d", uvp->v_usecount));
+ KASSERT(vrefcnt(uvp) > 0, ("copy: uvp refcount 0: %d", vrefcnt(uvp)));
union_vn_close(uvp, FWRITE, cred, td);
- KASSERT(uvp->v_usecount > 0, ("copy: uvp refcount 0: %d", uvp->v_usecount));
+ KASSERT(vrefcnt(uvp) > 0, ("copy: uvp refcount 0: %d", vrefcnt(uvp)));
/*
* Subsequent IOs will go to the top layer, so
* call close on the lower vnode and open on the
@@ -1279,10 +1279,10 @@ union_dircache(vp, td)
goto out;
/*vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, td);*/
- UDEBUG(("ALLOCVP-3 %p ref %d\n", *vpp, (*vpp ? (*vpp)->v_usecount : -99)));
+ UDEBUG(("ALLOCVP-3 %p ref %d\n", *vpp, (*vpp ? vrefcnt(*vpp) : -99)));
VREF(*vpp);
error = union_allocvp(&nvp, vp->v_mount, NULLVP, NULLVP, NULL, *vpp, NULLVP, 0);
- UDEBUG(("ALLOCVP-3B %p ref %d\n", nvp, (*vpp ? (*vpp)->v_usecount : -99)));
+ UDEBUG(("ALLOCVP-3B %p ref %d\n", nvp, (*vpp ? vrefcnt(*vpp) : -99)));
if (error)
goto out;
diff --git a/sys/fs/unionfs/union_vnops.c b/sys/fs/unionfs/union_vnops.c
index 264e39d..3ceb89f 100644
--- a/sys/fs/unionfs/union_vnops.c
+++ b/sys/fs/unionfs/union_vnops.c
@@ -117,7 +117,7 @@ union_lock_upper(struct union_node *un, struct thread *td)
VREF(uppervp);
vn_lock(uppervp, LK_EXCLUSIVE | LK_CANRECURSE | LK_RETRY, td);
}
- KASSERT((uppervp == NULL || uppervp->v_usecount > 0), ("uppervp usecount is 0"));
+ KASSERT((uppervp == NULL || vrefcnt(uppervp) > 0), ("uppervp usecount is 0"));
return(uppervp);
}
@@ -361,10 +361,10 @@ union_lookup(ap)
"uerror %d upperdvp %p %d/%d, uppervp %p ref=%d/lck=%d\n",
uerror,
upperdvp,
- upperdvp->v_usecount,
+ vrefcnt(upperdvp),
VOP_ISLOCKED(upperdvp, NULL),
uppervp,
- (uppervp ? uppervp->v_usecount : -99),
+ (uppervp ? vrefcnt(uppervp) : -99),
(uppervp ? VOP_ISLOCKED(uppervp, NULL) : -99)
));
@@ -542,7 +542,7 @@ union_lookup(ap)
error = union_allocvp(ap->a_vpp, dvp->v_mount, dvp, upperdvp, cnp,
uppervp, lowervp, 1);
- UDEBUG(("Create %p = %p %p refs=%d\n", *ap->a_vpp, uppervp, lowervp, (*ap->a_vpp) ? ((*ap->a_vpp)->v_usecount) : -99));
+ UDEBUG(("Create %p = %p %p refs=%d\n", *ap->a_vpp, uppervp, lowervp, (*ap->a_vpp) ? vrefcnt(*ap->a_vpp) : -99));
uppervp = NULL;
upperdvp = NULL;
@@ -582,7 +582,7 @@ out:
cnp->cn_flags &= ~LOCKPARENT;
UDEBUG(("Out %d vpp %p/%d lower %p upper %p\n", error, *ap->a_vpp,
- ((*ap->a_vpp) ? (*ap->a_vpp)->v_usecount : -99),
+ ((*ap->a_vpp) ? vrefcnt(*ap->a_vpp) : -99),
lowervp, uppervp));
/*
@@ -649,10 +649,10 @@ union_create(ap)
if (error == 0) {
mp = ap->a_dvp->v_mount;
VOP_UNLOCK(vp, 0, td);
- UDEBUG(("ALLOCVP-1 FROM %p REFS %d\n", vp, vp->v_usecount));
+ UDEBUG(("ALLOCVP-1 FROM %p REFS %d\n", vp, vrefcnt(vp)));
error = union_allocvp(ap->a_vpp, mp, NULLVP, NULLVP,
cnp, vp, NULLVP, 1);
- UDEBUG(("ALLOCVP-2B FROM %p REFS %d\n", *ap->a_vpp, vp->v_usecount));
+ UDEBUG(("ALLOCVP-2B FROM %p REFS %d\n", *ap->a_vpp, vrefcnt(vp)));
}
union_unlock_upper(dvp, td);
}
@@ -1491,10 +1491,10 @@ union_mkdir(ap)
if (error == 0) {
VOP_UNLOCK(vp, 0, td);
- UDEBUG(("ALLOCVP-2 FROM %p REFS %d\n", vp, vp->v_usecount));
+ UDEBUG(("ALLOCVP-2 FROM %p REFS %d\n", vp, vrefcnt(vp)));
error = union_allocvp(ap->a_vpp, ap->a_dvp->v_mount,
ap->a_dvp, NULLVP, cnp, vp, NULLVP, 1);
- UDEBUG(("ALLOCVP-2B FROM %p REFS %d\n", *ap->a_vpp, vp->v_usecount));
+ UDEBUG(("ALLOCVP-2B FROM %p REFS %d\n", *ap->a_vpp, vrefcnt(vp)));
}
}
return (error);
@@ -1723,7 +1723,7 @@ union_lock(ap)
*/
if (un->un_uppervp != NULLVP &&
(flags & LK_TYPE_MASK) == LK_EXCLUSIVE) {
- if ((un->un_flags & UN_ULOCK) == 0 && vp->v_usecount) {
+ if ((un->un_flags & UN_ULOCK) == 0 && vrefcnt(vp)) {
error = vn_lock(un->un_uppervp, flags, td);
if (error) {
struct vop_unlock_args uap = { 0 };
@@ -1760,7 +1760,7 @@ union_unlock(ap)
int error;
#if 0
- KASSERT((un->un_uppervp == NULL || un->un_uppervp->v_usecount > 0), ("uppervp usecount is 0"));
+ KASSERT((un->un_uppervp == NULL || vrefcnt(un->un_uppervp) > 0), ("uppervp usecount is 0"));
#endif
error = vop_stdunlock(ap);
OpenPOWER on IntegriCloud