diff --git a/src/blockstore_flush.cpp b/src/blockstore_flush.cpp index 0b70060b..4ad1b1b2 100644 --- a/src/blockstore_flush.cpp +++ b/src/blockstore_flush.cpp @@ -35,24 +35,14 @@ journal_flusher_co::journal_flusher_co() { bs->live = true; if (data->res != data->iov.iov_len) - { - throw std::runtime_error( - "data read operation failed during flush ("+std::to_string(data->res)+" != "+std::to_string(data->iov.iov_len)+ - "). can't continue, sorry :-(" - ); - } + bs->disk_error_abort("read operation during flush", data->res, data->iov.iov_len); wait_count--; }; simple_callback_w = [this](ring_data_t* data) { bs->live = true; if (data->res != data->iov.iov_len) - { - throw std::runtime_error( - "write operation failed ("+std::to_string(data->res)+" != "+std::to_string(data->iov.iov_len)+ - "). state "+std::to_string(wait_state)+". in-memory state is corrupted. AAAAAAAaaaaaaaaa!!!111" - ); - } + bs->disk_error_abort("write operation during flush", data->res, data->iov.iov_len); wait_count--; }; } diff --git a/src/blockstore_impl.cpp b/src/blockstore_impl.cpp index 7e7748d7..189632e6 100644 --- a/src/blockstore_impl.cpp +++ b/src/blockstore_impl.cpp @@ -676,3 +676,16 @@ void blockstore_impl_t::dump_diagnostics() journal.dump_diagnostics(); flusher->dump_diagnostics(); } + +void blockstore_impl_t::disk_error_abort(const char *op, int retval, int expected) +{ + if (retval == -EAGAIN) + { + fprintf(stderr, "EAGAIN error received from a disk %s during flush." + " It must never happen with io_uring and indicates a kernel bug." + " Please upgrade your kernel. Aborting.\n", op); + exit(1); + } + fprintf(stderr, "Disk %s failed: result is %d, expected %d. Can't continue, sorry :-(\n", op, retval, expected); + exit(1); +} diff --git a/src/blockstore_impl.h b/src/blockstore_impl.h index 89064179..7227e2db 100644 --- a/src/blockstore_impl.h +++ b/src/blockstore_impl.h @@ -292,6 +292,7 @@ class blockstore_impl_t // Journaling void prepare_journal_sector_write(int sector, blockstore_op_t *op); void handle_journal_write(ring_data_t *data, uint64_t flush_id); + void disk_error_abort(const char *op, int retval, int expected); // Asynchronous init int initialized; diff --git a/src/blockstore_journal.cpp b/src/blockstore_journal.cpp index 3c8699d9..37974308 100644 --- a/src/blockstore_journal.cpp +++ b/src/blockstore_journal.cpp @@ -198,10 +198,7 @@ void blockstore_impl_t::handle_journal_write(ring_data_t *data, uint64_t flush_i if (data->res != data->iov.iov_len) { // FIXME: our state becomes corrupted after a write error. maybe do something better than just die - throw std::runtime_error( - "journal write failed ("+std::to_string(data->res)+" != "+std::to_string(data->iov.iov_len)+ - "). in-memory state is corrupted. AAAAAAAaaaaaaaaa!!!111" - ); + disk_error_abort("journal write", data->res, data->iov.iov_len); } auto fl_it = journal.flushing_ops.upper_bound((pending_journaling_t){ .flush_id = flush_id }); if (fl_it != journal.flushing_ops.end() && fl_it->flush_id == flush_id) diff --git a/src/blockstore_write.cpp b/src/blockstore_write.cpp index 607d4563..2274cbbc 100644 --- a/src/blockstore_write.cpp +++ b/src/blockstore_write.cpp @@ -586,10 +586,7 @@ void blockstore_impl_t::handle_write_event(ring_data_t *data, blockstore_op_t *o if (data->res != data->iov.iov_len) { // FIXME: our state becomes corrupted after a write error. maybe do something better than just die - throw std::runtime_error( - "write operation failed ("+std::to_string(data->res)+" != "+std::to_string(data->iov.iov_len)+ - "). in-memory state is corrupted. AAAAAAAaaaaaaaaa!!!111" - ); + disk_error_abort("data write", data->res, data->iov.iov_len); } PRIV(op)->pending_ops--; assert(PRIV(op)->pending_ops >= 0);