Commit 51a82f4b authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Always unmap in VSM_Unmap when refs reaches zero.

Remove the unmap-handling from vsm_refresh_set.

Revert bdd70290 "Always munmap(2) segments when we delete them."
parent ed99b324
......@@ -299,26 +299,6 @@ VSM_ResetError(struct vsm *vd)
VSB_destroy(&vd->diag);
}
/*--------------------------------------------------------------------
*/
static void
vsm_unmap(struct vsm_seg *vg)
{
size_t sz, ps, len;
CHECK_OBJ_NOTNULL(vg, VSM_SEG_MAGIC);
AN(vg->b);
AN(vg->e);
sz = strtoul(vg->av[2], NULL, 10);
assert(sz > 0);
ps = getpagesize();
len = RUP2(sz, ps);
AZ(munmap(vg->b, len));
vg->b = NULL;
vg->e = NULL;
}
/*--------------------------------------------------------------------
*/
......@@ -490,8 +470,6 @@ vsm_refresh_set(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb)
vg->stale = 1;
VTAILQ_INSERT_TAIL(&vs->stale, vg, list);
} else {
if (vg->b != NULL)
vsm_unmap(vg);
VAV_Free(vg->av);
FREE_OBJ(vg);
}
......@@ -724,6 +702,7 @@ int
VSM_Unmap(struct vsm *vd, struct vsm_fantom *vf)
{
struct vsm_seg *vg;
size_t sz, ps, len;
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
AN(vd->attached);
......@@ -738,12 +717,18 @@ VSM_Unmap(struct vsm *vd, struct vsm_fantom *vf)
vf->e = NULL;
if (vg->refs > 0)
return(0);
AN(vg->b);
AN(vg->e);
sz = strtoul(vg->av[2], NULL, 10);
assert(sz > 0);
ps = getpagesize();
len = RUP2(sz, ps);
AZ(munmap(vg->b, len));
vg->b = vg->e = NULL;
if (vg->stale) {
VTAILQ_REMOVE(&vg->set->stale, vg, list);
VAV_Free(vg->av);
FREE_OBJ(vg);
} else {
vsm_unmap(vg);
}
return (0);
}
......
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