mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-25 18:40:19 -04:00
Rename the --percentage option to --plan
The old --percentage is still supported, but not documented anymore.
This commit is contained in:
parent
1917814d2d
commit
40265401d3
8 changed files with 56 additions and 55 deletions
8
HISTORY
8
HISTORY
|
|
@ -12,12 +12,12 @@ SnapRAID HISTORY
|
|||
uses 17 bytes of memory, instead of the previous 28 bytes
|
||||
(for 32 bit) or 36 bytes (for 64 bit).
|
||||
This could result is a memory saving of up the 50%.
|
||||
* The -p, --percentage option can be used to define a scrub plan:
|
||||
"new", "bad" and "full".
|
||||
* The -p, --plan option (old --percentage) can be used to
|
||||
define a scrub plan: "new", "bad" and "full".
|
||||
The "new" plan scrubs all the new synced blocks not yet scrubbed.
|
||||
This allows to verify as early as possible that the written
|
||||
parity during sync is really correct. You can use the "status" command
|
||||
to show the amount blocks not yet scrubbed.
|
||||
parity during sync is really correct. You can use the "status"
|
||||
command to show the amount blocks not yet scrubbed.
|
||||
The "bad" scrubs only bad blocks.
|
||||
The "full" scrubs all blocks.
|
||||
* Content files are now written asyncronously from different
|
||||
|
|
|
|||
|
|
@ -446,8 +446,8 @@ endif
|
|||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) --test-expect-recoverable --test-force-scrub-at 100000 scrub
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) status
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) fix -e
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) -p bad scrub
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) -p 1 scrub
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) --percentage bad scrub
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) --plan 1 scrub
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) -o 0 scrub
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) -p full scrub
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
|
||||
|
|
|
|||
|
|
@ -570,7 +570,7 @@ static uint32_t md(uint32_t a, uint32_t b, uint32_t c)
|
|||
return v;
|
||||
}
|
||||
|
||||
int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
|
||||
int state_scrub(struct snapraid_state* state, int plan, int olderthan)
|
||||
{
|
||||
block_off_t blockmax;
|
||||
block_off_t countlimit;
|
||||
|
|
@ -580,7 +580,7 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
|
|||
int ret;
|
||||
struct snapraid_parity_handle parity[LEV_MAX];
|
||||
struct snapraid_parity_handle* parity_ptr[LEV_MAX];
|
||||
struct snapraid_plan plan;
|
||||
struct snapraid_plan ps;
|
||||
time_t* timemap;
|
||||
unsigned error;
|
||||
time_t now;
|
||||
|
|
@ -591,10 +591,10 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
|
|||
|
||||
msg_progress("Initializing...\n");
|
||||
|
||||
if ((percentage == SCRUB_BAD || percentage == SCRUB_NEW || percentage == SCRUB_FULL)
|
||||
if ((plan == SCRUB_BAD || plan == SCRUB_NEW || plan == SCRUB_FULL)
|
||||
&& olderthan >= 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("You cannot specify -o, --older-than only with a numeric percentage.\n");
|
||||
log_fatal("You can specify -o, --older-than only with a numeric percentage.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -606,22 +606,22 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
|
|||
recentlimit = 0;
|
||||
|
||||
if (state->opt.force_scrub_even) {
|
||||
plan.plan = SCRUB_EVEN;
|
||||
} else if (percentage == SCRUB_FULL) {
|
||||
plan.plan = SCRUB_FULL;
|
||||
} else if (percentage == SCRUB_NEW) {
|
||||
plan.plan = SCRUB_NEW;
|
||||
} else if (percentage == SCRUB_BAD) {
|
||||
plan.plan = SCRUB_BAD;
|
||||
ps.plan = SCRUB_EVEN;
|
||||
} else if (plan == SCRUB_FULL) {
|
||||
ps.plan = SCRUB_FULL;
|
||||
} else if (plan == SCRUB_NEW) {
|
||||
ps.plan = SCRUB_NEW;
|
||||
} else if (plan == SCRUB_BAD) {
|
||||
ps.plan = SCRUB_BAD;
|
||||
} else if (state->opt.force_scrub_at) {
|
||||
/* scrub the specified amount of blocks */
|
||||
plan.plan = SCRUB_AUTO;
|
||||
ps.plan = SCRUB_AUTO;
|
||||
countlimit = state->opt.force_scrub_at;
|
||||
recentlimit = now;
|
||||
} else {
|
||||
plan.plan = SCRUB_AUTO;
|
||||
if (percentage >= 0) {
|
||||
countlimit = md(blockmax, percentage, 100);
|
||||
ps.plan = SCRUB_AUTO;
|
||||
if (plan >= 0) {
|
||||
countlimit = md(blockmax, plan, 100);
|
||||
} else {
|
||||
/* by default scrub 12.5% of the array (100/8=12.5) */
|
||||
countlimit = md(blockmax, 1, 8);
|
||||
|
|
@ -675,7 +675,7 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
|
|||
}
|
||||
|
||||
/* compute the limits from count/recentlimit */
|
||||
if (plan.plan == SCRUB_AUTO) {
|
||||
if (ps.plan == SCRUB_AUTO) {
|
||||
/* no more than the full count */
|
||||
if (countlimit > count)
|
||||
countlimit = count;
|
||||
|
|
@ -687,24 +687,24 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
|
|||
/* if there is something to scrub */
|
||||
if (countlimit > 0) {
|
||||
/* get the most recent time we want to scrub */
|
||||
plan.timelimit = timemap[countlimit - 1];
|
||||
ps.timelimit = timemap[countlimit - 1];
|
||||
|
||||
/* count how many entries for this exact time we have to scrub */
|
||||
/* if the blocks have all the same time, we end with countlimit == lastlimit */
|
||||
plan.lastlimit = 1;
|
||||
while (countlimit > plan.lastlimit && timemap[countlimit - plan.lastlimit - 1] == plan.timelimit)
|
||||
++plan.lastlimit;
|
||||
ps.lastlimit = 1;
|
||||
while (countlimit > ps.lastlimit && timemap[countlimit - ps.lastlimit - 1] == ps.timelimit)
|
||||
++ps.lastlimit;
|
||||
} else {
|
||||
/* if nothing to scrub, disable also other limits */
|
||||
plan.timelimit = 0;
|
||||
plan.lastlimit = 0;
|
||||
ps.timelimit = 0;
|
||||
ps.lastlimit = 0;
|
||||
}
|
||||
|
||||
log_tag("count_limit:%u\n", countlimit);
|
||||
}
|
||||
|
||||
log_tag("time_limit:%" PRIu64 "\n", (uint64_t)plan.timelimit);
|
||||
log_tag("last_limit:%u\n", plan.lastlimit);
|
||||
log_tag("time_limit:%" PRIu64 "\n", (uint64_t)ps.timelimit);
|
||||
log_tag("last_limit:%u\n", ps.lastlimit);
|
||||
|
||||
/* free the temp vector */
|
||||
free(timemap);
|
||||
|
|
@ -725,7 +725,7 @@ int state_scrub(struct snapraid_state* state, int percentage, int olderthan)
|
|||
|
||||
error = 0;
|
||||
|
||||
ret = state_scrub_process(state, parity_ptr, 0, blockmax, &plan, now);
|
||||
ret = state_scrub_process(state, parity_ptr, 0, blockmax, &ps, now);
|
||||
if (ret == -1) {
|
||||
++error;
|
||||
/* continue, as we are already exiting */
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ void usage(void)
|
|||
printf(" " SWITCH_GETOPT_LONG("-d, --filter-disk NAME", "-f") " Process only files in the specified disk\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-m, --filter-missing ", "-m") " Process only missing/deleted files\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-e, --filter-error ", "-e") " Process only files with errors\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-p, --percentage PERC ", "-p") " Process only a part of the array\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-p, --plan PLAN ", "-p") " Define a scrub plan or percentage\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-o, --older-than DAYS ", "-o") " Process only the older part of the array\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-i, --import DIR ", "-i") " Import deleted files\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-l, --log FILE ", "-l") " Log file. Default none\n");
|
||||
|
|
@ -253,7 +253,8 @@ struct option long_options[] = {
|
|||
{ "filter-disk", 1, 0, 'd' },
|
||||
{ "filter-missing", 0, 0, 'm' },
|
||||
{ "filter-error", 0, 0, 'e' },
|
||||
{ "percentage", 1, 0, 'p' },
|
||||
{ "percentage", 1, 0, 'p' }, /* legacy name for --plan */
|
||||
{ "plan", 1, 0, 'p' },
|
||||
{ "older-than", 1, 0, 'o' },
|
||||
{ "start", 1, 0, 'S' },
|
||||
{ "count", 1, 0, 'B' },
|
||||
|
|
@ -430,7 +431,7 @@ int main(int argc, char* argv[])
|
|||
tommy_list filterlist_disk;
|
||||
int filter_missing;
|
||||
int filter_error;
|
||||
int percentage;
|
||||
int plan;
|
||||
int olderthan;
|
||||
char* e;
|
||||
const char* command;
|
||||
|
|
@ -457,7 +458,7 @@ int main(int argc, char* argv[])
|
|||
period = 1000;
|
||||
filter_missing = 0;
|
||||
filter_error = 0;
|
||||
percentage = SCRUB_AUTO;
|
||||
plan = SCRUB_AUTO;
|
||||
olderthan = SCRUB_AUTO;
|
||||
import_timestamp = 0;
|
||||
import_content = 0;
|
||||
|
|
@ -513,16 +514,16 @@ int main(int argc, char* argv[])
|
|||
break;
|
||||
case 'p' :
|
||||
if (strcmp(optarg, "bad") == 0) {
|
||||
percentage = SCRUB_BAD;
|
||||
plan = SCRUB_BAD;
|
||||
} else if (strcmp(optarg, "new") == 0) {
|
||||
percentage = SCRUB_NEW;
|
||||
plan = SCRUB_NEW;
|
||||
} else if (strcmp(optarg, "full") == 0) {
|
||||
percentage = SCRUB_FULL;
|
||||
plan = SCRUB_FULL;
|
||||
} else {
|
||||
percentage = strtoul(optarg, &e, 10);
|
||||
if (!e || *e || percentage > 100) {
|
||||
plan = strtoul(optarg, &e, 10);
|
||||
if (!e || *e || plan > 100) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Invalid percentage '%s'\n", optarg);
|
||||
log_fatal("Invalid plan/percentage '%s'\n", optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1166,7 +1167,7 @@ int main(int argc, char* argv[])
|
|||
/* intercept signals while operating */
|
||||
signal_init();
|
||||
|
||||
ret = state_scrub(&state, percentage, olderthan);
|
||||
ret = state_scrub(&state, plan, olderthan);
|
||||
|
||||
/* save the new state if required */
|
||||
if (state.need_write || state.opt.force_content_write)
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ void state_rehash(struct snapraid_state* state);
|
|||
/**
|
||||
* Scrub the files.
|
||||
*/
|
||||
int state_scrub(struct snapraid_state* state, int percentage, int olderthan);
|
||||
int state_scrub(struct snapraid_state* state, int plan, int olderthan);
|
||||
|
||||
/**
|
||||
* Print the status.
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ snapraid [\-c, \-\-conf CONFIG]
|
|||
.PD 0
|
||||
.PP
|
||||
.PD
|
||||
[\-p, \-\-percentage PERC|bad|new|full]
|
||||
[\-p, \-\-plan PERC|bad|new|full]
|
||||
.PD 0
|
||||
.PP
|
||||
.PD
|
||||
|
|
@ -309,7 +309,7 @@ the hash computed in the \[dq]sync\[dq] command.
|
|||
.PP
|
||||
Every run of the command checks the 12.5% of the array, but not data
|
||||
already scrubbed in the previous 10 days.
|
||||
You can use the \-p, \-\-percentage option to specify a different amount,
|
||||
You can use the \-p, \-\-plan option to specify a different amount,
|
||||
and the \-o, \-\-older\-than option to specify a different age in days.
|
||||
For example, to check 5% of the array older than 20 days use:
|
||||
.PP
|
||||
|
|
@ -779,7 +779,7 @@ nothing that was already scrubbed in the last 10 days.
|
|||
This means that scrubbing once a week, every bit of data is checked
|
||||
at least one time every two months.
|
||||
.PP
|
||||
You can define a different scrub plan or amount using the \-p, \-\-percentage
|
||||
You can define a different scrub plan or amount using the \-p, \-\-plan
|
||||
option that takes as argument:
|
||||
bad \- Scrub blocks marked bad.
|
||||
new \- Scrub just synced blocks not yet scrubbed.
|
||||
|
|
@ -978,7 +978,7 @@ It processes only the blocks marked with silent or input/output
|
|||
errors during \[dq]sync\[dq] and \[dq]scrub\[dq], and listed in \[dq]status\[dq].
|
||||
This option can be used only with \[dq]check\[dq] and \[dq]fix\[dq].
|
||||
.TP
|
||||
.B \-p, \-\-percentage PERC|bad|new|full
|
||||
.B \-p, \-\-plan PERC|bad|new|full
|
||||
Selects the scrub plan. If PERC is a numeric value from 0 to 100,
|
||||
it\'s interpreted as the percentage of blocks to scrub.
|
||||
Instead of a percentage, you can also specify a plan:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ Synopsis
|
|||
: [-f, --filter PATTERN] [-d, --filter-disk NAME]
|
||||
: [-m, --filter-missing] [-e, --filter-error]
|
||||
: [-a, --audit-only] [-h, --pre-hash] [-i, --import DIR]
|
||||
: [-p, --percentage PERC|bad|new|full]
|
||||
: [-p, --plan PERC|bad|new|full]
|
||||
: [-o, --older-than DAYS] [-l, --log FILE]
|
||||
: [-Z, --force-zero] [-E, --force-empty]
|
||||
: [-U, --force-uuid] [-D, --force-device]
|
||||
|
|
@ -173,7 +173,7 @@ Getting Started
|
|||
|
||||
Every run of the command checks the 12.5% of the array, but not data
|
||||
already scrubbed in the previous 10 days.
|
||||
You can use the -p, --percentage option to specify a different amount,
|
||||
You can use the -p, --plan option to specify a different amount,
|
||||
and the -o, --older-than option to specify a different age in days.
|
||||
For example, to check 5% of the array older than 20 days use:
|
||||
|
||||
|
|
@ -487,7 +487,7 @@ Commands
|
|||
This means that scrubbing once a week, every bit of data is checked
|
||||
at least one time every two months.
|
||||
|
||||
You can define a different scrub plan or amount using the -p, --percentage
|
||||
You can define a different scrub plan or amount using the -p, --plan
|
||||
option that takes as argument:
|
||||
bad - Scrub blocks marked bad.
|
||||
new - Scrub just synced blocks not yet scrubbed.
|
||||
|
|
@ -696,7 +696,7 @@ Options
|
|||
errors during "sync" and "scrub", and listed in "status".
|
||||
This option can be used only with "check" and "fix".
|
||||
|
||||
-p, --percentage PERC|bad|new|full
|
||||
-p, --plan PERC|bad|new|full
|
||||
Selects the scrub plan. If PERC is a numeric value from 0 to 100,
|
||||
it's interpreted as the percentage of blocks to scrub.
|
||||
Instead of a percentage, you can also specify a plan:
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ snapraid [-c, --conf CONFIG]
|
|||
[-f, --filter PATTERN] [-d, --filter-disk NAME]
|
||||
[-m, --filter-missing] [-e, --filter-error]
|
||||
[-a, --audit-only] [-h, --pre-hash] [-i, --import DIR]
|
||||
[-p, --percentage PERC|bad|new|full]
|
||||
[-p, --plan PERC|bad|new|full]
|
||||
[-o, --older-than DAYS] [-l, --log FILE]
|
||||
[-Z, --force-zero] [-E, --force-empty]
|
||||
[-U, --force-uuid] [-D, --force-device]
|
||||
|
|
@ -188,7 +188,7 @@ the hash computed in the "sync" command.
|
|||
|
||||
Every run of the command checks the 12.5% of the array, but not data
|
||||
already scrubbed in the previous 10 days.
|
||||
You can use the -p, --percentage option to specify a different amount,
|
||||
You can use the -p, --plan option to specify a different amount,
|
||||
and the -o, --older-than option to specify a different age in days.
|
||||
For example, to check 5% of the array older than 20 days use:
|
||||
|
||||
|
|
@ -525,7 +525,7 @@ nothing that was already scrubbed in the last 10 days.
|
|||
This means that scrubbing once a week, every bit of data is checked
|
||||
at least one time every two months.
|
||||
|
||||
You can define a different scrub plan or amount using the -p, --percentage
|
||||
You can define a different scrub plan or amount using the -p, --plan
|
||||
option that takes as argument:
|
||||
bad - Scrub blocks marked bad.
|
||||
new - Scrub just synced blocks not yet scrubbed.
|
||||
|
|
@ -755,7 +755,7 @@ SnapRAID provides the following options:
|
|||
errors during "sync" and "scrub", and listed in "status".
|
||||
This option can be used only with "check" and "fix".
|
||||
|
||||
-p, --percentage PERC|bad|new|full
|
||||
-p, --plan PERC|bad|new|full
|
||||
Selects the scrub plan. If PERC is a numeric value from 0 to 100,
|
||||
it's interpreted as the percentage of blocks to scrub.
|
||||
Instead of a percentage, you can also specify a plan:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue