Commit ef400bba authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

vsm: Extract vsm_set_findseg() function

parent 32574ab4
...@@ -790,10 +790,25 @@ VSM_Attach(struct vsm *vd, int progress) ...@@ -790,10 +790,25 @@ VSM_Attach(struct vsm *vd, int progress)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static struct vsm_seg *
vsm_set_findseg(const struct vsm_set *vs, uintptr_t serial)
{
struct vsm_seg *vg;
VTAILQ_FOREACH(vg, &vs->segs, list) {
if (vg->serial == serial)
return (vg);
}
VTAILQ_FOREACH(vg, &vs->stale, list) {
if (vg->serial == serial)
return (vg);
}
return (NULL);
}
static struct vsm_seg * static struct vsm_seg *
vsm_findseg(const struct vsm *vd, const struct vsm_fantom *vf) vsm_findseg(const struct vsm *vd, const struct vsm_fantom *vf)
{ {
struct vsm_set *vs;
struct vsm_seg *vg; struct vsm_seg *vg;
uint64_t x; uint64_t x;
...@@ -807,26 +822,9 @@ vsm_findseg(const struct vsm *vd, const struct vsm_fantom *vf) ...@@ -807,26 +822,9 @@ vsm_findseg(const struct vsm *vd, const struct vsm_fantom *vf)
} }
x = VSM_PRIV_LOW(vf->priv); x = VSM_PRIV_LOW(vf->priv);
vs = vd->mgt; vg = vsm_set_findseg(vd->mgt, x);
VTAILQ_FOREACH(vg, &vs->segs, list) if (vg == NULL)
if (vg->serial == x) vg = vsm_set_findseg(vd->child, x);
break;
if (vg == NULL) {
VTAILQ_FOREACH(vg, &vs->stale, list)
if (vg->serial == x)
break;
}
vs = vd->child;
if (vg == NULL) {
VTAILQ_FOREACH(vg, &vs->segs, list)
if (vg->serial == x)
break;
}
if (vg == NULL) {
VTAILQ_FOREACH(vg, &vs->stale, list)
if (vg->serial == x)
break;
}
if (vg == NULL) if (vg == NULL)
return (NULL); return (NULL);
......
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