Fixes the percentage computation in scrub.

This commit is contained in:
Andrea Mazzoleni 2013-09-26 21:14:47 +02:00
parent 210975556e
commit 0489c98bb0

29
scrub.c
View file

@ -100,10 +100,14 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
continue;
}
/* if we reached the count limit */
if (countmax >= countlimit) {
/* skip it */
continue;
/* if the time is less than the limit, always include */
/* otherwise, check if we reaced the count max */
if (blocktime == timelimit) {
/* if we reached the count limit */
if (countmax >= countlimit) {
/* skip it */
continue;
}
}
}
@ -153,10 +157,14 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
continue;
}
/* if we reached the count limit */
if (recountmax >= countlimit) {
/* skip it */
continue;
/* if the time is less than the limit, always include */
/* otherwise, check if we reaced the count max */
if (blocktime == timelimit) {
/* if we reached the count limit */
if (recountmax >= countlimit) {
/* skip it */
continue;
}
}
}
@ -463,7 +471,7 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
recentlimit = now;
} else if (percentage != -1 || olderthan != -1) {
if (percentage != -1)
countlimit = blockmax * percentage / 100;
countlimit = (blockmax * percentage + 99) / 100;
else
countlimit = blockmax;
if (olderthan != -1)
@ -512,8 +520,9 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
timelimit = info_get_time(infomap[countlimit - 1]);
/* don't scrub too recent blocks */
if (timelimit > recentlimit)
if (timelimit > recentlimit) {
timelimit = recentlimit;
}
} else {
/* we don't have a time limit based on quota */
timelimit = recentlimit;