logcache needs 2 entries at least

parent b83a2f77
......@@ -1179,6 +1179,8 @@ fellow_logcache_init(struct fellow_logcache *flc, struct fellow_fd *ffd,
n = (typeof(n))sz;
if (n > BUDDY_REQS_MAX)
n = BUDDY_REQS_MAX;
if (n < 2)
n = 2; // fellow_logcache_(take|steal) assume 2 entries
INIT_OBJ(flc, FELLOW_LOGCACHE_MAGIC);
flc->ffd = ffd;
......@@ -1192,7 +1194,8 @@ fellow_logcache_init(struct fellow_logcache *flc, struct fellow_fd *ffd,
sz = n * sizeof *fle;
u = log2up(sz);
l = log2up(sizeof *fle);
cram = (int)l - (int)u;
cram = ((int)l - (int)u) + 1;
assert(cram <= 0);
if (u > UINT8_MAX)
......@@ -1215,7 +1218,7 @@ fellow_logcache_init(struct fellow_logcache *flc, struct fellow_fd *ffd,
for (u = 0; u < sz; u++)
AN(buddy_req_page(reqs, MIN_FELLOW_BITS, 0));
u = buddy_alloc_wait(reqs);
AN(u);
assert(u >= 2);
flc->n = u;
for (fle = flc->alloc_entry.ptr, u = 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