diff options
author | Markus Stockhausen <stockhausen@collogia.de> | 2014-12-14 20:57:04 -0500 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2015-04-21 18:00:42 -0400 |
commit | 7e92e1d7629b00578cef22b1f4c6ada726663701 (patch) | |
tree | 4aeceed85c09478c06fc3e0ff9d1bb2cfa67071a /lib/raid6/test/test.c | |
parent | fe5cbc6e06c7d8b3a86f6f5491d74766bb5c2827 (diff) |
md/raid6 algorithms: improve test program
It is always helpful to have a test tool in place if we implement
new data critical algorithms. So add some test routines to the raid6
checker that can prove if the new xor_syndrome() works as expected.
Run through all permutations of start/stop pages per algorithm and
simulate a xor_syndrome() assisted rmw run. After each rmw check if
the recovery algorithm still confirms that the stripe is fine.
Signed-off-by: Markus Stockhausen <stockhausen@collogia.de>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'lib/raid6/test/test.c')
-rw-r--r-- | lib/raid6/test/test.c | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/lib/raid6/test/test.c b/lib/raid6/test/test.c index 5a485b7a7d3c..3bebbabdb510 100644 --- a/lib/raid6/test/test.c +++ b/lib/raid6/test/test.c | |||
@@ -28,11 +28,11 @@ char *dataptrs[NDISKS]; | |||
28 | char data[NDISKS][PAGE_SIZE]; | 28 | char data[NDISKS][PAGE_SIZE]; |
29 | char recovi[PAGE_SIZE], recovj[PAGE_SIZE]; | 29 | char recovi[PAGE_SIZE], recovj[PAGE_SIZE]; |
30 | 30 | ||
31 | static void makedata(void) | 31 | static void makedata(int start, int stop) |
32 | { | 32 | { |
33 | int i, j; | 33 | int i, j; |
34 | 34 | ||
35 | for (i = 0; i < NDISKS; i++) { | 35 | for (i = start; i <= stop; i++) { |
36 | for (j = 0; j < PAGE_SIZE; j++) | 36 | for (j = 0; j < PAGE_SIZE; j++) |
37 | data[i][j] = rand(); | 37 | data[i][j] = rand(); |
38 | 38 | ||
@@ -91,34 +91,55 @@ int main(int argc, char *argv[]) | |||
91 | { | 91 | { |
92 | const struct raid6_calls *const *algo; | 92 | const struct raid6_calls *const *algo; |
93 | const struct raid6_recov_calls *const *ra; | 93 | const struct raid6_recov_calls *const *ra; |
94 | int i, j; | 94 | int i, j, p1, p2; |
95 | int err = 0; | 95 | int err = 0; |
96 | 96 | ||
97 | makedata(); | 97 | makedata(0, NDISKS-1); |
98 | 98 | ||
99 | for (ra = raid6_recov_algos; *ra; ra++) { | 99 | for (ra = raid6_recov_algos; *ra; ra++) { |
100 | if ((*ra)->valid && !(*ra)->valid()) | 100 | if ((*ra)->valid && !(*ra)->valid()) |
101 | continue; | 101 | continue; |
102 | |||
102 | raid6_2data_recov = (*ra)->data2; | 103 | raid6_2data_recov = (*ra)->data2; |
103 | raid6_datap_recov = (*ra)->datap; | 104 | raid6_datap_recov = (*ra)->datap; |
104 | 105 | ||
105 | printf("using recovery %s\n", (*ra)->name); | 106 | printf("using recovery %s\n", (*ra)->name); |
106 | 107 | ||
107 | for (algo = raid6_algos; *algo; algo++) { | 108 | for (algo = raid6_algos; *algo; algo++) { |
108 | if (!(*algo)->valid || (*algo)->valid()) { | 109 | if ((*algo)->valid && !(*algo)->valid()) |
109 | raid6_call = **algo; | 110 | continue; |
111 | |||
112 | raid6_call = **algo; | ||
113 | |||
114 | /* Nuke syndromes */ | ||
115 | memset(data[NDISKS-2], 0xee, 2*PAGE_SIZE); | ||
116 | |||
117 | /* Generate assumed good syndrome */ | ||
118 | raid6_call.gen_syndrome(NDISKS, PAGE_SIZE, | ||
119 | (void **)&dataptrs); | ||
120 | |||
121 | for (i = 0; i < NDISKS-1; i++) | ||
122 | for (j = i+1; j < NDISKS; j++) | ||
123 | err += test_disks(i, j); | ||
124 | |||
125 | if (!raid6_call.xor_syndrome) | ||
126 | continue; | ||
127 | |||
128 | for (p1 = 0; p1 < NDISKS-2; p1++) | ||
129 | for (p2 = p1; p2 < NDISKS-2; p2++) { | ||
110 | 130 | ||
111 | /* Nuke syndromes */ | 131 | /* Simulate rmw run */ |
112 | memset(data[NDISKS-2], 0xee, 2*PAGE_SIZE); | 132 | raid6_call.xor_syndrome(NDISKS, p1, p2, PAGE_SIZE, |
133 | (void **)&dataptrs); | ||
134 | makedata(p1, p2); | ||
135 | raid6_call.xor_syndrome(NDISKS, p1, p2, PAGE_SIZE, | ||
136 | (void **)&dataptrs); | ||
113 | 137 | ||
114 | /* Generate assumed good syndrome */ | 138 | for (i = 0; i < NDISKS-1; i++) |
115 | raid6_call.gen_syndrome(NDISKS, PAGE_SIZE, | 139 | for (j = i+1; j < NDISKS; j++) |
116 | (void **)&dataptrs); | 140 | err += test_disks(i, j); |
141 | } | ||
117 | 142 | ||
118 | for (i = 0; i < NDISKS-1; i++) | ||
119 | for (j = i+1; j < NDISKS; j++) | ||
120 | err += test_disks(i, j); | ||
121 | } | ||
122 | } | 143 | } |
123 | printf("\n"); | 144 | printf("\n"); |
124 | } | 145 | } |