Detect more hardware errors

This commit is contained in:
Andrea Mazzoleni 2026-02-22 14:58:06 +01:00
parent f5c07e07f5
commit 077cf5de01
6 changed files with 160 additions and 119 deletions

View file

@ -30,32 +30,12 @@
static const char* es(int err)
{
if (err == EIO)
if (is_hw(err))
return "error_io";
else
return "error";
}
static void log_fatal_errno(int err, const char* name)
{
if (err == EIO) {
log_fatal(err, "DANGER! Unexpected input/output error in disk %s. It isn't possible to continue.\n", name);
} else if (err == EACCES) {
log_fatal(err, "WARNING! Grant permission in the disk %s. It isn't possible to continue.\n", name);
} else if (err == ENOSPC) {
log_fatal(err, "WARNING! Ensure there is free space on the disk %s. It isn't possible to continue.\n", name);
} else {
log_fatal(err, "WARNING! Without a working %s disk, it isn't possible to continue.\n", name);
}
}
static void log_error_errno(int err, const char* name)
{
if (err == EIO) {
log_fatal(err, "DANGER! Unexpected input/output error in disk %s.\n", name);
}
}
static void dry_data_reader(struct snapraid_worker* worker, struct snapraid_task* task)
{
struct snapraid_io* io = worker->io;
@ -102,7 +82,7 @@ static void dry_data_reader(struct snapraid_worker* worker, struct snapraid_task
log_fatal_errno(errno, disk->name);
log_fatal(errno, "Stopping at block %u\n", blockcur);
if (errno == EIO) {
if (is_hw(errno)) {
task->state = TASK_STATE_IOERROR;
} else {
task->state = TASK_STATE_ERROR;
@ -115,7 +95,7 @@ static void dry_data_reader(struct snapraid_worker* worker, struct snapraid_task
ret = handle_open(handle, task->file, state->file_mode, log_error, 0); /* for missing file don't output a message */
if (ret == -1) {
log_tag("%s:%u:%s:%s: Open error. %s.\n", es(errno), blockcur, disk->name, esc_tag(task->file->sub, esc_buffer), strerror(errno));
if (errno == EIO) {
if (is_hw(errno)) {
/* LCOV_EXCL_START */
log_fatal_errno(errno, disk->name);
log_fatal(errno, "Stopping at block %u\n", blockcur);
@ -131,7 +111,7 @@ static void dry_data_reader(struct snapraid_worker* worker, struct snapraid_task
task->read_size = handle_read(handle, task->file_pos, buffer, state->block_size, log_error, 0);
if (task->read_size == -1) {
log_tag("%s:%u:%s:%s: Read error at position %u. %s.\n", es(errno), blockcur, disk->name, esc_tag(task->file->sub, esc_buffer), task->file_pos, strerror(errno));
if (errno == EIO) {
if (is_hw(errno)) {
/* LCOV_EXCL_START */
log_error_errno(errno, disk->name);
task->state = TASK_STATE_IOERROR_CONTINUE;
@ -163,7 +143,7 @@ static void dry_parity_reader(struct snapraid_worker* worker, struct snapraid_ta
ret = parity_read(parity_handle, blockcur, buffer, state->block_size, log_error);
if (ret == -1) {
log_tag("parity_%s:%u:%s: Read error. %s.\n", es(errno), blockcur, lev_config_name(level), strerror(errno));
if (errno == EIO) {
if (is_hw(errno)) {
/* LCOV_EXCL_START */
log_error_errno(errno, lev_config_name(level));
task->state = TASK_STATE_IOERROR_CONTINUE;
@ -406,7 +386,7 @@ bail:
log_tag("%s:%u:%s:%s: Close error. %s.\n", es(errno), blockcur, disk->name, esc_tag(file->sub, esc_buffer), strerror(errno));
log_fatal_errno(errno, disk->name);
if (errno == EIO) {
if (is_hw(errno)) {
++io_error;
} else {
++soft_error;