mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-30 20:06:56 -05: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
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue