sfemem_iterator: fix readahead for when segments are not yet available

parent 28409980
......@@ -3062,6 +3062,18 @@ fcs_state_read_needwait(enum fcos_state s)
}
}
/*
* ra[] is a ring of pointers to fcses which we (potentially)
* read ahead.
*
* ra[n % mod] is the current fcs, anything after that are read
* aheads.
* ran the next element to be read ahead
*
* c is a cursor tracking the current fcs
* rac is a cursor tracking the read ahead
*
*/
struct fellow_cache_res
fellow_cache_obj_iter(struct fellow_cache *fc, struct fellow_cache_obj *fco,
void *priv, objiterate_f func, int final)
......@@ -3090,26 +3102,30 @@ fellow_cache_obj_iter(struct fellow_cache *fc, struct fellow_cache_obj *fco,
fcsc_init(&c, &fco->seglist);
rac = c;
(void) fcsc_next(&rac);
nextc = rac;
flags = final ? OBJ_ITER_FLUSH : 0;
flush = 0;
while ((fcs = fcsc_next(&c)) != NULL) {
if (ra[n % mod] == NULL) {
assert(n == ran);
fcsra = fcsc_next(&rac);
assert(fcsra == fcs);
ran++;
fellow_cache_seg_ref_in(fc, FCIO_SYNC, &fcs, 1);
ra[n % mod] = fcs;
}
assert(ra[n % mod] == fcs);
raion = 0;
while (ran < n + readahead) {
while (ran <= n + readahead) {
fcsra = fcsc_next(&rac);
if (fcsra == NULL)
break;
ran++;
raio[raion++] = fcsra;
TAKEZN(ra[ran % mod], fcsra);
ran++;
}
if (raion)
fellow_cache_seg_ref_in(fc, FCIO_ASYNC,
......@@ -3153,6 +3169,7 @@ fellow_cache_obj_iter(struct fellow_cache *fc, struct fellow_cache_obj *fco,
* derefn == mod - 1 == 0
*/
AZ(flags & OBJ_ITER_END);
nextc = c;
fcsnext = fcsc_next(&nextc);
flush = 0;
if (fcsnext == NULL || fcsnext->state == FCS_USABLE) {
......
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