Unverified Commit a9700c63 authored by Nils Goroll's avatar Nils Goroll

Improve IO error erporting

Ref #65
parent 9aaaf1fd
...@@ -788,6 +788,11 @@ struct fellow_cache_obj { ...@@ -788,6 +788,11 @@ struct fellow_cache_obj {
(struct fellow_cache_res){.r.err = (str), .status = fcr_ioerr} (struct fellow_cache_res){.r.err = (str), .status = fcr_ioerr}
#define FCR_ALLOCFAIL(str) FCR_ALLOCERR(FC_ERRSTR(str)) #define FCR_ALLOCFAIL(str) FCR_ALLOCERR(FC_ERRSTR(str))
#define FCR_IOFAIL(str) FCR_IOERR(FC_ERRSTR(str)) #define FCR_IOFAIL(str) FCR_IOERR(FC_ERRSTR(str))
#define FCR_IOFAILHOW(str, have, want) \
((have) < 0 ? errno = -(have), FCR_IOFAIL(str " error") \
: ((have) == 0 ? FCR_IOFAIL(str " zero") \
: ((have) < (want) ? FCR_IOFAIL(str " short") \
: FCR_IOFAIL(str " other"))))
const char * const fellow_cache_res_s[FCR_LIM] = { const char * const fellow_cache_res_s[FCR_LIM] = {
[fcr_ok] = "ok", [fcr_ok] = "ok",
...@@ -2213,7 +2218,8 @@ fellow_cache_seglists_load(struct worker *wrk, void *priv) ...@@ -2213,7 +2218,8 @@ fellow_cache_seglists_load(struct worker *wrk, void *priv)
ssz = fellow_io_pread_sync(fc->ffd, fdsl, next.size, next.off); ssz = fellow_io_pread_sync(fc->ffd, fdsl, next.size, next.off);
if (FC_INJ || ssz < 0 || (size_t)ssz != next.size) { if (FC_INJ || ssz < 0 || (size_t)ssz != next.size) {
fcr = FCR_IOFAIL("disk seglist read"); fcr = FCR_IOFAILHOW("disk seglist read",
(size_t)ssz, next.size);
goto err; goto err;
} }
err = fellow_disk_seglist_check(fdsl); err = fellow_disk_seglist_check(fdsl);
...@@ -3390,7 +3396,8 @@ fellow_cache_read_complete(struct fellow_cache *fc, void *ptr, int32_t result) ...@@ -3390,7 +3396,8 @@ fellow_cache_read_complete(struct fellow_cache *fc, void *ptr, int32_t result)
assert(fcs->alloc.size <= INT32_MAX); assert(fcs->alloc.size <= INT32_MAX);
if (FC_INJ || result < (int32_t)fcs->alloc.size) { if (FC_INJ || result < (int32_t)fcs->alloc.size) {
fcr = FCR_IOFAIL("fcs read error"); fcr = FCR_IOFAILHOW("fcs read",
result, (int32_t)fcs->alloc.size);
fcos_next = (typeof(fcos_next))FCOS_READFAIL; fcos_next = (typeof(fcos_next))FCOS_READFAIL;
} }
else { else {
...@@ -3465,8 +3472,10 @@ fellow_cache_async_write_complete(struct fellow_cache *fc, ...@@ -3465,8 +3472,10 @@ fellow_cache_async_write_complete(struct fellow_cache *fc,
assert(fcs->alloc.size <= INT32_MAX); assert(fcs->alloc.size <= INT32_MAX);
if (FC_INJ || result < (int32_t)fcs->alloc.size) if (FC_INJ || result < (int32_t)fcs->alloc.size) {
fcr = FCR_IOFAIL("fcs write error"); fcr = FCR_IOFAILHOW("fcs write", result,
(int32_t)fcs->alloc.size);
}
else else
fcr = FCR_OK(fco); fcr = FCR_OK(fco);
...@@ -3482,8 +3491,10 @@ fellow_cache_async_write_complete(struct fellow_cache *fc, ...@@ -3482,8 +3491,10 @@ fellow_cache_async_write_complete(struct fellow_cache *fc,
} }
} else { } else {
assert(type == FBIO_SEGLIST); assert(type == FBIO_SEGLIST);
if (FC_INJ || result < (int32_t)fbio->u.seglist.reg.size) if (FC_INJ || result < (int32_t)fbio->u.seglist.reg.size) {
fcr = FCR_IOFAIL("seglist write error"); fcr = FCR_IOFAILHOW("seglist write",
result, (int32_t)fbio->u.seglist.reg.size);
}
else else
fcr = FCR_OK(fco); fcr = FCR_OK(fco);
} }
......
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