diff --git a/HISTORY b/HISTORY index fc330fbb..d1f6ef8d 100644 --- a/HISTORY +++ b/HISTORY @@ -9,6 +9,7 @@ SnapRAID HISTORY * Before starting a sync, we wait for two seconds, to workaround the FAT limitation of having two seconds modification time precision. This a safe measure to be 100% sure to always detect file changes. + * Autosave isn't triggered if we are near the end of the process. 1.11 2012/7 =========== diff --git a/TODO b/TODO index a2c27426..5010c90e 100644 --- a/TODO +++ b/TODO @@ -19,8 +19,6 @@ See: http://www.codeproject.com/Articles/21202/Reparse-Points-in-Vista * In Windows to use FILE_FLAG_BACKUP_SEMANTICS we should also get privileges. See http://www.codeproject.com/Articles/21202/Reparse-Points-in-Vista. -* In Autosave, do not save if we are near the termination. - * Allow to filter the files to check/fix based on the drive where they reside. * When checking, allow to disable the parity check, thus allowing to read only diff --git a/sync.c b/sync.c index cb62fd08..9dce8791 100644 --- a/sync.c +++ b/sync.c @@ -40,7 +40,9 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari data_off_t countsize; block_off_t countpos; block_off_t countmax; - uint64_t autosavesize; + block_off_t autosavedone; + block_off_t autosavelimit; + block_off_t autosavemissing; int ret; unsigned unrecoverable_error; @@ -84,8 +86,14 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari ++countmax; } + /* compute the autosave size for all disk, even if not read */ + /* this makes sense because the speed should be almost the same */ + /* if the disks are read in parallel */ + autosavelimit = state->autosave / (diskmax * state->block_size); + autosavemissing = countmax; /* blocks to do */ + autosavedone = 0; /* blocks done */ + countsize = 0; - autosavesize = 0; countpos = 0; state_progress_begin(state, blockstart, blockmax, countmax); for(i=blockstart;iblock_size; - /* for each disk, process the block */ for(j=0;jautosave != 0 && autosavesize >= state->autosave) { - autosavesize = 0; + if (state->autosave != 0 + && autosavedone >= autosavelimit /* if we have reached the limit */ + && autosavemissing >= autosavelimit /* if we have at least a full step to do */ + ) { + autosavedone = 0; /* restart the counter */ state_progress_stop(state);