Adds more logging in scrub and sync.

This commit is contained in:
Andrea Mazzoleni 2013-10-21 21:56:53 +02:00
parent 6c3d84d775
commit c95917ecfe
4 changed files with 43 additions and 24 deletions

35
sync.c
View file

@ -230,7 +230,9 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
if (ret == -1) {
/* This one is really an unexpected error, because we are only reading */
/* and closing a descriptor should never fail */
fprintf(stdlog, "error:%u:%s:%s: Close error. %s\n", i, handle[j].disk->name, handle[j].file->sub, strerror(errno));
fprintf(stderr, "DANGER! Unexpected close error in a data disk, it isn't possible to sync.\n");
fprintf(stderr, "Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", handle[j].disk->dir, handle[j].path);
printf("Stopping at block %u\n", i);
++error;
goto bail;
@ -240,8 +242,10 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
ret = handle_open(&handle[j], block_file_get(block), state->opt.skip_sequential, stderr);
if (ret == -1) {
if (errno == ENOENT) {
fprintf(stdlog, "error:%u:%s:%s: Open missing error\n", i, handle[j].disk->name, handle[j].file->sub);
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");
fprintf(stderr, "WARNING! You cannot modify data disk during a sync.\n");
fprintf(stderr, "Rerun the sync command when finished.\n");
++error;
@ -250,12 +254,21 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
error_on_this_block = 1;
continue;
} else if (errno == EACCES) {
fprintf(stdlog, "error:%u:%s:%s: Open access error\n", i, handle[j].disk->name, handle[j].file->sub);
fprintf(stderr, "No access at file '%s'.\n", handle[j].path);
fprintf(stderr, "WARNING! Please fix the access permission in the data disk.\n");
printf("Stopping at block %u\n", i);
fprintf(stderr, "Rerun the sync command when finished.\n");
++error;
/* this isn't a serious error, so we skip this block, and continue with others */
error_on_this_block = 1;
continue;
} else {
fprintf(stdlog, "error:%u:%s:%s: Open error. %s\n", i, handle[j].disk->name, handle[j].file->sub, strerror(errno));
fprintf(stderr, "DANGER! Unexpected open error in a data disk, it isn't possible to sync.\n");
printf("Stopping to allow recovery. Try with 'snapraid check'\n");
fprintf(stderr, "Ensure that disk '%s' is sane and that file '%s' can be accessed.\n", handle[j].disk->dir, handle[j].path);
printf("Stopping to allow recovery. Try with 'snapraid check -f %s'\n", handle[j].file->sub);
}
++error;
@ -268,6 +281,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|| STAT_NSEC(&handle[j].st) != block_file_get(block)->mtime_nsec
|| handle[j].st.st_ino != block_file_get(block)->inode
) {
fprintf(stdlog, "error:%u:%s:%s: Unexpected change\n", i, handle[j].disk->name, handle[j].file->sub);
if (handle[j].st.st_size != block_file_get(block)->size)
fprintf(stderr, "Unexpected size change at file '%s'.\n", handle[j].path);
else if (handle[j].st.st_mtime != block_file_get(block)->mtime_sec
@ -275,7 +289,8 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
fprintf(stderr, "Unexpected time change at file '%s'.\n", handle[j].path);
else
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");
fprintf(stderr, "WARNING! You cannot modify files during a sync.\n");
fprintf(stderr, "Rerun the sync command when finished.\n");
++error;
@ -287,8 +302,10 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
read_size = handle_read(&handle[j], block, buffer[j], state->block_size, stderr);
if (read_size == -1) {
fprintf(stdlog, "error:%u:%s:%s: Read error at position %u\n", i, handle[j].disk->name, handle[j].file->sub, block_file_pos(block));
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");
fprintf(stderr, "Ensure that disk '%s' is sane and that file '%s' can be read.\n", handle[j].disk->dir, handle[j].path);
printf("Stopping to allow recovery. Try with 'snapraid check -f %s'\n", handle[j].file->sub);
++error;
goto bail;
}
@ -309,9 +326,9 @@ 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! The block is now marked as bad!\n");
fprintf(stdlog, "error:%u:%s:%s: Data error at position %u\n", i, handle[j].disk->name, handle[j].file->sub, block_file_pos(block));
fprintf(stderr, "Data error at file '%s' at position '%u'\n", handle[j].path, block_file_pos(block));
fprintf(stderr, "WARNING! 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 */
@ -363,7 +380,9 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
for(l=0;l<state->level;++l) {
ret = parity_write(parity[l], i, buffer[diskmax+l], state->block_size);
if (ret == -1) {
fprintf(stdlog, "parity_error:%u:%s: Write error\n", i, lev_config_name(l));
fprintf(stderr, "DANGER! Write error in the %s disk, it isn't possible to sync.\n", lev_name(l));
fprintf(stderr, "Ensure that disk '%s' is sane.\n", lev_config_name(l));
printf("Stopping at block %u\n", i);
++error;
goto bail;