From d371fec14fef7ba422fa094026ec6e41730e0776 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Fri, 25 Oct 2013 18:04:42 +0200 Subject: [PATCH] Adds new files for Cauchy RAID. --- combos.h | 111 ++++++++++++++++++++++++++++++++++++++++++ mkcombos.c | 98 +++++++++++++++++++++++++++++++++++++ test-raidHP-hole.conf | 22 +++++++++ test-raidHP.conf | 22 +++++++++ test-raidPP.conf | 20 ++++++++ 5 files changed, 273 insertions(+) create mode 100644 combos.h create mode 100644 mkcombos.c create mode 100644 test-raidHP-hole.conf create mode 100644 test-raidHP.conf create mode 100644 test-raidPP.conf diff --git a/combos.h b/combos.h new file mode 100644 index 00000000..88853915 --- /dev/null +++ b/combos.h @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2013 Andrea Mazzoleni + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * Combinations of 6 elements. + * Ends is marked with first element as -1. + */ +static int combo[][32][8] = { + /* combinations of 1 of 6 elements */ + { + { 0 }, + { 1 }, + { 2 }, + { 3 }, + { 4 }, + { 5 }, + { -1 } + }, + /* combinations of 2 of 6 elements */ + { + { 0, 1 }, + { 0, 2 }, + { 0, 3 }, + { 0, 4 }, + { 0, 5 }, + { 1, 2 }, + { 1, 3 }, + { 1, 4 }, + { 1, 5 }, + { 2, 3 }, + { 2, 4 }, + { 2, 5 }, + { 3, 4 }, + { 3, 5 }, + { 4, 5 }, + { -1 } + }, + /* combinations of 3 of 6 elements */ + { + { 0, 1, 2 }, + { 0, 1, 3 }, + { 0, 1, 4 }, + { 0, 1, 5 }, + { 0, 2, 3 }, + { 0, 2, 4 }, + { 0, 2, 5 }, + { 0, 3, 4 }, + { 0, 3, 5 }, + { 0, 4, 5 }, + { 1, 2, 3 }, + { 1, 2, 4 }, + { 1, 2, 5 }, + { 1, 3, 4 }, + { 1, 3, 5 }, + { 1, 4, 5 }, + { 2, 3, 4 }, + { 2, 3, 5 }, + { 2, 4, 5 }, + { 3, 4, 5 }, + { -1 } + }, + /* combinations of 4 of 6 elements */ + { + { 0, 1, 2, 3 }, + { 0, 1, 2, 4 }, + { 0, 1, 2, 5 }, + { 0, 1, 3, 4 }, + { 0, 1, 3, 5 }, + { 0, 1, 4, 5 }, + { 0, 2, 3, 4 }, + { 0, 2, 3, 5 }, + { 0, 2, 4, 5 }, + { 0, 3, 4, 5 }, + { 1, 2, 3, 4 }, + { 1, 2, 3, 5 }, + { 1, 2, 4, 5 }, + { 1, 3, 4, 5 }, + { 2, 3, 4, 5 }, + { -1 } + }, + /* combinations of 5 of 6 elements */ + { + { 0, 1, 2, 3, 4 }, + { 0, 1, 2, 3, 5 }, + { 0, 1, 2, 4, 5 }, + { 0, 1, 3, 4, 5 }, + { 0, 2, 3, 4, 5 }, + { 1, 2, 3, 4, 5 }, + { -1 } + }, + /* combinations of 6 of 6 elements */ + { + { 0, 1, 2, 3, 4, 5 }, + { -1 } + }, +}; + diff --git a/mkcombos.c b/mkcombos.c new file mode 100644 index 00000000..d1d2239f --- /dev/null +++ b/mkcombos.c @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2013 Andrea Mazzoleni + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +unsigned combo(unsigned mask, unsigned pick, unsigned from, unsigned to, unsigned* map) +{ + unsigned i; + unsigned count; + + if (pick == 0) { + map[0] = mask; + return 1; + } + + count = 0; + for(i=from;i<=to;++i) + count += combo(mask | (1 << i), pick - 1, i + 1, to, map + count); + + return count; +} + +void print_combo(unsigned n) +{ + unsigned map[10000]; + unsigned count; + unsigned i, j, k; + + printf("/**\n"); + printf(" * Combinations of %u elements.\n", n); + printf(" * Ends is marked with first element as -1.\n"); + printf(" */\n"); + printf("static int combo[][32][8] = {\n"); /* fixed value 32/8, change them if changing maximum n */ + + for(i=1;i<=n;++i) { + count = combo(0, i, 0, n - 1, map); + + printf("\t/* combinations of %u of %u elements */\n", i, n); + printf("\t{\n"); + for(j=0;j>= 1; + if (mask) + printf(", "); + } else { + mask >>= 1; + } + } + printf(" },\n"); + } + printf("\t\t{ -1 }\n"); + printf("\t},\n"); + } + printf("};\n\n"); +} + +int main(void) +{ + printf("/*\n"); + printf(" * Copyright (C) 2013 Andrea Mazzoleni\n"); + printf(" *\n"); + printf(" * This program is free software: you can redistribute it and/or modify\n"); + printf(" * it under the terms of the GNU General Public License as published by\n"); + printf(" * the Free Software Foundation, either version 2 of the License, or\n"); + printf(" * (at your option) any later version.\n"); + printf(" *\n"); + printf(" * This program is distributed in the hope that it will be useful,\n"); + printf(" * but WITHOUT ANY WARRANTY; without even the implied warranty of\n"); + printf(" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"); + printf(" * GNU General Public License for more details.\n"); + printf(" *\n"); + printf(" * You should have received a copy of the GNU General Public License\n"); + printf(" * along with this program. If not, see .\n"); + printf(" */\n"); + printf("\n"); + + print_combo(6); + return 0; +} + diff --git a/test-raidHP-hole.conf b/test-raidHP-hole.conf new file mode 100644 index 00000000..ea4a5730 --- /dev/null +++ b/test-raidHP-hole.conf @@ -0,0 +1,22 @@ +block_size 1 +parity test/parity +q-parity test/q-parity +r-parity test/r-parity +s-parity test/s-parity +t-parity test/t-parity +u-parity test/u-parity +content test/content +content test/p-content +content test/q-content +content test/r-content +content test/s-content +content test/t-content +content test/u-content +disk disk1 test/disk1/ +disk disk3 test/disk3/ +disk disk4 test/disk4/ +disk disk5 test/disk5/ +disk disk6 test/disk6/ +include *.hidden +exclude *.unrecoverable + diff --git a/test-raidHP.conf b/test-raidHP.conf new file mode 100644 index 00000000..55b8b2b9 --- /dev/null +++ b/test-raidHP.conf @@ -0,0 +1,22 @@ +block_size 1 +parity test/parity +q-parity test/q-parity +r-parity test/r-parity +s-parity test/s-parity +t-parity test/t-parity +u-parity test/u-parity +content test/content +content test/p-content +content test/q-content +content test/r-content +content test/t-content +content test/u-content +disk disk1 test/disk1/ +disk disk2 test/disk2/ +disk disk3 test/disk3/ +disk disk4 test/disk4/ +disk disk5 test/disk5/ +disk disk6 test/disk6/ +include *.hidden +exclude *.unrecoverable + diff --git a/test-raidPP.conf b/test-raidPP.conf new file mode 100644 index 00000000..e16b3e71 --- /dev/null +++ b/test-raidPP.conf @@ -0,0 +1,20 @@ +block_size 1 +parity test/parity +q-parity test/q-parity +r-parity test/r-parity +s-parity test/s-parity +t-parity test/t-parity +content test/content +content test/p-content +content test/q-content +content test/r-content +content test/t-content +disk disk1 test/disk1/ +disk disk2 test/disk2/ +disk disk3 test/disk3/ +disk disk4 test/disk4/ +disk disk5 test/disk5/ +disk disk6 test/disk6/ +include *.hidden +exclude *.unrecoverable +