fellow_logcache: for prefetch, do not wait for allocations

parent 38fa9b39
......@@ -1234,9 +1234,6 @@ fellow_logcache_init(struct fellow_logcache *flc, struct fellow_fd *ffd,
VTAILQ_INSERT_TAIL(&flc->free, fle, list);
}
//XXX
(void) flc_mempool_avail(flc->mempool);
fellow_fd_ioctx_get(ffd, &flc->fdil);
}
......@@ -1309,9 +1306,13 @@ fellow_logcache_steal(struct fellow_logcache *flc, int direction)
return (fle);
}
/* get an element from the free list, if any */
/*
* get an element from the free list, if any
*
* prefetch uses it with need == 0 to not wait for allocations
*/
static struct fellow_logcache_entry *
fellow_logcache_take(struct fellow_logcache *flc, int direction)
fellow_logcache_take(struct fellow_logcache *flc, int direction, int need)
{
struct fellow_logcache_entry *fle;
......@@ -1320,6 +1321,9 @@ fellow_logcache_take(struct fellow_logcache *flc, int direction)
if (fle == NULL)
return (fellow_logcache_steal(flc, direction));
if (need == 0 && ! flc_mempool_avail(flc->mempool))
return (NULL);
VTAILQ_REMOVE(&flc->free, fle, list);
AZ(fle->alloc.ptr);
......@@ -1489,7 +1493,7 @@ fellow_logcache_prefetch(struct fellow_logcache *flc,
}
if (noff == 0)
break;
next = fellow_logcache_take(flc, direction);
next = fellow_logcache_take(flc, direction, 0);
if (next == NULL)
break;
//DBG("%zu %s", noff, direction < 0 ? "<-" : "->");
......@@ -1528,7 +1532,7 @@ fellow_logcache_get(struct fellow_logcache *flc, off_t off, int direction,
if (flc->current == NULL) {
DBG("1st %zu %s", off, direction < 0 ? "<-" : "->");
fle = fellow_logcache_take(flc, direction);
fle = fellow_logcache_take(flc, direction, 1);
AN(fle);
flc->current = fle;
assert(VTAILQ_EMPTY(&flc->used));
......@@ -1546,7 +1550,7 @@ fellow_logcache_get(struct fellow_logcache *flc, off_t off, int direction,
CHECK_OBJ_ORNULL(fle, FELLOW_LOGCACHE_ENTRY_MAGIC);
if (fle == NULL) {
DBG("miss %zu %s", off, direction < 0 ? "<-" : "->");
fle = fellow_logcache_take(flc, direction);
fle = fellow_logcache_take(flc, direction, 1);
AN(fle);
fellow_logcache_insert(flc, flc->current,
fle, direction);
......
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