Always recheck bad blocks in scrub.

This commit is contained in:
Andrea Mazzoleni 2013-08-18 19:35:25 +02:00
parent 746901d0be
commit 367d243f63

70
scrub.c
View file

@ -50,6 +50,7 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
data_off_t countsize; data_off_t countsize;
block_off_t countpos; block_off_t countpos;
block_off_t countmax; block_off_t countmax;
block_off_t recountmax;
block_off_t autosavedone; block_off_t autosavedone;
block_off_t autosavelimit; block_off_t autosavelimit;
block_off_t autosavemissing; block_off_t autosavemissing;
@ -88,26 +89,30 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
continue; continue;
} }
/* if it's too new */ /* blocks marked as bad are always checked */
blocktime = info_get_time(info); if (!info_get_bad(info)) {
if (blocktime > timelimit) {
/* skip it */
continue;
}
/* skip odd blocks, used only for testing */ /* if it's too new */
if (state->opt.force_scrub_even && (i % 2) != 0) { blocktime = info_get_time(info);
/* skip it */ if (blocktime > timelimit) {
continue; /* skip it */
continue;
}
/* skip odd blocks, used only for testing */
if (state->opt.force_scrub_even && (i % 2) != 0) {
/* skip it */
continue;
}
/* if we reached the count limit */
if (countmax >= countlimit) {
/* skip it */
continue;
}
} }
++countmax; ++countmax;
if (countmax >= countlimit) {
/* if we reached the count limit, recompute the stop address */
blockmax = i + 1;
break;
}
} }
/* compute the autosave size for all disk, even if not read */ /* compute the autosave size for all disk, even if not read */
@ -120,6 +125,7 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
countsize = 0; countsize = 0;
countpos = 0; countpos = 0;
state_progress_begin(state, blockstart, blockmax, countmax); state_progress_begin(state, blockstart, blockmax, countmax);
recountmax = 0;
for(i=blockstart;i<blockmax;++i) { for(i=blockstart;i<blockmax;++i) {
time_t blocktime; time_t blocktime;
snapraid_info info; snapraid_info info;
@ -136,18 +142,30 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
continue; continue;
} }
/* if it's too new */ /* blocks marked as bad are always checked */
blocktime = info_get_time(info); if (!info_get_bad(info)) {
if (blocktime > timelimit) {
/* skip it */ /* if it's too new */
continue; blocktime = info_get_time(info);
if (blocktime > timelimit) {
/* skip it */
continue;
}
/* skip odd blocks, used only for testing */
if (state->opt.force_scrub_even && (i % 2) != 0) {
/* skip it */
continue;
}
/* if we reached the count limit */
if (recountmax >= countlimit) {
/* skip it */
continue;
}
} }
/* skip odd blocks, used only for testing */ ++recountmax;
if (state->opt.force_scrub_even && (i % 2) != 0) {
/* skip it */
continue;
}
/* one more block processed for autosave */ /* one more block processed for autosave */
++autosavedone; ++autosavedone;