fellow_cache: latch fellow_cache_seglists_load() errors

parent 87fa0004
......@@ -789,6 +789,16 @@ struct fellow_cache_obj {
#define FCR_ALLOCFAIL(str) FCR_ALLOCERR(FC_ERRSTR(str))
#define FCR_IOFAIL(str) FCR_IOERR(FC_ERRSTR(str))
static inline void
fco_latch_err(struct fellow_cache_obj *fco, struct fellow_cache_res res)
{
assert(res.status != fcr_ok);
if (fco->res.status != fcr_ok)
return;
fco->res = res;
}
const char * const fellow_cache_res_s[FCR_LIM] = {
[fcr_ok] = "ok",
[fcr_allocerr] = "allocation",
......@@ -2144,6 +2154,7 @@ fellow_cache_seglists_load(struct worker *wrk, void *priv)
struct fellow_lru_chgbatch lcb[1] =
FELLOW_LRU_CHGBATCH_INIT(lcb, fco, 1);
struct fellow_cache_res res = FCR_OK(NULL);
// invalidates fclsp, no use after this point
TAKE(mem, fclsp->mem);
......@@ -2182,7 +2193,7 @@ fellow_cache_seglists_load(struct worker *wrk, void *priv)
fdsl = fdsl_mem.ptr;
//if (FC_INJ || fdsl == NULL) {
if (fdsl == NULL) {
err = FC_ERRSTR("disk seglist fdsl alloc failed");
res = FCR_ALLOCFAIL("disk seglist fdsl");
goto err;
}
assert(fdsl_mem.size >= next.size);
......@@ -2190,19 +2201,20 @@ fellow_cache_seglists_load(struct worker *wrk, void *priv)
ssz = fellow_io_pread_sync(fc->ffd, fdsl, next.size, next.off);
//if (FC_INJ || ssz < 0 || (size_t)ssz != next.size) {
if (ssz < 0 || (size_t)ssz != next.size) {
err = FC_ERRSTR("disk seglist read failed");
res = FCR_IOFAIL("disk seglist read");
goto err;
}
err = fellow_disk_seglist_check(fdsl);
if (err != NULL)
if (err != NULL) {
res = FCR_IOFAIL(err);
goto err;
}
fcsl_mem = buddy_alloc1_ptr_extent_wait(fc->membuddy, FEP_META,
SEGLIST_SIZE(fcsl, fdsl->nsegs), 0);
//if (FC_INJ || fcsl_mem.ptr == NULL) {
if (fcsl_mem.ptr == NULL) {
err = FC_ERRSTR("disk seglist fcsl alloc failed");
res = FCR_ALLOCFAIL("disk seglist fcsl");
goto err;
}
......@@ -2251,6 +2263,7 @@ fellow_cache_seglists_load(struct worker *wrk, void *priv)
fellow_cache_seg_transition_locked(lcb, FCO_FCS(fco),
FCO_STATE(fco), FCO_READFAIL);
}
fco_latch_err(fco, res);
refcnt = fellow_cache_obj_deref_locked(lcb, fc, fco);
AZ(pthread_cond_broadcast(&fco->cond));
fellow_cache_lru_chgbatch_apply(lcb);
......@@ -2259,12 +2272,6 @@ fellow_cache_seglists_load(struct worker *wrk, void *priv)
fellow_cache_obj_free(fc, &fco);
else
AZ(pthread_mutex_unlock(&fco->mtx));
// XXX where to store?
(void)err;
// XXX handle
//INCOMPL();
}
static void
......
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