mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
In sync if a silent error is detect marks the block as bad like in scrub.
This commit is contained in:
parent
1f0da860c7
commit
7014486bb7
3 changed files with 26 additions and 11 deletions
2
HISTORY
2
HISTORY
|
|
@ -10,6 +10,8 @@ SnapRAID HISTORY
|
|||
up to 89 disks with Hexa (6) parity is possible, but not yet implemented.
|
||||
Note that more general approaches without these limitations are also
|
||||
possible, but they would affect badly the performance.
|
||||
* In sync, if a silent error is found, directly mark the block as bad
|
||||
just like in scrub, and continue with the sync process.
|
||||
* Sort files by inode when listing the directory. This improves
|
||||
performance in scanning.
|
||||
* Removed the detailed list of errors from the screen output.
|
||||
|
|
|
|||
6
TODO
6
TODO
|
|
@ -5,12 +5,14 @@ This is the list of TODO items for SnapRAID.
|
|||
|
||||
- Next
|
||||
|
||||
* In sync if a data error is found, we can mark the block as bad, like in scrub
|
||||
and allow sync to continue.
|
||||
* Remove/Reduce the opt.gui uses. We can now always output to stdlog becase
|
||||
it never go to screen.
|
||||
|
||||
* Detect files moved from one disk to another. We won't be able to reuse
|
||||
parity, but we can reuse the hash to check that the file was moved
|
||||
correctly.
|
||||
We can assume a file moved to another disk if it has the same name, size,
|
||||
and timestamp. Directory and inode can be different.
|
||||
|
||||
* Add a way to list the content of the array. A new "list" command ?
|
||||
Something similar at "diff" and "dup".
|
||||
|
|
|
|||
29
sync.c
29
sync.c
|
|
@ -122,7 +122,8 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
for(i=blockstart;i<blockmax;++i) {
|
||||
int one_invalid;
|
||||
int one_valid;
|
||||
int skip_this_block;
|
||||
int error_on_this_block;
|
||||
int silent_error_on_this_block;
|
||||
int parity_needs_to_be_updated;
|
||||
int ret;
|
||||
snapraid_info info;
|
||||
|
|
@ -171,7 +172,8 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
--autosavemissing;
|
||||
|
||||
/* by default process the block, and skip it if something go wrong */
|
||||
skip_this_block = 0;
|
||||
error_on_this_block = 0;
|
||||
silent_error_on_this_block = 0;
|
||||
|
||||
/* if we have to use the old hash */
|
||||
info = info_get(&state->infoarr, i);
|
||||
|
|
@ -245,7 +247,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
|
||||
/* 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 */
|
||||
skip_this_block = 1;
|
||||
error_on_this_block = 1;
|
||||
continue;
|
||||
} else if (errno == EACCES) {
|
||||
fprintf(stderr, "No access at file '%s'.\n", handle[j].path);
|
||||
|
|
@ -279,7 +281,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
|
||||
/* 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 */
|
||||
skip_this_block = 1;
|
||||
error_on_this_block = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -307,11 +309,17 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
if (block_has_updated_hash(block)) {
|
||||
/* compare the hash */
|
||||
if (memcmp(hash, block->hash, HASH_SIZE) != 0) {
|
||||
fprintf(stdlog, "error:%u:%s:%s: Data error at position %u\n", i, handle[j].disk->name, block_file_get(block)->sub, block_file_pos(block));
|
||||
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);
|
||||
fprintf(stderr, "DANGER! Unexpected data error in a data disk! The block is now marked as bad!\n");
|
||||
fprintf(stderr, "Try with 'snapraid -e fix' to recover!\n");
|
||||
|
||||
/* silent errors are very rare, and are not a signal that a disk */
|
||||
/* is going to fail. So, we just continue marking the block as bad */
|
||||
/* just like in scrub */
|
||||
++silent_error;
|
||||
goto bail;
|
||||
silent_error_on_this_block = 1;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
/* if until now the parity doesn't need to be update */
|
||||
|
|
@ -343,8 +351,8 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
}
|
||||
}
|
||||
|
||||
/* if we have read all the data required, proceed with the parity */
|
||||
if (!skip_this_block) {
|
||||
/* if we have read all the data required and it's correct, proceed with the parity */
|
||||
if (!error_on_this_block && !silent_error_on_this_block) {
|
||||
|
||||
/* updates the parity only if really needed */
|
||||
if (parity_needs_to_be_updated) {
|
||||
|
|
@ -402,6 +410,9 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
/* we are also clearing any previous bad and rehash flag */
|
||||
info_set(&state->infoarr, i, info_make(now, 0, 0));
|
||||
}
|
||||
} else if (silent_error_on_this_block) {
|
||||
/* set the error status keeping the existing time and hash */
|
||||
info_set(&state->infoarr, i, info_set_bad(info));
|
||||
}
|
||||
|
||||
/* mark the state as needing write */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue