mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-04 13:50:09 -05:00
If a file is modified during a sync, the sync will continue.
This commit is contained in:
parent
f87667445a
commit
faa9559fe5
2 changed files with 51 additions and 26 deletions
6
HISTORY
6
HISTORY
|
|
@ -1,6 +1,12 @@
|
||||||
SnapRAID HISTORY
|
SnapRAID HISTORY
|
||||||
================
|
================
|
||||||
|
|
||||||
|
1.7 2011/9
|
||||||
|
==========
|
||||||
|
* If a file is modified or removed during a sync, the sync process doesn't
|
||||||
|
stop anymore, but it will simply skip the file, resulting in an incomplete
|
||||||
|
sync. Note that the sync will terminate with an error.
|
||||||
|
|
||||||
1.6 2011/9 - THIS UPDATE IS HIGHLY RECOMMENDED!
|
1.6 2011/9 - THIS UPDATE IS HIGHLY RECOMMENDED!
|
||||||
===============================================
|
===============================================
|
||||||
* The content file is now saved also at the start of the "sync" command.
|
* The content file is now saved also at the start of the "sync" command.
|
||||||
|
|
|
||||||
71
sync.c
71
sync.c
|
|
@ -87,6 +87,7 @@ static int state_sync_process(struct snapraid_state* state, int parity_f, int qa
|
||||||
state_progress_begin(state, blockstart, blockmax, countmax);
|
state_progress_begin(state, blockstart, blockmax, countmax);
|
||||||
for(i=blockstart;i<blockmax;++i) {
|
for(i=blockstart;i<blockmax;++i) {
|
||||||
int one_invalid;
|
int one_invalid;
|
||||||
|
int skip_this_block;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* for each disk */
|
/* for each disk */
|
||||||
|
|
@ -103,6 +104,9 @@ static int state_sync_process(struct snapraid_state* state, int parity_f, int qa
|
||||||
if (!one_invalid)
|
if (!one_invalid)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/* by default process the block, and skip it if something go wrong */
|
||||||
|
skip_this_block = 0;
|
||||||
|
|
||||||
/* for each disk, process the block */
|
/* for each disk, process the block */
|
||||||
for(j=0;j<diskmax;++j) {
|
for(j=0;j<diskmax;++j) {
|
||||||
int read_size;
|
int read_size;
|
||||||
|
|
@ -134,7 +138,13 @@ static int state_sync_process(struct snapraid_state* state, int parity_f, int qa
|
||||||
if (errno == ENOENT) {
|
if (errno == ENOENT) {
|
||||||
fprintf(stderr, "Missing file '%s'.\n", handle[j].path);
|
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. Rerun the sync command when finished.\n");
|
||||||
printf("Stopping at block %u\n", i);
|
|
||||||
|
++unrecoverable_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 */
|
||||||
|
skip_this_block = 1;
|
||||||
|
continue;
|
||||||
} else if (errno == EACCES) {
|
} else if (errno == EACCES) {
|
||||||
fprintf(stderr, "No access at file '%s'.\n", handle[j].path);
|
fprintf(stderr, "No access at file '%s'.\n", handle[j].path);
|
||||||
fprintf(stderr, "WARNING! Please fix the access permission in the data disk.\n");
|
fprintf(stderr, "WARNING! Please fix the access permission in the data disk.\n");
|
||||||
|
|
@ -143,6 +153,7 @@ static int state_sync_process(struct snapraid_state* state, int parity_f, int qa
|
||||||
fprintf(stderr, "DANGER! Unexpected open error in a data disk, it isn't possible to sync.\n");
|
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");
|
printf("Stopping to allow recovery. Try with 'snapraid check'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
++unrecoverable_error;
|
++unrecoverable_error;
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
|
|
@ -159,9 +170,13 @@ static int state_sync_process(struct snapraid_state* state, int parity_f, int qa
|
||||||
else
|
else
|
||||||
fprintf(stderr, "Unexpected inode change from %"PRIu64" to %"PRIu64" at file '%s'.\n", block_file_get(block)->inode, handle[j].st.st_ino, handle[j].path);
|
fprintf(stderr, "Unexpected inode change from %"PRIu64" to %"PRIu64" at file '%s'.\n", block_file_get(block)->inode, 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. Rerun the sync command when finished.\n");
|
||||||
printf("Stopping at block %u\n", i);
|
|
||||||
++unrecoverable_error;
|
++unrecoverable_error;
|
||||||
goto bail;
|
|
||||||
|
/* if the file is charnged, 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;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
read_size = handle_read(&handle[j], block, buffer[j], state->block_size);
|
read_size = handle_read(&handle[j], block, buffer[j], state->block_size);
|
||||||
|
|
@ -193,39 +208,43 @@ static int state_sync_process(struct snapraid_state* state, int parity_f, int qa
|
||||||
countsize += read_size;
|
countsize += read_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* compute the parity */
|
/* if we have read all the data required, proceed with the parity */
|
||||||
raid_gen(state->level, buffer, diskmax, state->block_size);
|
if (!skip_this_block) {
|
||||||
|
|
||||||
/* write the parity */
|
/* compute the parity */
|
||||||
ret = parity_write(state->parity, parity_f, i, buffer[diskmax], state->block_size);
|
raid_gen(state->level, buffer, diskmax, state->block_size);
|
||||||
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;
|
|
||||||
goto bail;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* write the qarity */
|
/* write the parity */
|
||||||
if (state->level >= 2) {
|
ret = parity_write(state->parity, parity_f, i, buffer[diskmax], state->block_size);
|
||||||
ret = parity_write(state->qarity, qarity_f, i, buffer[diskmax+1], state->block_size);
|
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
fprintf(stderr, "DANGER! Write error in the Q-Parity disk, it isn't possible to sync.\n");
|
fprintf(stderr, "DANGER! Write error in the Parity disk, it isn't possible to sync.\n");
|
||||||
printf("Stopping at block %u\n", i);
|
printf("Stopping at block %u\n", i);
|
||||||
++unrecoverable_error;
|
++unrecoverable_error;
|
||||||
goto bail;
|
goto bail;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* for each disk, mark the blocks as processed */
|
/* write the qarity */
|
||||||
for(j=0;j<diskmax;++j) {
|
if (state->level >= 2) {
|
||||||
struct snapraid_block* block;
|
ret = parity_write(state->qarity, qarity_f, i, buffer[diskmax+1], state->block_size);
|
||||||
|
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;
|
||||||
|
goto bail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
block = disk_block_get(handle[j].disk, i);
|
/* for each disk, mark the blocks as processed */
|
||||||
if (!block)
|
for(j=0;j<diskmax;++j) {
|
||||||
continue;
|
struct snapraid_block* block;
|
||||||
|
|
||||||
/* now all the blocks have the hash and the parity computed */
|
block = disk_block_get(handle[j].disk, i);
|
||||||
block_flag_set(block, BLOCK_HAS_HASH | BLOCK_HAS_PARITY);
|
if (!block)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* now all the blocks have the hash and the parity computed */
|
||||||
|
block_flag_set(block, BLOCK_HAS_HASH | BLOCK_HAS_PARITY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mark the state as needing write */
|
/* mark the state as needing write */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue