mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Avoid autosave if near at the end.
This commit is contained in:
parent
462cdf95a4
commit
179195435b
3 changed files with 20 additions and 11 deletions
1
HISTORY
1
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
|
||||
===========
|
||||
|
|
|
|||
2
TODO
2
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
|
||||
|
|
|
|||
28
sync.c
28
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;i<blockmax;++i) {
|
||||
|
|
@ -127,14 +135,13 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
continue;
|
||||
}
|
||||
|
||||
/* one more block processed for autosave */
|
||||
++autosavedone;
|
||||
--autosavemissing;
|
||||
|
||||
/* by default process the block, and skip it if something go wrong */
|
||||
skip_this_block = 0;
|
||||
|
||||
/* 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 */
|
||||
autosavesize += diskmax * state->block_size;
|
||||
|
||||
/* for each disk, process the block */
|
||||
for(j=0;j<diskmax;++j) {
|
||||
int read_size;
|
||||
|
|
@ -306,8 +313,11 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
}
|
||||
|
||||
/* autosave */
|
||||
if (state->autosave != 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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue