Keeps the default value of -p and -o.

This commit is contained in:
Andrea Mazzoleni 2014-02-16 21:05:25 +01:00
parent 10d305285c
commit 5d8f17dcd1
6 changed files with 28 additions and 18 deletions

View file

@ -19,8 +19,10 @@ SnapRAID HISTORY
* In "fix", if a previous fixing attempt was made resulting in a
.unrecoverable file, uses this file as starting point for the
new attempt.
* In the log file name allow the use of the '>>', %D, %T modifiers
* In the log file name allows the use of the '>>', %D, %T modifiers
to select append mode, and to insert the date and time in the name.
* The options -p, --percentage and -o, --older-than now keep their
default value even if the other one is specified.
* New source code organization. The RAID engine is now
an external component usable also in other projects.

3
TODO
View file

@ -5,9 +5,6 @@ This is the list of TODO items for SnapRAID.
- Next
* Don't disable default 10d/12% if -p or -o is specified.
But check that -p0 still work.
* Checks if splitting hash/parity computation in 4K pages
can improve speed in sync. That should increase cache locality,
becase we read the data two times for hash and and parity,

30
scrub.c
View file

@ -459,6 +459,20 @@ bail:
return 0;
}
/**
* Returns a * b / c approximated to the upper value.
*/
static uint32_t md(uint32_t a, uint32_t b, uint32_t c)
{
uint64_t v = a;
v *= b;
v += c - 1;
v /= c;
return v;
}
int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
{
block_off_t blockmax;
@ -490,21 +504,21 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
/* scrub the specified amount of blocks */
countlimit = state->opt.force_scrub;
recentlimit = now;
} else if (percentage != -1 || olderthan != -1) {
} else {
/* by default scrub 1/12 of the array */
countlimit = md(blockmax, 1, 12);
/* by default use a 10 day time limit */
recentlimit = now - 10 * 24 * 3600;
if (percentage != -1)
countlimit = (blockmax * (uint64_t)percentage + 99) / 100;
countlimit = md(blockmax, percentage, 100);
else
countlimit = blockmax;
if (olderthan != -1)
recentlimit = now - olderthan * 24 * 3600;
else
recentlimit = now;
} else {
/* by default scrub 1/12 of the array */
countlimit = blockmax / 12;
/* by default use a 10 day time limit */
recentlimit = now - 10 * 24 * 3600;
}
/* identify the time limit */

View file

@ -557,8 +557,7 @@ at least one time every two months.
.PP
You can use the \-p, \-\-percentage option to specify a different amount,
and the \-o, \-\-older\-than option to specify a different age in days.
Note that if only one of \-p and \-o is specified the default value of
the other option is not used.
You can have a full scrub with \(a"\-p100 \-o0\(a".
.PP
Any silent error identified is recorded in the content file,
and it\(cqs listed in the \(a"status\(a" command until it\(cqs fixed calling

View file

@ -315,8 +315,7 @@ Commands
You can use the -p, --percentage option to specify a different amount,
and the -o, --older-than option to specify a different age in days.
Note that if only one of -p and -o is specified the default value of
the other option is not used.
You can have a full scrub with "-p100 -o0".
Any silent error identified is recorded in the content file,
and it's listed in the "status" command until it's fixed calling

View file

@ -343,8 +343,7 @@ at least one time every two months.
You can use the -p, --percentage option to specify a different amount,
and the -o, --older-than option to specify a different age in days.
Note that if only one of -p and -o is specified the default value of
the other option is not used.
You can have a full scrub with "-p100 -o0".
Any silent error identified is recorded in the content file,
and it's listed in the "status" command until it's fixed calling