mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-29 11:26:48 -05: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
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