summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authoravg <avg@FreeBSD.org>2018-04-19 06:03:50 +0000
committeravg <avg@FreeBSD.org>2018-04-19 06:03:50 +0000
commite56e26ee8f0642f8e321cf245762af48da6d62bd (patch)
tree4b269385ccf36d6d19e00fde022ba2bf29e89407 /sys/kern
parent84be9809679970a7258d3e14432fc6562a459444 (diff)
downloadFreeBSD-src-e56e26ee8f0642f8e321cf245762af48da6d62bd.zip
FreeBSD-src-e56e26ee8f0642f8e321cf245762af48da6d62bd.tar.gz
MFC r331666: ZFS vn_rele_async: catch up with the use of refcount(9) for the vnode use count
It's not sufficient nor required to use the vnode interlock when checking if we are going to drop the last use count as the code in vputx() uses refcount (atomic) operations for both checking and decrementing the use code. Apply the same method to vn_rele_async(). While here, remove vn_rele_inactive(), a wrapper around vrele() that didn't add any value. Also, the change required making vfs_refcount_release_if_not_last() public. I've made vfs_refcount_acquire_if_not_zero() public as well. They are in sys/refcount.h now. While making the move I've dropped the vfs_ prefix. Sponsored by: Panzura
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/vfs_subr.c41
1 files changed, 5 insertions, 36 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 8ef878e..b4f9374 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -2389,37 +2389,6 @@ reassignbuf(struct buf *bp)
BO_UNLOCK(bo);
}
-/*
- * A temporary hack until refcount_* APIs are sorted out.
- */
-static __inline int
-vfs_refcount_acquire_if_not_zero(volatile u_int *count)
-{
- u_int old;
-
- old = *count;
- for (;;) {
- if (old == 0)
- return (0);
- if (atomic_fcmpset_int(count, &old, old + 1))
- return (1);
- }
-}
-
-static __inline int
-vfs_refcount_release_if_not_last(volatile u_int *count)
-{
- u_int old;
-
- old = *count;
- for (;;) {
- if (old == 1)
- return (0);
- if (atomic_fcmpset_int(count, &old, old - 1))
- return (1);
- }
-}
-
static void
v_init_counters(struct vnode *vp)
{
@@ -2459,7 +2428,7 @@ v_incr_usecount(struct vnode *vp)
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
if (vp->v_type != VCHR &&
- vfs_refcount_acquire_if_not_zero(&vp->v_usecount)) {
+ refcount_acquire_if_not_zero(&vp->v_usecount)) {
VNASSERT((vp->v_iflag & VI_OWEINACT) == 0, vp,
("vnode with usecount and VI_OWEINACT set"));
} else {
@@ -2551,7 +2520,7 @@ vget(struct vnode *vp, int flags, struct thread *td)
* Upgrade our holdcnt to a usecount.
*/
if (vp->v_type == VCHR ||
- !vfs_refcount_acquire_if_not_zero(&vp->v_usecount)) {
+ !refcount_acquire_if_not_zero(&vp->v_usecount)) {
VI_LOCK(vp);
if ((vp->v_iflag & VI_OWEINACT) == 0) {
oweinact = 0;
@@ -2654,7 +2623,7 @@ vputx(struct vnode *vp, int func)
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
if (vp->v_type != VCHR &&
- vfs_refcount_release_if_not_last(&vp->v_usecount)) {
+ refcount_release_if_not_last(&vp->v_usecount)) {
if (func == VPUTX_VPUT)
VOP_UNLOCK(vp, 0);
vdrop(vp);
@@ -2770,7 +2739,7 @@ _vhold(struct vnode *vp, bool locked)
ASSERT_VI_UNLOCKED(vp, __func__);
CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
if (!locked) {
- if (vfs_refcount_acquire_if_not_zero(&vp->v_holdcnt)) {
+ if (refcount_acquire_if_not_zero(&vp->v_holdcnt)) {
VNASSERT((vp->v_iflag & VI_FREE) == 0, vp,
("_vhold: vnode with holdcnt is free"));
return;
@@ -2831,7 +2800,7 @@ _vdrop(struct vnode *vp, bool locked)
if ((int)vp->v_holdcnt <= 0)
panic("vdrop: holdcnt %d", vp->v_holdcnt);
if (!locked) {
- if (vfs_refcount_release_if_not_last(&vp->v_holdcnt))
+ if (refcount_release_if_not_last(&vp->v_holdcnt))
return;
VI_LOCK(vp);
}
OpenPOWER on IntegriCloud