From afd29347bbabe9a365d6482bdaab76c1d40ede44 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sat, 2 Jan 2016 17:13:19 +0100 Subject: [PATCH] Restore the io error limit feature for multithread support --- cmdline/scrub.c | 43 ++++++++++++++++++++----------------------- cmdline/sync.c | 17 ++++++++--------- 2 files changed, 28 insertions(+), 32 deletions(-) diff --git a/cmdline/scrub.c b/cmdline/scrub.c index 135b773f..fccedd69 100644 --- a/cmdline/scrub.c +++ b/cmdline/scrub.c @@ -199,17 +199,6 @@ static void scrub_data_reader(struct snapraid_worker* worker, struct snapraid_ta if (task->read_size == -1) { if (errno == EIO) { log_tag("error:%u:%s:%s: Read EIO error at position %u. %s\n", blockcur, disk->name, esc(task->file->sub), task->file_pos, strerror(errno)); -#if 0 - if (io_error >= state->opt.io_error_limit) { - /* LCOV_EXCL_START */ - log_fatal("DANGER! Too many input/output read error in a data disk, it isn't possible to scrub.\n"); - log_fatal("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, handle->path); - log_fatal("Stopping at block %u\n", blockcur); - task->state = TASK_STATE_IOERROR; - return; - /* LCOV_EXCL_STOP */ - } -#endif log_error("Input/Output error in file '%s' at position '%u'\n", handle->path, task->file_pos); task->state = TASK_STATE_IOERROR_CONTINUE; return; @@ -241,18 +230,6 @@ static void scrub_parity_reader(struct snapraid_worker* worker, struct snapraid_ if (ret == -1) { if (errno == EIO) { log_tag("parity_error:%u:%s: Read EIO error. %s\n", blockcur, lev_config_name(level), strerror(errno)); -#if 0 - if (io_error >= state->opt.io_error_limit) { - /* LCOV_EXCL_START */ - log_fatal("DANGER! Too many input/output read error in the %s disk, it isn't possible to scrub.\n", lev_name(level)); - log_fatal("Ensure that disk '%s' is sane and can be read.\n", lev_config_name(level)); - log_fatal("Stopping at block %u\n", blockcur); - task->state = TASK_STATE_IOERROR; - return; - /* LCOV_EXCL_STOP */ - } -#endif - log_error("Input/Output error in parity '%s' at position '%u'\n", lev_config_name(level), blockcur); task->state = TASK_STATE_IOERROR_CONTINUE; return; @@ -440,6 +417,16 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par } if (task->state == TASK_STATE_IOERROR_CONTINUE) { ++io_error; + if (io_error >= state->opt.io_error_limit) { + /* LCOV_EXCL_START */ + log_fatal("DANGER! Too many input/output read error in a data disk, it isn't possible to scrub.\n"); + log_fatal("Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", disk->dir, task->path); + log_fatal("Stopping at block %u\n", blockcur); + goto bail; + /* LCOV_EXCL_STOP */ + } + + /* otherwise continue */ io_error_on_this_block = 1; continue; } @@ -522,6 +509,16 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par } if (task->state == TASK_STATE_IOERROR_CONTINUE) { ++io_error; + if (io_error >= state->opt.io_error_limit) { + /* LCOV_EXCL_START */ + log_fatal("DANGER! Too many input/output read error in the %s disk, it isn't possible to scrub.\n", lev_name(levcur)); + log_fatal("Ensure that disk '%s' is sane and can be read.\n", lev_config_name(levcur)); + log_fatal("Stopping at block %u\n", blockcur); + goto bail; + /* LCOV_EXCL_STOP */ + } + + /* otherwise continue */ io_error_on_this_block = 1; /* if continuing on error, clear the missing buffer */ diff --git a/cmdline/sync.c b/cmdline/sync.c index 0d13c9c8..d38d2432 100644 --- a/cmdline/sync.c +++ b/cmdline/sync.c @@ -595,15 +595,6 @@ static void sync_data_reader(struct snapraid_worker* worker, struct snapraid_tas /* LCOV_EXCL_START */ if (errno == EIO) { log_tag("error:%u:%s:%s: Read EIO error at position %u. %s\n", blockcur, disk->name, esc(task->file->sub), task->file_pos, strerror(errno)); -#if 0 - if (io_error >= state->opt.io_error_limit) { - log_fatal("DANGER! Unexpected input/output read error in a data disk, it isn't possible to sync.\n"); - log_fatal("Ensure that disk '%s' is sane and that file '%s' can be read.\n", disk->dir, handle->path); - log_fatal("Stopping at block %u\n", blockcur); - task->state = TASK_STATE_IOERROR; - return; - } -#endif log_error("Input/Output error in file '%s' at position '%u'\n", handle->path, task->file_pos); task->state = TASK_STATE_IOERROR_CONTINUE; return; @@ -841,6 +832,14 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari } if (task->state == TASK_STATE_IOERROR_CONTINUE) { ++io_error; + if (io_error >= state->opt.io_error_limit) { + log_fatal("DANGER! Unexpected input/output read error in a data disk, it isn't possible to sync.\n"); + log_fatal("Ensure that disk '%s' is sane and that file '%s' can be read.\n", disk->dir, task->path); + log_fatal("Stopping at block %u\n", blockcur); + goto bail; + } + + /* otherwise continue */ io_error_on_this_block = 1; continue; }