From faa9559fe57e2f5bbda154766d9fc030147d9256 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Wed, 14 Sep 2011 22:52:55 +0200 Subject: [PATCH] If a file is modified during a sync, the sync will continue. --- HISTORY | 6 +++++ sync.c | 71 ++++++++++++++++++++++++++++++++++++--------------------- 2 files changed, 51 insertions(+), 26 deletions(-) diff --git a/HISTORY b/HISTORY index d4834ad6..d1afaaa5 100644 --- a/HISTORY +++ b/HISTORY @@ -1,6 +1,12 @@ 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! =============================================== * The content file is now saved also at the start of the "sync" command. diff --git a/sync.c b/sync.c index 50f96694..b5861cdf 100644 --- a/sync.c +++ b/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); for(i=blockstart;iinode, 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"); - printf("Stopping at block %u\n", i); + ++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); @@ -193,39 +208,43 @@ static int state_sync_process(struct snapraid_state* state, int parity_f, int qa countsize += read_size; } - /* compute the parity */ - raid_gen(state->level, buffer, diskmax, state->block_size); + /* if we have read all the data required, proceed with the parity */ + if (!skip_this_block) { - /* write the parity */ - ret = parity_write(state->parity, parity_f, i, 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; - } + /* compute the parity */ + raid_gen(state->level, buffer, diskmax, state->block_size); - /* write the qarity */ - if (state->level >= 2) { - ret = parity_write(state->qarity, qarity_f, i, buffer[diskmax+1], state->block_size); + /* write the parity */ + ret = parity_write(state->parity, parity_f, i, buffer[diskmax], state->block_size); 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); ++unrecoverable_error; goto bail; } - } - /* for each disk, mark the blocks as processed */ - for(j=0;jlevel >= 2) { + 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); - if (!block) - continue; + /* for each disk, mark the blocks as processed */ + for(j=0;j