Refactor out log block assignment from buddy reqs

Ref #28
parent 5b459d50
......@@ -2113,6 +2113,23 @@ logblocks_alloc_from_logregion(struct fellow_log_region *logreg,
return (i);
}
static void
log_blocks_alloc_from_reqs(struct buddy_reqs *reqs,
struct fellow_alloc_log_block **arr, unsigned *n)
{
uint8_t nreq, r;
nreq = BUDDYF(alloc_async_ready)(reqs);
for (r = 0; r < nreq; (*arr)++, (*n)--) {
if ((*arr)->off > 0)
continue;
(*arr)->off = buddy_get_off_page(reqs, r++).off;
assert((*arr)->off > 0);
FDBG(D_LOG_ALLOC, "next[extra] = %zu", (*arr)->off);
}
}
static void
logbuffer_alloc(const struct fellow_logbuffer *lbuf,
struct fellow_alloc_log_block *arr, unsigned n)
......@@ -2159,17 +2176,13 @@ logbuffer_alloc(const struct fellow_logbuffer *lbuf,
}
if (nreq == 0)
break;
// XXX should not wait here
r = buddy_alloc_wait(reqs);
assert(r == nreq);
assert(r <= n);
log_blocks_alloc_from_reqs(reqs, &arr, &n);
for (r = 0; r < nreq; arr++, n--) {
if (arr->off > 0)
continue;
arr->off = buddy_get_off_page(reqs, r++).off;
assert(arr->off > 0);
FDBG(D_LOG_ALLOC, "next[extra] = %zu", arr->off);
}
buddy_alloc_wait_done(reqs);
}
}
......
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