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)
{
struct vsmw_cluster *vc;
vsmw_lock();
CHECK_OBJ_NOTNULL(vsmw, VSMW_MAGIC);
TAKE_OBJ_NOTNULL(vc, vsmcp, VSMW_CLUSTER_MAGIC);
......@@ -294,10 +293,8 @@ VSMW_DestroyCluster(struct vsmw *vsmw, struct vsmw_cluster **vsmcp)
*/
vsmw_delseg(vsmw, vc->cseg, 1);
vc->cseg = NULL;
if (vc->refs > 0) {
vsmw_unlock();
if (vc->refs > 0)
return;
}
}
AZ(munmap(vc->ptr, vc->len));
......@@ -307,7 +304,6 @@ VSMW_DestroyCluster(struct vsmw *vsmw, struct vsmw_cluster **vsmcp)
assert (errno == ENOENT);
REPLACE(vc->fn, NULL);
FREE_OBJ(vc);
vsmw_unlock();
}
/*--------------------------------------------------------------------*/
......@@ -369,26 +365,24 @@ void
VSMW_Free(struct vsmw *vsmw, void **pp)
{
struct vsmwseg *seg;
void *p;
struct vsmw_cluster *cp;
vsmw_lock();
CHECK_OBJ_NOTNULL(vsmw, VSMW_MAGIC);
AN(pp);
p = *pp;
AN(p);
*pp = NULL;
VTAILQ_FOREACH(seg, &vsmw->segs, list)
if (seg->ptr == p)
if (seg->ptr == *pp)
break;
AN(seg);
*pp = NULL;
if (!--seg->cluster->refs && seg->cluster->cseg == NULL) {
vsmw_unlock();
VSMW_DestroyCluster(vsmw, &seg->cluster);
vsmw_lock();
}
cp = seg->cluster;
vsmw_delseg(vsmw, seg, 1);
if (!--cp->refs && cp->cseg == NULL)
VSMW_DestroyCluster(vsmw, &cp);
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