fellow_cache: Factor out seglist loading wait

parent 8606e06b
......@@ -2297,6 +2297,16 @@ fellow_cache_seglists_need(const struct fellow_cache *fc,
AZ(fc->taskrun(fellow_cache_seglists_load, fclsp, &fclsp->state));
}
static void
fellow_cache_seglists_wait_locked(struct fellow_cache_obj *fco)
{
CHECK_OBJ_NOTNULL(fco, FELLOW_CACHE_OBJ_MAGIC);
while (fco->seglstate == SEGL_LOADING)
AZ(pthread_cond_wait(&fco->cond, &fco->mtx));
assert(fco->seglstate == SEGL_DONE || fco->seglstate == SEGL_NEED);
}
/*
* MEM LAYOUT
*
......@@ -3734,9 +3744,7 @@ fellow_cache_obj_slim(const struct fellow_cache *fc,
AZ(pthread_mutex_lock(&fco->mtx));
// we wait for loading complete to be able to ignore pending
while (fco->seglstate == SEGL_LOADING)
AZ(pthread_cond_wait(&fco->cond, &fco->mtx));
assert(fco->seglstate == SEGL_DONE || fco->seglstate == SEGL_NEED);
fellow_cache_seglists_wait_locked(fco);
/* anything to do at all? */
while ((fcs = fcsc_next_ignore_pending(&c)) != 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