mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Adds test for scrub.
This commit is contained in:
parent
d93f2f0595
commit
33cf866699
3 changed files with 24 additions and 4 deletions
|
|
@ -158,6 +158,13 @@ endif
|
|||
echo --- Dry
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -c $(srcdir)/test-raid5.conf dry
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -c $(srcdir)/test-raid6.conf dry
|
||||
echo --- Scrub some times
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -v -c $(srcdir)/test-raid6.conf --test-force-scrub 100 scrub
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -v -c $(srcdir)/test-raid6.conf status
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -v -c $(srcdir)/test-raid6.conf --test-force-scrub 1000 scrub
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -v -c $(srcdir)/test-raid6.conf status
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -v -c $(srcdir)/test-raid6.conf --test-force-scrub 10000 scrub
|
||||
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -v -c $(srcdir)/test-raid6.conf status
|
||||
echo --- Make a hole in the disk array
|
||||
mv test/disk2 test/disk2.old
|
||||
mkdir test/disk2
|
||||
|
|
|
|||
14
scrub.c
14
scrub.c
|
|
@ -331,11 +331,17 @@ int state_scrub(struct snapraid_state* state)
|
|||
|
||||
blockmax = parity_size(state);
|
||||
|
||||
/* by default scrub 1/12 of the array */
|
||||
countlimit = blockmax / 12;
|
||||
if (state->opt.force_scrub) {
|
||||
/* scrub the specified amount of blocks */
|
||||
countlimit = state->opt.force_scrub;
|
||||
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;
|
||||
/* by default use a 10 day time limit */
|
||||
recentlimit = now - 10 * 24 * 3600;
|
||||
}
|
||||
|
||||
/* identify the time limit */
|
||||
/* we sort all the block times, and we identify the time limit for which we reach the quota */
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@ void usage(void)
|
|||
#define OPT_TEST_FORCE_ORDER_INODE 268
|
||||
#define OPT_TEST_FORCE_ORDER_ALPHA 269
|
||||
#define OPT_TEST_FORCE_ORDER_DIR 270
|
||||
#define OPT_TEST_FORCE_SCRUB 271
|
||||
|
||||
#if HAVE_GETOPT_LONG
|
||||
struct option long_options[] = {
|
||||
|
|
@ -154,6 +155,9 @@ struct option long_options[] = {
|
|||
{ "test-force-order-alpha", 0, 0, OPT_TEST_FORCE_ORDER_ALPHA },
|
||||
{ "test-force-order-dir", 0, 0, OPT_TEST_FORCE_ORDER_DIR },
|
||||
|
||||
/* Force scrub of the specified number of blocks */
|
||||
{ "test-force-scrub", 1, 0, OPT_TEST_FORCE_SCRUB },
|
||||
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
#endif
|
||||
|
|
@ -351,6 +355,9 @@ int main(int argc, char* argv[])
|
|||
case OPT_TEST_FORCE_ORDER_DIR :
|
||||
opt.force_order = SORT_DIR;
|
||||
break;
|
||||
case OPT_TEST_FORCE_SCRUB :
|
||||
opt.force_scrub = atoi(optarg);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown option '%c'\n", (char)c);
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue