mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-25 09:26:27 -05:00
Initial RAID6 support. Not yet complete.
Uses Murmur3 as default hash. Check now returns and error even if only recoverable errors are present.
This commit is contained in:
parent
ad70b7e560
commit
08831c6641
24 changed files with 1624 additions and 394 deletions
106
snapraid.c
106
snapraid.c
|
|
@ -17,9 +17,11 @@
|
|||
|
||||
#include "portable.h"
|
||||
|
||||
#include "snapraid.h"
|
||||
#include "util.h"
|
||||
#include "elem.h"
|
||||
#include "state.h"
|
||||
#include "raid.h"
|
||||
|
||||
/****************************************************************************/
|
||||
/* main */
|
||||
|
|
@ -33,91 +35,6 @@
|
|||
#define CONF "/etc/" PACKAGE ".conf"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Test vectors for MD5 from RFC1321.
|
||||
*
|
||||
* MD5("") = d41d8cd98f00b204e9800998ecf8427e
|
||||
* MD5("a") = 0cc175b9c0f1b6a831c399e269772661
|
||||
* MD5("abc") = 900150983cd24fb0d6963f7d28e17f72
|
||||
* MD5("message digest") = f96b697d7cb7938d525a2f31aaf161d0
|
||||
* MD5("abcdefghijklmnopqrstuvwxyz") = c3fcd3d76192e4007dfb496cca67e13b
|
||||
* MD5("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") = d174ab98d277d9f5a5611c2c9f419d9f
|
||||
* MD5("12345678901234567890123456789012345678901234567890123456789012345678901234567890") = 57edf4a22be3c955ac49da2e2107b67a
|
||||
*/
|
||||
struct test_vector {
|
||||
const char* data;
|
||||
unsigned char digest[HASH_SIZE];
|
||||
} TEST[] = {
|
||||
{ "", { 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e } },
|
||||
{ "a", { 0x0c, 0xc1, 0x75, 0xb9, 0xc0, 0xf1, 0xb6, 0xa8, 0x31, 0xc3, 0x99, 0xe2, 0x69, 0x77, 0x26, 0x61 } },
|
||||
{ "abc", { 0x90, 0x01, 0x50, 0x98, 0x3c, 0xd2, 0x4f, 0xb0, 0xd6, 0x96, 0x3f, 0x7d, 0x28, 0xe1, 0x7f, 0x72 } },
|
||||
{ "message digest", { 0xf9, 0x6b, 0x69, 0x7d, 0x7c, 0xb7, 0x93, 0x8d, 0x52, 0x5a, 0x2f, 0x31, 0xaa, 0xf1, 0x61, 0xd0 } },
|
||||
{ "abcdefghijklmnopqrstuvwxyz", { 0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00, 0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b } },
|
||||
{ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", { 0xd1, 0x74, 0xab, 0x98, 0xd2, 0x77, 0xd9, 0xf5, 0xa5, 0x61, 0x1c, 0x2c, 0x9f, 0x41, 0x9d, 0x9f } },
|
||||
{ "12345678901234567890123456789012345678901234567890123456789012345678901234567890", { 0x57, 0xed, 0xf4, 0xa2, 0x2b, 0xe3, 0xc9, 0x55, 0xac, 0x49, 0xda, 0x2e, 0x21, 0x07, 0xb6, 0x7a, } },
|
||||
{ 0, { 0 } }
|
||||
};
|
||||
|
||||
void selftest(void)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
printf("Self test...\n");
|
||||
|
||||
/* large file check */
|
||||
if (sizeof(off_t) < sizeof(uint64_t)) {
|
||||
fprintf(stderr, "Missing support for large files\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* test vectors for MD5. It could be dynamically linked, so we have to test it at runtime */
|
||||
for(i=0;TEST[i].data;++i) {
|
||||
unsigned char digest[HASH_SIZE];
|
||||
memhash(digest, TEST[i].data, strlen(TEST[i].data));
|
||||
if (memcmp(digest, TEST[i].digest, HASH_SIZE) != 0) {
|
||||
fprintf(stderr, "Failed MD5 test vector\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void speed(void)
|
||||
{
|
||||
struct timeval start;
|
||||
struct timeval stop;
|
||||
int64_t ds;
|
||||
int64_t dt;
|
||||
unsigned i;
|
||||
unsigned char digest[HASH_SIZE];
|
||||
|
||||
unsigned count = 10000;
|
||||
unsigned blocksize = 256 * 1024;
|
||||
void* block = malloc_nofail(blocksize);
|
||||
|
||||
#if HAVE_LIBCRYPTO
|
||||
printf("Using OpenSSL libcrypto MD5\n");
|
||||
#else
|
||||
printf("Using portable MD5\n");
|
||||
#endif
|
||||
#ifdef __GNUC__
|
||||
printf("Compiled with gcc " __VERSION__ "\n");
|
||||
#endif
|
||||
|
||||
printf("Hashing speed test...\n");
|
||||
|
||||
gettimeofday(&start, 0);
|
||||
for(i=0;i<count;++i)
|
||||
memhash(digest, block, blocksize);
|
||||
gettimeofday(&stop, 0);
|
||||
|
||||
ds = blocksize * (int64_t)count;
|
||||
dt = (int64_t)1000000 * (stop.tv_sec - start.tv_sec) + (stop.tv_usec - start.tv_usec);
|
||||
|
||||
printf("%llu [MB/s]\n", ds / dt);
|
||||
|
||||
free(block);
|
||||
}
|
||||
|
||||
void version(void)
|
||||
{
|
||||
printf(PACKAGE " v" VERSION " by Andrea Mazzoleni, " PACKAGE_URL "\n");
|
||||
|
|
@ -136,7 +53,6 @@ void usage(void)
|
|||
printf(" " SWITCH_GETOPT_LONG("-E, --force-empty ", "-E") " Force synching of disks that get empty\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-s, --start BLKSTART", "-s") " Start from the specified block number\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-t, --count BLKCOUNT", "-t") " Count of block to process\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-T, --speed-test ", "-T") " Speed test of the MD5 implementation\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-v, --verbose ", "-v") " Verbose\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-h, --help ", "-h") " Help\n");
|
||||
printf(" " SWITCH_GETOPT_LONG("-V, --version ", "-V") " Version\n");
|
||||
|
|
@ -154,11 +70,13 @@ struct option long_options[] = {
|
|||
{ "verbose", 0, 0, 'v' },
|
||||
{ "help", 0, 0, 'h' },
|
||||
{ "version", 0, 0, 'V' },
|
||||
{ "expect-unrecoverable", 0, 0, 'U' },
|
||||
{ "expect-recoverable", 0, 0, 'R' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
#endif
|
||||
|
||||
#define OPTIONS "c:f:s:t:ZETvhV"
|
||||
#define OPTIONS "c:f:s:t:ZEURTvhV"
|
||||
|
||||
volatile int global_interrupt = 0;
|
||||
|
||||
|
|
@ -182,6 +100,8 @@ int main(int argc, char* argv[])
|
|||
int verbose;
|
||||
int force_zero;
|
||||
int force_empty;
|
||||
int expect_unrecoverable;
|
||||
int expect_recoverable;
|
||||
const char* conf;
|
||||
struct snapraid_state state;
|
||||
int operation;
|
||||
|
|
@ -195,6 +115,8 @@ int main(int argc, char* argv[])
|
|||
verbose = 0;
|
||||
force_zero = 0;
|
||||
force_empty = 0;
|
||||
expect_unrecoverable = 0;
|
||||
expect_recoverable = 0;
|
||||
blockstart = 0;
|
||||
blockcount = 0;
|
||||
tommy_list_init(&filterlist);
|
||||
|
|
@ -237,6 +159,12 @@ int main(int argc, char* argv[])
|
|||
case 'E' :
|
||||
force_empty = 1;
|
||||
break;
|
||||
case 'U' :
|
||||
expect_unrecoverable = 1;
|
||||
break;
|
||||
case 'R' :
|
||||
expect_recoverable = 1;
|
||||
break;
|
||||
case 'v' :
|
||||
verbose = 1;
|
||||
break;
|
||||
|
|
@ -275,9 +203,11 @@ int main(int argc, char* argv[])
|
|||
|
||||
selftest();
|
||||
|
||||
raid_init();
|
||||
|
||||
state_init(&state);
|
||||
|
||||
state_config(&state, conf, verbose, force_zero, force_empty);
|
||||
state_config(&state, conf, verbose, force_zero, force_empty, expect_unrecoverable, expect_recoverable);
|
||||
|
||||
if (operation == OPERATION_SYNC) {
|
||||
if (!tommy_list_empty(&filterlist)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue