mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 02:49:02 -04:00
Prints a more clear statement that Everything is OK at the end of commands.
This commit is contained in:
parent
5033e1e2f1
commit
013306e325
10 changed files with 59 additions and 32 deletions
2
HISTORY
2
HISTORY
|
|
@ -9,6 +9,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
|
||||
==========
|
||||
|
|
|
|||
4
check.c
4
check.c
|
|
@ -643,7 +643,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;
|
||||
|
|
@ -1537,7 +1537,7 @@ bail:
|
|||
printf("No unrecoverable errors\n");
|
||||
}
|
||||
} else {
|
||||
printf("No error\n");
|
||||
printf("Everything OK\n");
|
||||
}
|
||||
|
||||
free(failed);
|
||||
|
|
|
|||
4
dry.c
4
dry.c
|
|
@ -77,7 +77,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);
|
||||
|
|
@ -142,7 +142,7 @@ bail:
|
|||
if (error) {
|
||||
printf("%u read errors\n", error);
|
||||
} else {
|
||||
printf("No error\n");
|
||||
printf("Everything OK\n");
|
||||
}
|
||||
|
||||
free(handle);
|
||||
|
|
|
|||
2
handle.c
2
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;
|
||||
|
|
|
|||
2
handle.h
2
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.
|
||||
|
|
|
|||
12
scrub.c
12
scrub.c
|
|
@ -217,7 +217,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;
|
||||
|
|
@ -396,12 +396,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:
|
||||
|
|
@ -420,10 +420,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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
44
sync.c
44
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;
|
||||
|
||||
/* get the present time */
|
||||
|
|
@ -70,7 +71,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;
|
||||
|
|
@ -201,18 +203,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 */
|
||||
|
|
@ -227,7 +229,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;
|
||||
}
|
||||
|
||||
|
|
@ -246,7 +248,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 */
|
||||
|
|
@ -258,7 +260,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;
|
||||
}
|
||||
|
||||
|
|
@ -281,7 +283,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 {
|
||||
|
|
@ -305,7 +307,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
if (ret == -1) {
|
||||
fprintf(stderr, "DANGER! Write error in the Parity disk, it isn't possible to sync.\n");
|
||||
printf("Stopping at block %u\n", i);
|
||||
++unrecoverable_error;
|
||||
++error;
|
||||
goto bail;
|
||||
}
|
||||
|
||||
|
|
@ -315,7 +317,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
if (ret == -1) {
|
||||
fprintf(stderr, "DANGER! Write error in the Q-Parity disk, it isn't possible to sync.\n");
|
||||
printf("Stopping at block %u\n", i);
|
||||
++unrecoverable_error;
|
||||
++error;
|
||||
goto bail;
|
||||
}
|
||||
}
|
||||
|
|
@ -385,12 +387,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;j<diskmax;++j) {
|
||||
ret = handle_close(&handle[j]);
|
||||
if (ret == -1) {
|
||||
fprintf(stderr, "DANGER! Unexpected close error in a data disk.\n");
|
||||
++unrecoverable_error;
|
||||
++error;
|
||||
/* continue, as we are already exiting */
|
||||
}
|
||||
}
|
||||
|
|
@ -400,8 +411,13 @@ bail:
|
|||
free(buffer);
|
||||
free(rehandle_alloc);
|
||||
|
||||
if (unrecoverable_error != 0)
|
||||
return -1;
|
||||
if (state->opt.expect_recoverable) {
|
||||
if (error + silent_error == 0)
|
||||
return -1;
|
||||
} else {
|
||||
if (error + silent_error != 0)
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue