Update to the new RAID library

This commit is contained in:
Andrea Mazzoleni 2026-07-29 12:47:44 +02:00
parent 47b321d97c
commit c79f82bc99
5 changed files with 3790 additions and 15 deletions

View file

@ -5,3 +5,4 @@
#define HAVE_CHECKER 1 #define HAVE_CHECKER 1
#include "snapraid.c" #include "snapraid.c"

View file

@ -1046,35 +1046,64 @@ void selftest(void)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
if (raid_test_par(RAID_MODE_VANDERMONDE, 32, 256) != 0) { if (raid_test_par(RAID_MODE_VANDERMONDE_RAID, 32, 256) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed GEN Vandermonde test\n"); log_fatal(EINTERNAL, "Failed GEN Vandermonde RAID test\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
if (raid_test_rec(RAID_MODE_VANDERMONDE, 12, 256) != 0) { if (raid_test_rec(RAID_MODE_VANDERMONDE_RAID, 12, 256) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed REC Vandermonde test\n"); log_fatal(EINTERNAL, "Failed REC Vandermonde RAID test\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
if (raid_test_par(RAID_MODE_CAUCHY, 32, 256) != 0) { if (raid_test_par(RAID_MODE_CAUCHY_RAID, 32, 256) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed GEN Cauchy test\n"); log_fatal(EINTERNAL, "Failed GEN Cauchy RAID test\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
if (raid_test_rec(RAID_MODE_CAUCHY, 12, 256) != 0) { if (raid_test_rec(RAID_MODE_CAUCHY_RAID, 12, 256) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed REC Cauchy test\n"); log_fatal(EINTERNAL, "Failed REC Cauchy RAID test\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
if (raid_test_par(RAID_MODE_CAUCHY, 1, 256) != 0) { if (raid_test_par(RAID_MODE_CAUCHY_RAID, 1, 256) != 0) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed GEN Cauchy test single data disk\n"); log_fatal(EINTERNAL, "Failed GEN Cauchy RAID test single data disk\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */ /* LCOV_EXCL_STOP */
} }
if (raid_test_par(RAID_MODE_CAUCHY_AES, 32, 256) != 0) {
/* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed GEN Cauchy AES test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (raid_test_rec(RAID_MODE_CAUCHY_AES, 12, 256) != 0) {
/* LCOV_EXCL_START */
log_fatal(EINTERNAL, "Failed REC Cauchy AES test\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
/* Verify raid_mode get/set behavior */
int cur = raid_mode(RAID_MODE_GET);
int prev = raid_mode(RAID_MODE_CAUCHY_AES);
if (prev != cur) {
/* LCOV_EXCL_START */
log_fatal(EINTERNAL, "raid_mode set did not return previous mode\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
if (raid_mode(RAID_MODE_GET) != RAID_MODE_CAUCHY_AES) {
/* LCOV_EXCL_START */
log_fatal(EINTERNAL, "raid_mode GET did not return active mode\n");
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
raid_mode(prev);
} }

View file

@ -95,7 +95,7 @@ static int lev_config_scan(const char* s, unsigned* level, unsigned* mode)
if (strcmp(s, "z-parity") == 0) { if (strcmp(s, "z-parity") == 0) {
*level = 2; *level = 2;
if (mode) if (mode)
*mode = RAID_MODE_VANDERMONDE; *mode = RAID_MODE_VANDERMONDE_RAID;
return 0; return 0;
} }
@ -107,7 +107,7 @@ const char* lev_raid_name(unsigned mode, unsigned n)
switch (n) { switch (n) {
case 1 : return "par1"; case 1 : return "par1";
case 2 : return "par2"; case 2 : return "par2";
case 3 : if (mode == RAID_MODE_CAUCHY) case 3 : if (mode == RAID_MODE_CAUCHY_RAID || mode == RAID_MODE_CAUCHY_AES)
return "par3"; return "par3";
else else
return "parz"; return "parz";
@ -132,7 +132,7 @@ void state_init(struct snapraid_state* state)
state->written = 0; state->written = 0;
state->checked_read = 0; state->checked_read = 0;
state->block_size = 256 * KIBI; /* default 256 KiB */ state->block_size = 256 * KIBI; /* default 256 KiB */
state->raid_mode = RAID_MODE_CAUCHY; state->raid_mode = RAID_MODE_CAUCHY_RAID;
state->file_mode = ADVISE_DEFAULT; state->file_mode = ADVISE_DEFAULT;
for (l = 0; l < LEV_MAX; ++l) { for (l = 0; l < LEV_MAX; ++l) {
state->parity[l].split_mac = 0; state->parity[l].split_mac = 0;
@ -226,7 +226,7 @@ static void state_config_check(struct snapraid_state* state, const char* path, t
unsigned l, s; unsigned l, s;
/* check for parity level */ /* check for parity level */
if (state->raid_mode == RAID_MODE_VANDERMONDE) { if (state->raid_mode == RAID_MODE_VANDERMONDE_RAID) {
if (state->level > 3) { if (state->level > 3) {
/* LCOV_EXCL_START */ /* LCOV_EXCL_START */
log_fatal(EUSER, "Using z-parity limits you to a maximum of 3 parities.\n"); log_fatal(EUSER, "Using z-parity limits you to a maximum of 3 parities.\n");
@ -481,7 +481,7 @@ static void state_config_check(struct snapraid_state* state, const char* path, t
#ifdef CONFIG_X86 #ifdef CONFIG_X86
if (!raid_cpu_has_ssse3()) if (!raid_cpu_has_ssse3())
#endif #endif
if (state->raid_mode == RAID_MODE_CAUCHY && !state->opt.no_warnings) { if ((state->raid_mode == RAID_MODE_CAUCHY_RAID || state->raid_mode == RAID_MODE_CAUCHY_AES) && !state->opt.no_warnings) {
if (state->level == 3) { if (state->level == 3) {
log_info(EUSER, "WARNING! Your CPU doesn't have a fast implementation for triple parity.\n"); log_info(EUSER, "WARNING! Your CPU doesn't have a fast implementation for triple parity.\n");
log_info(EUSER, "WARNING! It's recommended to switch to 'z-parity' instead than '3-parity'.\n"); log_info(EUSER, "WARNING! It's recommended to switch to 'z-parity' instead than '3-parity'.\n");

3744
linux.cfg Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,4 @@
#!/bin/sh #!/bin/sh
uncrustify -c uncrustify.cfg --replace --no-backup cmdline/*.c cmdline/*.h uncrustify -c uncrustify.cfg --replace --no-backup cmdline/*.c cmdline/*.h
uncrustify -c linux.cfg --replace --no-backup raid/*.c raid/*.h raid/test/*.c raid/test/*.h