Commit 5f97b89a authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Avoid lock/unlock/lock/unlock for cluster delete

parent 3c22a616
...@@ -281,7 +281,6 @@ VSMW_DestroyCluster(struct vsmw *vsmw, struct vsmw_cluster **vsmcp) ...@@ -281,7 +281,6 @@ VSMW_DestroyCluster(struct vsmw *vsmw, struct vsmw_cluster **vsmcp)
{ {
struct vsmw_cluster *vc; struct vsmw_cluster *vc;
vsmw_lock();
CHECK_OBJ_NOTNULL(vsmw, VSMW_MAGIC); CHECK_OBJ_NOTNULL(vsmw, VSMW_MAGIC);
TAKE_OBJ_NOTNULL(vc, vsmcp, VSMW_CLUSTER_MAGIC); TAKE_OBJ_NOTNULL(vc, vsmcp, VSMW_CLUSTER_MAGIC);
...@@ -294,11 +293,9 @@ VSMW_DestroyCluster(struct vsmw *vsmw, struct vsmw_cluster **vsmcp) ...@@ -294,11 +293,9 @@ VSMW_DestroyCluster(struct vsmw *vsmw, struct vsmw_cluster **vsmcp)
*/ */
vsmw_delseg(vsmw, vc->cseg, 1); vsmw_delseg(vsmw, vc->cseg, 1);
vc->cseg = NULL; vc->cseg = NULL;
if (vc->refs > 0) { if (vc->refs > 0)
vsmw_unlock();
return; return;
} }
}
AZ(munmap(vc->ptr, vc->len)); AZ(munmap(vc->ptr, vc->len));
AZ(vc->refs); AZ(vc->refs);
...@@ -307,7 +304,6 @@ VSMW_DestroyCluster(struct vsmw *vsmw, struct vsmw_cluster **vsmcp) ...@@ -307,7 +304,6 @@ VSMW_DestroyCluster(struct vsmw *vsmw, struct vsmw_cluster **vsmcp)
assert (errno == ENOENT); assert (errno == ENOENT);
REPLACE(vc->fn, NULL); REPLACE(vc->fn, NULL);
FREE_OBJ(vc); FREE_OBJ(vc);
vsmw_unlock();
} }
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
...@@ -369,26 +365,24 @@ void ...@@ -369,26 +365,24 @@ void
VSMW_Free(struct vsmw *vsmw, void **pp) VSMW_Free(struct vsmw *vsmw, void **pp)
{ {
struct vsmwseg *seg; struct vsmwseg *seg;
void *p; struct vsmw_cluster *cp;
vsmw_lock(); vsmw_lock();
CHECK_OBJ_NOTNULL(vsmw, VSMW_MAGIC); CHECK_OBJ_NOTNULL(vsmw, VSMW_MAGIC);
AN(pp); AN(pp);
p = *pp;
AN(p);
*pp = NULL;
VTAILQ_FOREACH(seg, &vsmw->segs, list) VTAILQ_FOREACH(seg, &vsmw->segs, list)
if (seg->ptr == p) if (seg->ptr == *pp)
break; break;
AN(seg); AN(seg);
*pp = NULL;
if (!--seg->cluster->refs && seg->cluster->cseg == NULL) { cp = seg->cluster;
vsmw_unlock();
VSMW_DestroyCluster(vsmw, &seg->cluster);
vsmw_lock();
}
vsmw_delseg(vsmw, seg, 1); vsmw_delseg(vsmw, seg, 1);
if (!--cp->refs && cp->cseg == NULL)
VSMW_DestroyCluster(vsmw, &cp);
vsmw_unlock(); vsmw_unlock();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment