diff --git a/HISTORY b/HISTORY index d38df838..c12e5306 100644 --- a/HISTORY +++ b/HISTORY @@ -19,6 +19,8 @@ SnapRAID HISTORY * Added a new -C, --gen-conf option to generate a dummy configuration file from the info in the content file. Just in case that you lose everything, except the content file. + * At the end of sync/scrub/check/fix prints "Everything OK" if no error + was found. This should make clear that everything is really OK. 4.0 2013/9 ========== diff --git a/check.c b/check.c index 83584f79..a2797b0a 100644 --- a/check.c +++ b/check.c @@ -791,7 +791,7 @@ static int state_check_process(struct snapraid_state* state, int check, int fix, } } else { /* if checking or hashing, open the file only for reading */ - ret = handle_open(&handle[j], block_file_get(block), stdlog, state->opt.skip_sequential); + ret = handle_open(&handle[j], block_file_get(block), state->opt.skip_sequential, stdlog); if (ret == -1) { /* save the failed block for the check/fix */ failed[failed_count].is_bad = 1; @@ -1647,7 +1647,7 @@ bail: printf("No unrecoverable errors\n"); } } else { - printf("No error\n"); + printf("Everything OK\n"); } free(failed); diff --git a/dry.c b/dry.c index 4a74f27b..8334765f 100644 --- a/dry.c +++ b/dry.c @@ -78,7 +78,7 @@ static int state_dry_process(struct snapraid_state* state, struct snapraid_parit } /* open the file only for reading */ - ret = handle_open(&handle[j], block_file_get(block), stdlog, state->opt.skip_sequential); + ret = handle_open(&handle[j], block_file_get(block), state->opt.skip_sequential, stdlog); if (ret == -1) { fprintf(stderr, "DANGER! Unexpected open error in a data disk, it isn't possible to rehash.\n"); printf("Stopping at block %u\n", i); @@ -134,7 +134,7 @@ bail: if (error) { printf("%u read errors\n", error); } else { - printf("No error\n"); + printf("Everything OK\n"); } free(handle); diff --git a/handle.c b/handle.c index 1b22474b..85f2f8b7 100644 --- a/handle.c +++ b/handle.c @@ -131,7 +131,7 @@ int handle_create(struct snapraid_handle* handle, struct snapraid_file* file, in return 0; } -int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, FILE* out, int skip_sequential) +int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int skip_sequential, FILE* out) { int ret; int flags; diff --git a/handle.h b/handle.h index 9c69b6d9..297474e7 100644 --- a/handle.h +++ b/handle.h @@ -58,7 +58,7 @@ int handle_create(struct snapraid_handle* handle, struct snapraid_file* file, in * Opens a file. * The file is opened for reading. */ -int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, FILE* out, int skip_sequential); +int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int skip_sequential, FILE* out); /** * Closes a file. diff --git a/scrub.c b/scrub.c index ed713b05..d525c671 100644 --- a/scrub.c +++ b/scrub.c @@ -218,7 +218,7 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par } } - ret = handle_open(&handle[j], block_file_get(block), stderr, state->opt.skip_sequential); + ret = handle_open(&handle[j], block_file_get(block), state->opt.skip_sequential, stderr); if (ret == -1) { fprintf(stdlog, "error:%u:%s:%s: Open error at position %u\n", i, handle[j].disk->name, block_file_get(block)->sub, block_file_pos(block)); ++error; @@ -373,12 +373,12 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par state_progress_end(state, countpos, countmax, countsize); if (error || silent_error) { - printf("%u read/data errors\n", error); - printf("%u silent errors\n", silent_error); + printf("%u read errors\n", error); + printf("%u data errors\n", silent_error); } else { /* print the result only if processed something */ if (countpos != 0) - printf("No error\n"); + printf("Everything OK\n"); } bail: @@ -397,10 +397,10 @@ bail: free(rehandle_alloc); if (state->opt.expect_recoverable) { - if (error == 0) + if (error + silent_error == 0) return -1; } else { - if (error != 0) + if (error + silent_error != 0) return -1; } return 0; diff --git a/snapraid.1 b/snapraid.1 index 3b0df3d6..ae6d0ddb 100644 --- a/snapraid.1 +++ b/snapraid.1 @@ -673,11 +673,14 @@ disk in the free space left in an already used disk. and this option allows you to continue anyway. .TP .B \(hyl, \(hy\(hylog FILE -Outputs a detailed log to the specified file. -It contains the exact specification of which block of +Redirect the detailed log of errors to the specified file. +This log contains the exact specification of which block of any file is not recoverable and why. If this option is not specified, the log is printed in the console using the standard error stream. +When checking and fixing this allows to keep separated +the possible huge list of errors from the human readable +output. .TP .B \(hys, \(hy\(hystart BLKSTART Starts the processing from the specified diff --git a/snapraid.d b/snapraid.d index 558dcefa..3b55c957 100644 --- a/snapraid.d +++ b/snapraid.d @@ -497,11 +497,14 @@ Options option allows you to continue anyway. -l, --log FILE - Outputs a detailed log to the specified file. - It contains the exact specification of which block of + Redirect the detailed log of errors to the specified file. + This log contains the exact specification of which block of any file is not recoverable and why. If this option is not specified, the log is printed in the console using the standard error stream. + When checking and fixing this allows to keep separated + the possible huge list of errors from the human readable + output. -s, --start BLKSTART Starts the processing from the specified diff --git a/snapraid.txt b/snapraid.txt index 12ba6719..f7397580 100644 --- a/snapraid.txt +++ b/snapraid.txt @@ -540,11 +540,14 @@ SnapRAID provides the following options: option allows you to continue anyway. -l, --log FILE - Outputs a detailed log to the specified file. - It contains the exact specification of which block of + Redirect the detailed log of errors to the specified file. + This log contains the exact specification of which block of any file is not recoverable and why. If this option is not specified, the log is printed in the console using the standard error stream. + When checking and fixing this allows to keep separated + the possible huge list of errors from the human readable + output. -s, --start BLKSTART Starts the processing from the specified diff --git a/sync.c b/sync.c index f3c63fc8..4f14da15 100644 --- a/sync.c +++ b/sync.c @@ -53,7 +53,8 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari block_off_t autosavelimit; block_off_t autosavemissing; int ret; - unsigned unrecoverable_error; + unsigned error; + unsigned silent_error; time_t now; unsigned l; @@ -71,7 +72,8 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari buffer = malloc_nofail_vector_align(buffermax, state->block_size, &buffer_alloc); - unrecoverable_error = 0; + error = 0; + silent_error = 0; /* first count the number of blocks to process */ countmax = 0; @@ -202,18 +204,18 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari /* and closing a descriptor should never fail */ fprintf(stderr, "DANGER! Unexpected close error in a data disk, it isn't possible to sync.\n"); printf("Stopping at block %u\n", i); - ++unrecoverable_error; + ++error; goto bail; } } - ret = handle_open(&handle[j], block_file_get(block), stderr, state->opt.skip_sequential); + ret = handle_open(&handle[j], block_file_get(block), state->opt.skip_sequential, stderr); if (ret == -1) { if (errno == ENOENT) { fprintf(stderr, "Missing file '%s'.\n", handle[j].path); fprintf(stderr, "WARNING! You cannot modify data disk during a sync. Rerun the sync command when finished.\n"); - ++unrecoverable_error; + ++error; /* if the file is missing, it means that it was removed during sync */ /* this isn't a serious error, so we skip this block, and continue with others */ @@ -228,7 +230,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari printf("Stopping to allow recovery. Try with 'snapraid check'\n"); } - ++unrecoverable_error; + ++error; goto bail; } @@ -247,7 +249,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari fprintf(stderr, "Unexpected inode change from %"PRIu64" to %"PRIu64" at file '%s'.\n", block_file_get(block)->inode, (uint64_t)handle[j].st.st_ino, handle[j].path); fprintf(stderr, "WARNING! You cannot modify files during a sync. Rerun the sync command when finished.\n"); - ++unrecoverable_error; + ++error; /* if the file is changed, it means that it was modified during sync */ /* this isn't a serious error, so we skip this block, and continue with others */ @@ -259,7 +261,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari if (read_size == -1) { fprintf(stderr, "DANGER! Unexpected read error in a data disk, it isn't possible to sync.\n"); printf("Stopping to allow recovery. Try with 'snapraid check'\n"); - ++unrecoverable_error; + ++error; goto bail; } @@ -282,7 +284,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari fprintf(stderr, "Data error in file '%s' at position '%u'\n", handle[j].path, block_file_pos(block)); fprintf(stderr, "DANGER! Unexpected data error in a data disk, it isn't possible to sync.\n"); printf("Stopping to allow recovery. Try with 'snapraid -s %u check'\n", i); - ++unrecoverable_error; + ++silent_error; goto bail; } } else { @@ -307,7 +309,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari if (ret == -1) { fprintf(stderr, "DANGER! Write error in the %s disk, it isn't possible to sync.\n", lev_name(l)); printf("Stopping at block %u\n", i); - ++unrecoverable_error; + ++error; goto bail; } } @@ -377,12 +379,21 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari state_progress_end(state, countpos, countmax, countsize); + if (error || silent_error) { + printf("%u read/write errors\n", error); + printf("%u data errors\n", silent_error); + } else { + /* print the result only if processed something */ + if (countpos != 0) + printf("Everything OK\n"); + } + bail: for(j=0;jopt.expect_recoverable) { + if (error + silent_error == 0) + return -1; + } else { + if (error + silent_error != 0) + return -1; + } return 0; }