mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 02:49:02 -04:00
Refactors the RAID engine for a potential independent release.
This commit is contained in:
parent
b81e4a0141
commit
de0c8db8d7
15 changed files with 964 additions and 882 deletions
19
check.c
19
check.c
|
|
@ -93,7 +93,7 @@ static int blockcmp(struct snapraid_state* state, int rehash, struct snapraid_bl
|
|||
/**
|
||||
* Checks if the hash of at least one failed block is now matching.
|
||||
*/
|
||||
static int is_hash_matching(struct snapraid_state* state, int rehash, unsigned diskmax, struct failed_struct* failed, unsigned* failed_map, unsigned failed_count, unsigned char** buffer, unsigned char* buffer_zero)
|
||||
static int is_hash_matching(struct snapraid_state* state, int rehash, unsigned diskmax, struct failed_struct* failed, unsigned* failed_map, unsigned failed_count, void** buffer, void* buffer_zero)
|
||||
{
|
||||
unsigned j;
|
||||
int hash_checked;
|
||||
|
|
@ -122,7 +122,7 @@ static int is_hash_matching(struct snapraid_state* state, int rehash, unsigned d
|
|||
/**
|
||||
* Checks if specified parity is now matching with a recomputed one.
|
||||
*/
|
||||
static int is_parity_matching(struct snapraid_state* state, unsigned diskmax, unsigned i, unsigned char** buffer, unsigned char** buffer_recov)
|
||||
static int is_parity_matching(struct snapraid_state* state, unsigned diskmax, unsigned i, void** buffer, void** buffer_recov)
|
||||
{
|
||||
/* recompute parity, note that we don't need parity over i */
|
||||
raid_par(i + 1, diskmax, state->block_size, buffer);
|
||||
|
|
@ -142,7 +142,7 @@ static int is_parity_matching(struct snapraid_state* state, unsigned diskmax, un
|
|||
* Returns <0 if failure for missing strategy, >0 if data is wrong and we cannot rebuild correctly, 0 on success.
|
||||
* If success, the parity are computed in the buffer variable.
|
||||
*/
|
||||
static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, unsigned diskmax, struct failed_struct* failed, unsigned* failed_map, unsigned failed_count, unsigned char** buffer, unsigned char** buffer_recov, unsigned char* buffer_zero)
|
||||
static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, unsigned diskmax, struct failed_struct* failed, unsigned* failed_map, unsigned failed_count, void** buffer, void** buffer_recov, void* buffer_zero)
|
||||
{
|
||||
unsigned i, n;
|
||||
int error;
|
||||
|
|
@ -199,7 +199,7 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
|
|||
memcpy(buffer[diskmax+ip[i]], buffer_recov[ip[i]], state->block_size);
|
||||
|
||||
/* recover using one less parity, the ip[r-1] one */
|
||||
raid_rec(r-1, id, ip, diskmax, state->block_size, buffer, buffer_zero);
|
||||
raid_rec(r-1, id, ip, diskmax, state->block_size, buffer);
|
||||
|
||||
/* use the remaining ip[r-1] parity to check the result */
|
||||
if (is_parity_matching(state, diskmax, ip[r-1], buffer, buffer_recov))
|
||||
|
|
@ -239,7 +239,7 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
|
|||
memcpy(buffer[diskmax+ip[i]], buffer_recov[ip[i]], state->block_size);
|
||||
|
||||
/* recover */
|
||||
raid_rec(r, id, ip, diskmax, state->block_size, buffer, buffer_zero);
|
||||
raid_rec(r, id, ip, diskmax, state->block_size, buffer);
|
||||
|
||||
/* use the hash to check the result */
|
||||
if (is_hash_matching(state, rehash, diskmax, failed, failed_map, failed_count, buffer, buffer_zero))
|
||||
|
|
@ -264,7 +264,7 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsigned diskmax, struct failed_struct* failed, unsigned* failed_map, unsigned failed_count, unsigned char** buffer, unsigned char** buffer_recov, unsigned char* buffer_zero)
|
||||
static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsigned diskmax, struct failed_struct* failed, unsigned* failed_map, unsigned failed_count, void** buffer, void** buffer_recov, void* buffer_zero)
|
||||
{
|
||||
int ret;
|
||||
int error;
|
||||
|
|
@ -468,7 +468,7 @@ static int state_check_process(struct snapraid_state* state, int check, int fix,
|
|||
block_off_t i;
|
||||
unsigned j;
|
||||
void* buffer_alloc;
|
||||
unsigned char** buffer;
|
||||
void** buffer;
|
||||
unsigned buffermax;
|
||||
int ret;
|
||||
data_off_t countsize;
|
||||
|
|
@ -492,6 +492,7 @@ static int state_check_process(struct snapraid_state* state, int check, int fix,
|
|||
|
||||
/* fill up the zero buffer */
|
||||
memset(buffer[buffermax-1], 0, state->block_size);
|
||||
raid_zero(buffer[buffermax-1]);
|
||||
|
||||
failed = malloc_nofail(diskmax * sizeof(struct failed_struct));
|
||||
failed_map = malloc_nofail(diskmax * sizeof(unsigned));
|
||||
|
|
@ -768,8 +769,8 @@ static int state_check_process(struct snapraid_state* state, int check, int fix,
|
|||
|
||||
/* now read and check the parity if requested */
|
||||
if (check) {
|
||||
unsigned char* buffer_recov[LEV_MAX];
|
||||
unsigned char* buffer_zero;
|
||||
void* buffer_recov[LEV_MAX];
|
||||
void* buffer_zero;
|
||||
|
||||
/* buffers for parity read and not computed */
|
||||
for(l=0;l<state->level;++l)
|
||||
|
|
|
|||
48
cpu.h
48
cpu.h
|
|
@ -15,12 +15,12 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __CPU_H
|
||||
#define __CPU_H
|
||||
#ifndef __RAID_CPU_H
|
||||
#define __RAID_CPU_H
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
|
||||
static inline void cpuid(uint32_t func_eax, uint32_t sub_ecx, uint32_t* reg)
|
||||
static __always_inline void raid_cpuid(uint32_t func_eax, uint32_t sub_ecx, uint32_t* reg)
|
||||
{
|
||||
asm volatile(
|
||||
#if defined(__i386__) && defined(__PIC__)
|
||||
|
|
@ -40,19 +40,19 @@ static inline void cpuid(uint32_t func_eax, uint32_t sub_ecx, uint32_t* reg)
|
|||
|
||||
#define CPU_VENDOR_MAX 13
|
||||
|
||||
static inline void cpu_info(char* vendor, unsigned* family, unsigned* model)
|
||||
static __always_inline void raid_cpu_info(char* vendor, unsigned* family, unsigned* model)
|
||||
{
|
||||
uint32_t reg[4];
|
||||
unsigned f, ef, m, em;
|
||||
|
||||
cpuid(0, 0, reg);
|
||||
raid_cpuid(0, 0, reg);
|
||||
|
||||
((uint32_t*)vendor)[0] = reg[1];
|
||||
((uint32_t*)vendor)[1] = reg[3];
|
||||
((uint32_t*)vendor)[2] = reg[2];
|
||||
vendor[12] = 0;
|
||||
|
||||
cpuid(1, 0, reg);
|
||||
raid_cpuid(1, 0, reg);
|
||||
|
||||
f = (reg[0] >> 8) & 0xF;
|
||||
ef = (reg[0] >> 20) & 0xFF;
|
||||
|
|
@ -73,56 +73,56 @@ static inline void cpu_info(char* vendor, unsigned* family, unsigned* model)
|
|||
}
|
||||
}
|
||||
|
||||
static inline int cpu_has_mmx(void)
|
||||
static __always_inline int raid_cpu_has_mmx(void)
|
||||
{
|
||||
uint32_t reg[4];
|
||||
|
||||
cpuid(1, 0, reg);
|
||||
raid_cpuid(1, 0, reg);
|
||||
|
||||
return (reg[3] >> 23) & 1;
|
||||
}
|
||||
|
||||
static inline int cpu_has_sse2(void)
|
||||
static __always_inline int raid_cpu_has_sse2(void)
|
||||
{
|
||||
uint32_t reg[4];
|
||||
|
||||
cpuid(1, 0, reg);
|
||||
raid_cpuid(1, 0, reg);
|
||||
|
||||
return (reg[3] >> 26) & 1;
|
||||
}
|
||||
|
||||
static inline int cpu_has_ssse3(void)
|
||||
static __always_inline int raid_cpu_has_ssse3(void)
|
||||
{
|
||||
uint32_t reg[4];
|
||||
|
||||
cpuid(1, 0, reg);
|
||||
raid_cpuid(1, 0, reg);
|
||||
|
||||
return (reg[2] >> 9) & 1;
|
||||
}
|
||||
|
||||
static inline int cpu_has_sse42(void)
|
||||
static __always_inline int raid_cpu_has_sse42(void)
|
||||
{
|
||||
uint32_t reg[4];
|
||||
|
||||
cpuid(1, 0, reg);
|
||||
raid_cpuid(1, 0, reg);
|
||||
|
||||
return (reg[2] >> 20) & 1;
|
||||
}
|
||||
|
||||
static inline int cpu_has_avx(void)
|
||||
static __always_inline int raid_cpu_has_avx(void)
|
||||
{
|
||||
uint32_t reg[4];
|
||||
|
||||
cpuid(1, 0, reg);
|
||||
raid_cpuid(1, 0, reg);
|
||||
|
||||
return (reg[2] >> 28) & 1;
|
||||
}
|
||||
|
||||
static inline int cpu_has_avx2(void)
|
||||
static __always_inline int raid_cpu_has_avx2(void)
|
||||
{
|
||||
uint32_t reg[4];
|
||||
|
||||
cpuid(7, 0, reg);
|
||||
raid_cpuid(7, 0, reg);
|
||||
|
||||
return (reg[1] >> 5) & 1;
|
||||
}
|
||||
|
|
@ -131,13 +131,13 @@ static inline int cpu_has_avx2(void)
|
|||
* Check if the processor has a slow MULT implementation.
|
||||
* If yes, it's better to use a hash not based on multiplication.
|
||||
*/
|
||||
static inline int cpu_has_slowmult(void)
|
||||
static __always_inline int raid_cpu_has_slowmult(void)
|
||||
{
|
||||
char vendor[CPU_VENDOR_MAX];
|
||||
unsigned family;
|
||||
unsigned model;
|
||||
|
||||
cpu_info(vendor, &family, &model);
|
||||
raid_cpu_info(vendor, &family, &model);
|
||||
|
||||
if (strcmp(vendor, "GenuineIntel") == 0) {
|
||||
/* Intel(R) Atom(TM) CPU D525 @ 1.80GHz (info from user)
|
||||
|
|
@ -169,13 +169,13 @@ static inline int cpu_has_slowmult(void)
|
|||
* Check if the processor has a slow PSHUFB implementation.
|
||||
* If yes, it's better to not use it.
|
||||
*/
|
||||
static inline int cpu_has_slowpshufb(void)
|
||||
static __always_inline int raid_cpu_has_slowpshufb(void)
|
||||
{
|
||||
char vendor[CPU_VENDOR_MAX];
|
||||
unsigned family;
|
||||
unsigned model;
|
||||
|
||||
cpu_info(vendor, &family, &model);
|
||||
raid_cpu_info(vendor, &family, &model);
|
||||
|
||||
if (strcmp(vendor, "GenuineIntel") == 0) {
|
||||
/* Intel ATOM (info from x264 -> full family/model 6/28) */
|
||||
|
|
@ -233,13 +233,13 @@ static inline int cpu_has_slowpshufb(void)
|
|||
* Check if the processor has a slow extended set of SSE registers.
|
||||
* If yes, it's better to unroll without using the second part of registers.
|
||||
*/
|
||||
static inline int cpu_has_slowextendedreg(void)
|
||||
static __always_inline int raid_cpu_has_slowextendedreg(void)
|
||||
{
|
||||
char vendor[CPU_VENDOR_MAX];
|
||||
unsigned family;
|
||||
unsigned model;
|
||||
|
||||
cpu_info(vendor, &family, &model);
|
||||
raid_cpu_info(vendor, &family, &model);
|
||||
|
||||
if (strcmp(vendor, "AuthenticAMD") == 0) {
|
||||
/* AMD Bulldozer (from user)
|
||||
|
|
|
|||
39
mktables.c
39
mktables.c
|
|
@ -16,13 +16,14 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* Multiplication in GF(2^8).
|
||||
*/
|
||||
unsigned char gfmul(unsigned char a, unsigned char b)
|
||||
static uint8_t gfmul(uint8_t a, uint8_t b)
|
||||
{
|
||||
unsigned char v;
|
||||
uint8_t v;
|
||||
|
||||
v = 0;
|
||||
while (b) {
|
||||
|
|
@ -45,7 +46,7 @@ unsigned char gfmul(unsigned char a, unsigned char b)
|
|||
/**
|
||||
* Inversion table in GF(2^8).
|
||||
*/
|
||||
unsigned char gfinv[256];
|
||||
uint8_t gfinv[256];
|
||||
|
||||
/**
|
||||
* Number of parity.
|
||||
|
|
@ -62,10 +63,10 @@ unsigned char gfinv[256];
|
|||
/**
|
||||
* Setup the Cauchy matrix used to generate the parity.
|
||||
*/
|
||||
void set_cauchy(unsigned char* matrix)
|
||||
static void set_cauchy(uint8_t* matrix)
|
||||
{
|
||||
int i, j;
|
||||
unsigned char inv_x, y;
|
||||
uint8_t inv_x, y;
|
||||
|
||||
/*
|
||||
* First row is formed by all 1.
|
||||
|
|
@ -110,7 +111,7 @@ void set_cauchy(unsigned char* matrix)
|
|||
for(j=0;j<PARITY-2;++j) {
|
||||
inv_x = 1;
|
||||
for(i=0;i<DISK;++i) {
|
||||
unsigned char x = gfinv[inv_x];
|
||||
uint8_t x = gfinv[inv_x];
|
||||
matrix[(j+2)*DISK+i] = gfinv[y ^ x];
|
||||
inv_x = gfmul(2, inv_x);
|
||||
}
|
||||
|
|
@ -126,7 +127,7 @@ void set_cauchy(unsigned char* matrix)
|
|||
* submatrices are not singular.
|
||||
*/
|
||||
for(j=0;j<PARITY-2;++j) {
|
||||
unsigned char f = gfinv[matrix[(j+2)*DISK]];
|
||||
uint8_t f = gfinv[matrix[(j+2)*DISK]];
|
||||
|
||||
for(i=0;i<DISK;++i) {
|
||||
matrix[(j+2)*DISK+i] = gfmul(matrix[(j+2)*DISK+i], f);
|
||||
|
|
@ -137,10 +138,10 @@ void set_cauchy(unsigned char* matrix)
|
|||
/**
|
||||
* Setup the Power matrix used to generate the parity.
|
||||
*/
|
||||
void set_power(unsigned char* matrix)
|
||||
static void set_power(uint8_t* matrix)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned char v;
|
||||
uint8_t v;
|
||||
|
||||
v = 1;
|
||||
for(i=0;i<DISK;++i) {
|
||||
|
|
@ -163,7 +164,7 @@ void set_power(unsigned char* matrix)
|
|||
/**
|
||||
* Next power of 2.
|
||||
*/
|
||||
unsigned np(unsigned v)
|
||||
static unsigned np(unsigned v)
|
||||
{
|
||||
--v;
|
||||
v |= v >> 1;
|
||||
|
|
@ -178,9 +179,9 @@ unsigned np(unsigned v)
|
|||
|
||||
int main(void)
|
||||
{
|
||||
unsigned char v;
|
||||
uint8_t v;
|
||||
int i, j, k, p;
|
||||
unsigned char matrix[PARITY * 256];
|
||||
uint8_t matrix[PARITY * 256];
|
||||
|
||||
printf("/*\n");
|
||||
printf(" * Copyright (C) 2013 Andrea Mazzoleni\n");
|
||||
|
|
@ -201,7 +202,7 @@ int main(void)
|
|||
printf("\n");
|
||||
|
||||
/* a*b */
|
||||
printf("const unsigned char __attribute__((aligned(256))) gfmul[256][256] =\n");
|
||||
printf("const uint8_t __attribute__((aligned(256))) gfmul[256][256] =\n");
|
||||
printf("{\n");
|
||||
for(i=0;i<256;++i) {
|
||||
printf("\t{\n");
|
||||
|
|
@ -222,7 +223,7 @@ int main(void)
|
|||
printf("};\n\n");
|
||||
|
||||
/* 2^a */
|
||||
printf("const unsigned char __attribute__((aligned(256))) gfexp2[256] =\n");
|
||||
printf("const uint8_t __attribute__((aligned(256))) gfexp[256] =\n");
|
||||
printf("{\n");
|
||||
v = 1;
|
||||
for(i=0;i<256;++i) {
|
||||
|
|
@ -238,7 +239,7 @@ int main(void)
|
|||
printf("};\n\n");
|
||||
|
||||
/* 1/a */
|
||||
printf("const unsigned char __attribute__((aligned(256))) gfinv[256] =\n");
|
||||
printf("const uint8_t __attribute__((aligned(256))) gfinv[256] =\n");
|
||||
printf("{\n");
|
||||
printf("\t/* note that the first element is not significative */\n");
|
||||
for(i=0;i<256;++i) {
|
||||
|
|
@ -271,7 +272,7 @@ int main(void)
|
|||
printf("\n");
|
||||
}
|
||||
printf(" */\n");
|
||||
printf("const unsigned char __attribute__((aligned(256))) gfvandermonde[%u][256] =\n", 3);
|
||||
printf("const uint8_t __attribute__((aligned(256))) gfvandermonde[%u][256] =\n", 3);
|
||||
printf("{\n");
|
||||
for(p=0;p<3;++p) {
|
||||
printf("\t{\n");
|
||||
|
|
@ -303,7 +304,7 @@ int main(void)
|
|||
printf("\n");
|
||||
}
|
||||
printf(" */\n");
|
||||
printf("const unsigned char __attribute__((aligned(256))) gfcauchy[%u][256] =\n", PARITY);
|
||||
printf("const uint8_t __attribute__((aligned(256))) gfcauchy[%u][256] =\n", PARITY);
|
||||
printf("{\n");
|
||||
for(p=0;p<PARITY;++p) {
|
||||
printf("\t{\n");
|
||||
|
|
@ -327,7 +328,7 @@ int main(void)
|
|||
printf(" * Indexes are [DISK][PARITY - 2][LH].\n");
|
||||
printf(" * Where DISK is from 0 to %u, PARITY from 2 to %u, LH from 0 to 1.\n", DISK - 1, PARITY - 1);
|
||||
printf(" */\n");
|
||||
printf("const unsigned char __attribute__((aligned(256))) gfgenpshufb[%u][%u][2][16] =\n", DISK, np(PARITY - 2));
|
||||
printf("const uint8_t __attribute__((aligned(256))) gfcauchypshufb[%u][%u][2][16] =\n", DISK, np(PARITY - 2));
|
||||
printf("{\n");
|
||||
for(i=0;i<DISK;++i) {
|
||||
printf("\t{\n");
|
||||
|
|
@ -359,7 +360,7 @@ int main(void)
|
|||
printf(" * Indexes are [MULTIPLER][LH].\n");
|
||||
printf(" * Where MULTIPLER is from 0 to 255, LH from 0 to 1.\n");
|
||||
printf(" */\n");
|
||||
printf("const unsigned char __attribute__((aligned(256))) gfmulpshufb[256][2][16] =\n");
|
||||
printf("const uint8_t __attribute__((aligned(256))) gfmulpshufb[256][2][16] =\n");
|
||||
printf("{\n");
|
||||
for(i=0;i<256;++i) {
|
||||
printf("\t{\n");
|
||||
|
|
|
|||
|
|
@ -173,6 +173,13 @@
|
|||
#include "unix.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Missing __always_inline, like in MINGW.
|
||||
*/
|
||||
#ifndef __always_inline
|
||||
#define __always_inline inline __attribute__((always_inline))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Another name for link() to avoid confusion with local variables called "link".
|
||||
*/
|
||||
|
|
|
|||
134
raid.h
134
raid.h
|
|
@ -41,14 +41,9 @@
|
|||
#define RAID_MODE_VANDERMONDE 1
|
||||
|
||||
/**
|
||||
* Max level of parity supported for RAID_MODE_CAUCHY.
|
||||
* Max level of parity supported in the default mode RAID_MODE_CAUCHY.
|
||||
*/
|
||||
#define RAID_PARITY_CAUCHY_MAX 6
|
||||
|
||||
/**
|
||||
* Max level of parity supported for RAID_MODE_VANDERMONDE.
|
||||
*/
|
||||
#define RAID_PARITY_VANDERMONDE_MAX 3
|
||||
#define RAID_PARITY_MAX 6
|
||||
|
||||
/**
|
||||
* Maximum number of data disks.
|
||||
|
|
@ -62,39 +57,74 @@
|
|||
void raid_init(void);
|
||||
|
||||
/**
|
||||
* Set the RAID mode to use. One of RAID_MODE_*.
|
||||
* Sets the mode to use. One of RAID_MODE_*.
|
||||
*
|
||||
* You can change mode at any time, and it will affect next calls to raid_par() and raid_rec().
|
||||
* You can change mode at any time, and it will affect next calls to raid_par(),
|
||||
* raid_rec() and raid_recpar().
|
||||
*
|
||||
* The two modes are compatible for the first two levels of parity. The third one is different.
|
||||
* The two modes are compatible for the first two levels of parity. The third one
|
||||
* is different.
|
||||
*/
|
||||
void raid_set(unsigned mode);
|
||||
void raid_mode(int mode);
|
||||
|
||||
/**
|
||||
* Sets the zero buffer to use in recovering.
|
||||
*
|
||||
* Before calling raid_rec() and raid_recpar() you must provide a memory
|
||||
* buffer filled with zero with the same size of the blocks to recover.
|
||||
*/
|
||||
void raid_zero(void* zero);
|
||||
|
||||
/**
|
||||
* Computes the parity.
|
||||
*
|
||||
* \param np Number of parities to compute.
|
||||
* \param nd Number of data disks.
|
||||
* \param size Size of the blocks pointed by vbuf. It must be a power of 2, and at least 64.
|
||||
* \param vbuf Vector of pointers to the blocks for disks and parities.
|
||||
* It has (::nd + ::np) elements. Each element points to a buffer of ::size bytes.
|
||||
* \param size Size of the blocks pointed by vv. It must be a power of 2, and at least 64.
|
||||
* \param vv Vector of pointers to the blocks for disks and parities.
|
||||
* It has (::nd + ::np) elements. Each element points to a buffer of ::size bytes.
|
||||
*/
|
||||
void raid_par(unsigned np, unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_par(int np, int nd, size_t size, void** vv);
|
||||
|
||||
/**
|
||||
* Recovers failures of data disks using the specified parities.
|
||||
*
|
||||
* Note that only the data blocks are recovered. The parity is destroyed.
|
||||
* \param nr Number of failed disks to recover.
|
||||
* Only the data blocks are recovered. The parity buffers are destroyed.
|
||||
* If you want also to recompute parities, you can use raid_recpar().
|
||||
*
|
||||
* \param nr Number of failed data disks to recover.
|
||||
* \param id[] Vector of ::nr indexes of the data disks to recover. Starting from 0.
|
||||
* \param ip[] Vector of ::nr indexes of the parity to use for the recovering. Starting from 0.
|
||||
* \param ip[] Vector of ::nr indexes of the parity disks to use for recovering. Starting from 0.
|
||||
* \param nd Number of data disks.
|
||||
* \param size Size of the blocks pointed by vbuf. It must be a power of 2, and at least 64.
|
||||
* \param vbuf Vector of pointers to the blocks for disks and parities.
|
||||
* It has (::nd + max(::ip[] + 1)) elements. Each element points to a buffer of ::size bytes.
|
||||
* \param zero Buffer filled with 0 of ::size bytes. This buffer is not modified.
|
||||
* \param size Size of the blocks pointed by vv. It must be a power of 2, and at least 64.
|
||||
* \param vv Vector of pointers to the blocks for disks and parities.
|
||||
* It has (::nd + ::ip[::nr - 1] + 1) elements. Each element points to a buffer of ::size bytes.
|
||||
*/
|
||||
void raid_rec(unsigned nr, const int* id, const int* ip, unsigned nd, unsigned size, unsigned char** vbuf, unsigned char* zero);
|
||||
void raid_rec(int nr, const int* id, const int* ip, int nd, size_t size, void** vv);
|
||||
|
||||
/**
|
||||
* Recovers failures of data and parity disks.
|
||||
*
|
||||
* It's similar at raid_rec() but it also recovers parities.
|
||||
*
|
||||
* In case there are more parities available than needed, ones to use are
|
||||
* automatically selected, excluding the ones specified in the ::ip vector.
|
||||
*
|
||||
* Ensure to have ::nrd + ::nrp <= ::np, otherwise recovering is not possible.
|
||||
*
|
||||
* \param nrd Number of failed data disks to recover.
|
||||
* \param id[] Vector of ::nrd indexes of the data disks to recover. Starting from 0.
|
||||
* \param nrp Number of failed parity disks to recover.
|
||||
* \param ip[] Vector of ::nrp indexes of the parity disks to recover. Starting from 0.
|
||||
* Note that as difference than raid_rec() these are the failed parities.
|
||||
* All the parities not specified here are assumed correct, and they are not recomputed.
|
||||
* \param np Number of parity disks.
|
||||
* \param nd Number of data disks.
|
||||
* \param size Size of the blocks pointed by vv. It must be a power of 2, and at least 64.
|
||||
* \param vv Vector of pointers to the blocks for disks and parities.
|
||||
* It has (::nd + ::np) elements. Each element points to a buffer of ::size bytes.
|
||||
*/
|
||||
void raid_recpar(int nrd, const int* id, int nrp, int* ip, int np, int nd, size_t size, void** vv);
|
||||
|
||||
/**
|
||||
* Gets the name of the selected function to compute the parity.
|
||||
|
|
@ -115,34 +145,34 @@ const char* raid_recX_tag(void);
|
|||
* Specialized parity computation.
|
||||
* Only for testing.
|
||||
*/
|
||||
void raid_par1_int32(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_par1_int64(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_par1_sse2(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_par2_int32(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_par2_int64(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_par2_sse2(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_par2_sse2ext(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_parz_int32(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_parz_int64(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_parz_sse2(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_parz_sse2ext(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_par3_int8(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_par3_ssse3(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_par3_ssse3ext(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_par4_int8(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_par4_ssse3(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_par4_ssse3ext(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_par5_int8(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_par5_ssse3(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_par5_ssse3ext(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_par6_int8(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_par6_ssse3(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_par6_ssse3ext(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void raid_rec1_int8(unsigned nr, const int* id, const int* ip, unsigned nd, unsigned size, unsigned char** vbuf, unsigned char* zero);
|
||||
void raid_rec2_int8(unsigned nr, const int* id, const int* ip, unsigned nd, unsigned size, unsigned char** vbuf, unsigned char* zero);
|
||||
void raid_recX_int8(unsigned nr, const int* id, const int* ip, unsigned nd, unsigned size, unsigned char** vbuf, unsigned char* zero);
|
||||
void raid_rec1_ssse3(unsigned nr, const int* id, const int* ip, unsigned nd, unsigned size, unsigned char** vbuf, unsigned char* zero);
|
||||
void raid_rec2_ssse3(unsigned nr, const int* id, const int* ip, unsigned nd, unsigned size, unsigned char** vbuf, unsigned char* zero);
|
||||
void raid_recX_ssse3(unsigned nr, const int* id, const int* ip, unsigned nd, unsigned size, unsigned char** vbuf, unsigned char* zero);
|
||||
void raid_par1_int32(int nd, size_t size, void** vv);
|
||||
void raid_par1_int64(int nd, size_t size, void** vv);
|
||||
void raid_par1_sse2(int nd, size_t size, void** vv);
|
||||
void raid_par2_int32(int nd, size_t size, void** vv);
|
||||
void raid_par2_int64(int nd, size_t size, void** vv);
|
||||
void raid_par2_sse2(int nd, size_t size, void** vv);
|
||||
void raid_par2_sse2ext(int nd, size_t size, void** vv);
|
||||
void raid_parz_int32(int nd, size_t size, void** vv);
|
||||
void raid_parz_int64(int nd, size_t size, void** vv);
|
||||
void raid_parz_sse2(int nd, size_t size, void** vv);
|
||||
void raid_parz_sse2ext(int nd, size_t size, void** vv);
|
||||
void raid_par3_int8(int nd, size_t size, void** vv);
|
||||
void raid_par3_ssse3(int nd, size_t size, void** vv);
|
||||
void raid_par3_ssse3ext(int nd, size_t size, void** vv);
|
||||
void raid_par4_int8(int nd, size_t size, void** vv);
|
||||
void raid_par4_ssse3(int nd, size_t size, void** vv);
|
||||
void raid_par4_ssse3ext(int nd, size_t size, void** vv);
|
||||
void raid_par5_int8(int nd, size_t size, void** vv);
|
||||
void raid_par5_ssse3(int nd, size_t size, void** vv);
|
||||
void raid_par5_ssse3ext(int nd, size_t size, void** vv);
|
||||
void raid_par6_int8(int nd, size_t size, void** vv);
|
||||
void raid_par6_ssse3(int nd, size_t size, void** vv);
|
||||
void raid_par6_ssse3ext(int nd, size_t size, void** vv);
|
||||
void raid_rec1_int8(int nr, const int* id, const int* ip, int nd, size_t size, void** vv);
|
||||
void raid_rec2_int8(int nr, const int* id, const int* ip, int nd, size_t size, void** vv);
|
||||
void raid_recX_int8(int nr, const int* id, const int* ip, int nd, size_t size, void** vv);
|
||||
void raid_rec1_ssse3(int nr, const int* id, const int* ip, int nd, size_t size, void** vv);
|
||||
void raid_rec2_ssse3(int nr, const int* id, const int* ip, int nd, size_t size, void** vv);
|
||||
void raid_recX_ssse3(int nr, const int* id, const int* ip, int nd, size_t size, void** vv);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
2
scrub.c
2
scrub.c
|
|
@ -44,7 +44,7 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
|
|||
block_off_t i;
|
||||
unsigned j;
|
||||
void* buffer_alloc;
|
||||
unsigned char** buffer;
|
||||
void** buffer;
|
||||
unsigned buffermax;
|
||||
data_off_t countsize;
|
||||
block_off_t countpos;
|
||||
|
|
|
|||
59
selftest.c
59
selftest.c
|
|
@ -83,29 +83,29 @@ static void combotest(void)
|
|||
static void recovtest(unsigned mode, unsigned nd, unsigned block_size)
|
||||
{
|
||||
void* buffer_alloc;
|
||||
unsigned char** buffer;
|
||||
unsigned char** data;
|
||||
unsigned char** parity;
|
||||
unsigned char** test;
|
||||
unsigned char* data_save[LEV_MAX];
|
||||
unsigned char* parity_save[LEV_MAX];
|
||||
unsigned char* zero;
|
||||
unsigned char* waste;
|
||||
void** buffer;
|
||||
void** data;
|
||||
void** parity;
|
||||
void** test;
|
||||
void* data_save[LEV_MAX];
|
||||
void* parity_save[LEV_MAX];
|
||||
void* zero;
|
||||
void* waste;
|
||||
unsigned buffermax;
|
||||
int id[LEV_MAX];
|
||||
int ip[LEV_MAX];
|
||||
unsigned i;
|
||||
unsigned j;
|
||||
unsigned nr;
|
||||
void (*map[LEV_MAX][4])(unsigned nr, const int* id, const int* ip, unsigned nd, unsigned size, unsigned char** vbuf, unsigned char* zero);
|
||||
void (*map[LEV_MAX][4])(int nr, const int* id, const int* ip, int nd, size_t size, void** vbuf);
|
||||
unsigned mac[LEV_MAX];
|
||||
unsigned np;
|
||||
|
||||
raid_set(mode);
|
||||
raid_mode(mode);
|
||||
if (mode == RAID_MODE_CAUCHY)
|
||||
np = RAID_PARITY_CAUCHY_MAX;
|
||||
np = RAID_PARITY_MAX;
|
||||
else
|
||||
np = RAID_PARITY_VANDERMONDE_MAX;
|
||||
np = 3;
|
||||
|
||||
buffermax = nd + np * 2 + 2;
|
||||
|
||||
|
|
@ -121,14 +121,12 @@ static void recovtest(unsigned mode, unsigned nd, unsigned block_size)
|
|||
|
||||
zero = buffer[buffermax-2];
|
||||
memset(zero, 0, block_size);
|
||||
raid_zero(zero);
|
||||
|
||||
waste = buffer[buffermax-1];
|
||||
|
||||
/* fill data disk with random */
|
||||
for(i=0;i<nd;++i) {
|
||||
for(j=0;j<block_size;++j)
|
||||
data[i][j] = rand();
|
||||
}
|
||||
mrand_vector(buffer, nd, block_size);
|
||||
|
||||
/* setup recov functions */
|
||||
for(i=0;i<np;++i) {
|
||||
|
|
@ -136,21 +134,21 @@ static void recovtest(unsigned mode, unsigned nd, unsigned block_size)
|
|||
if (i == 0) {
|
||||
map[i][mac[i]++] = raid_rec1_int8;
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
if (raid_cpu_has_ssse3()) {
|
||||
map[i][mac[i]++] = raid_rec1_ssse3;
|
||||
}
|
||||
#endif
|
||||
} else if (i == 1) {
|
||||
map[i][mac[i]++] = raid_rec2_int8;
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
if (raid_cpu_has_ssse3()) {
|
||||
map[i][mac[i]++] = raid_rec2_ssse3;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
map[i][mac[i]++] = raid_recX_int8;
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
if (raid_cpu_has_ssse3()) {
|
||||
map[i][mac[i]++] = raid_recX_ssse3;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -184,7 +182,7 @@ static void recovtest(unsigned mode, unsigned nd, unsigned block_size)
|
|||
}
|
||||
|
||||
/* recover */
|
||||
map[nr-1][0](nr, id, ip, nd, block_size, buffer, zero);
|
||||
map[nr-1][0](nr, id, ip, nd, block_size, buffer);
|
||||
|
||||
/* check */
|
||||
for(i=0;i<nr;++i) {
|
||||
|
|
@ -213,18 +211,18 @@ static void recovtest(unsigned mode, unsigned nd, unsigned block_size)
|
|||
static void gentest(unsigned mode, unsigned nd, unsigned block_size)
|
||||
{
|
||||
void* buffer_alloc;
|
||||
unsigned char** buffer;
|
||||
void** buffer;
|
||||
unsigned buffermax;
|
||||
unsigned i, j;
|
||||
void (*map[64])(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
void (*map[64])(int nd, size_t size, void** vbuf);
|
||||
unsigned mac;
|
||||
unsigned np;
|
||||
|
||||
raid_set(mode);
|
||||
raid_mode(mode);
|
||||
if (mode == RAID_MODE_CAUCHY)
|
||||
np = RAID_PARITY_CAUCHY_MAX;
|
||||
np = RAID_PARITY_MAX;
|
||||
else
|
||||
np = RAID_PARITY_VANDERMONDE_MAX;
|
||||
np = 3;
|
||||
|
||||
buffermax = nd + np * 2;
|
||||
|
||||
|
|
@ -232,10 +230,7 @@ static void gentest(unsigned mode, unsigned nd, unsigned block_size)
|
|||
mtest_vector(buffer, buffermax, block_size);
|
||||
|
||||
/* fill with random */
|
||||
for(i=0;i<nd;++i) {
|
||||
for(j=0;j<block_size;++j)
|
||||
buffer[i][j] = rand();
|
||||
}
|
||||
mrand_vector(buffer, buffermax, block_size);
|
||||
|
||||
/* compute the parity */
|
||||
raid_par(np, nd, block_size, buffer);
|
||||
|
|
@ -253,7 +248,7 @@ static void gentest(unsigned mode, unsigned nd, unsigned block_size)
|
|||
map[mac++] = raid_par2_int64;
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_sse2()) {
|
||||
if (raid_cpu_has_sse2()) {
|
||||
map[mac++] = raid_par1_sse2;
|
||||
map[mac++] = raid_par2_sse2;
|
||||
#if defined(__x86_64__)
|
||||
|
|
@ -267,7 +262,7 @@ static void gentest(unsigned mode, unsigned nd, unsigned block_size)
|
|||
map[mac++] = raid_par5_int8;
|
||||
map[mac++] = raid_par6_int8;
|
||||
|
||||
if (cpu_has_ssse3()) {
|
||||
if (raid_cpu_has_ssse3()) {
|
||||
map[mac++] = raid_par3_ssse3;
|
||||
map[mac++] = raid_par4_ssse3;
|
||||
map[mac++] = raid_par5_ssse3;
|
||||
|
|
@ -284,7 +279,7 @@ static void gentest(unsigned mode, unsigned nd, unsigned block_size)
|
|||
#if defined(__i386__) || defined(__x86_64__)
|
||||
map[mac++] = raid_parz_int32;
|
||||
map[mac++] = raid_parz_int64;
|
||||
if (cpu_has_sse2()) {
|
||||
if (raid_cpu_has_sse2()) {
|
||||
map[mac++] = raid_parz_sse2;
|
||||
#if defined(__x86_64__)
|
||||
map[mac++] = raid_parz_sse2ext;
|
||||
|
|
|
|||
|
|
@ -561,7 +561,7 @@ int main(int argc, char* argv[])
|
|||
state_config(&state, conf, command, &opt, &filterlist_disk);
|
||||
|
||||
/* set the raid mode */
|
||||
raid_set(state.raid_mode);
|
||||
raid_mode(state.raid_mode);
|
||||
|
||||
#if HAVE_LOCKFILE
|
||||
/* create the lock file */
|
||||
|
|
|
|||
89
speed.c
89
speed.c
|
|
@ -67,8 +67,8 @@ void speed(void)
|
|||
unsigned nd = 8;
|
||||
unsigned buffermax;
|
||||
void* buffer_alloc;
|
||||
unsigned char** buffer;
|
||||
unsigned char* zero;
|
||||
void** buffer;
|
||||
void* zero;
|
||||
|
||||
/* we need disk + 1 for each parity buffers + 1 zero buffer */
|
||||
buffermax = nd + LEV_MAX + 1;
|
||||
|
|
@ -84,6 +84,7 @@ void speed(void)
|
|||
/* zero buffer */
|
||||
zero = buffer[nd+LEV_MAX];
|
||||
memset(zero, 0, block_size);
|
||||
raid_zero(zero);
|
||||
|
||||
/* hash seed */
|
||||
for(i=0;i<HASH_SIZE;++i) {
|
||||
|
|
@ -108,17 +109,17 @@ void speed(void)
|
|||
unsigned family;
|
||||
unsigned model;
|
||||
|
||||
cpu_info(vendor, &family, &model);
|
||||
raid_cpu_info(vendor, &family, &model);
|
||||
|
||||
printf("CPU %s, family %u, model %u, flags%s%s%s%s%s%s%s%s\n", vendor, family, model,
|
||||
cpu_has_mmx() ? " mmx" : "",
|
||||
cpu_has_sse2() ? " sse2" : "",
|
||||
cpu_has_ssse3() ? " ssse3" : "",
|
||||
cpu_has_sse42() ? " sse42" : "",
|
||||
cpu_has_avx() ? " avx" : "",
|
||||
cpu_has_avx2() ? "avx2" : "",
|
||||
cpu_has_slowmult() ? " slowmult" : "",
|
||||
cpu_has_slowpshufb() ? " slowpshufb" : ""
|
||||
raid_cpu_has_mmx() ? " mmx" : "",
|
||||
raid_cpu_has_sse2() ? " sse2" : "",
|
||||
raid_cpu_has_ssse3() ? " ssse3" : "",
|
||||
raid_cpu_has_sse42() ? " sse42" : "",
|
||||
raid_cpu_has_avx() ? " avx" : "",
|
||||
raid_cpu_has_avx2() ? "avx2" : "",
|
||||
raid_cpu_has_slowmult() ? " slowmult" : "",
|
||||
raid_cpu_has_slowpshufb() ? " slowpshufb" : ""
|
||||
);
|
||||
}
|
||||
#else
|
||||
|
|
@ -179,7 +180,7 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
#if HAVE_CRC32B
|
||||
if (cpu_has_sse42()) {
|
||||
if (raid_cpu_has_sse42()) {
|
||||
SPEED_START {
|
||||
for(j=0;j<nd;++j) {
|
||||
crc32c_x86(0, buffer[j], block_size);
|
||||
|
|
@ -203,7 +204,7 @@ void speed(void)
|
|||
|
||||
printf("%8s", "hash");
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (sizeof(void*) == 4 && !cpu_has_slowmult())
|
||||
if (sizeof(void*) == 4 && !raid_cpu_has_slowmult())
|
||||
printf("%8s", "murmur3");
|
||||
else
|
||||
printf("%8s", "spooky2");
|
||||
|
|
@ -275,7 +276,7 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_sse2()) {
|
||||
if (raid_cpu_has_sse2()) {
|
||||
SPEED_START {
|
||||
raid_par1_sse2(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
|
@ -308,7 +309,7 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_sse2()) {
|
||||
if (raid_cpu_has_sse2()) {
|
||||
SPEED_START {
|
||||
raid_par2_sse2(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
|
@ -350,7 +351,7 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_sse2()) {
|
||||
if (raid_cpu_has_sse2()) {
|
||||
SPEED_START {
|
||||
raid_parz_sse2(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
|
@ -385,7 +386,7 @@ void speed(void)
|
|||
printf("%8s", "");
|
||||
printf("%8s", "");
|
||||
|
||||
if (cpu_has_sse2()) {
|
||||
if (raid_cpu_has_sse2()) {
|
||||
printf("%8s", "");
|
||||
|
||||
#if defined(__x86_64__)
|
||||
|
|
@ -394,7 +395,7 @@ void speed(void)
|
|||
}
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
if (raid_cpu_has_ssse3()) {
|
||||
SPEED_START {
|
||||
raid_par3_ssse3(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
|
@ -429,7 +430,7 @@ void speed(void)
|
|||
printf("%8s", "");
|
||||
printf("%8s", "");
|
||||
|
||||
if (cpu_has_sse2()) {
|
||||
if (raid_cpu_has_sse2()) {
|
||||
printf("%8s", "");
|
||||
|
||||
#if defined(__x86_64__)
|
||||
|
|
@ -438,7 +439,7 @@ void speed(void)
|
|||
}
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
if (raid_cpu_has_ssse3()) {
|
||||
SPEED_START {
|
||||
raid_par4_ssse3(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
|
@ -473,7 +474,7 @@ void speed(void)
|
|||
printf("%8s", "");
|
||||
printf("%8s", "");
|
||||
|
||||
if (cpu_has_sse2()) {
|
||||
if (raid_cpu_has_sse2()) {
|
||||
printf("%8s", "");
|
||||
|
||||
#if defined(__x86_64__)
|
||||
|
|
@ -482,7 +483,7 @@ void speed(void)
|
|||
}
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
if (raid_cpu_has_ssse3()) {
|
||||
SPEED_START {
|
||||
raid_par5_ssse3(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
|
@ -517,7 +518,7 @@ void speed(void)
|
|||
printf("%8s", "");
|
||||
printf("%8s", "");
|
||||
|
||||
if (cpu_has_sse2()) {
|
||||
if (raid_cpu_has_sse2()) {
|
||||
printf("%8s", "");
|
||||
|
||||
#if defined(__x86_64__)
|
||||
|
|
@ -526,7 +527,7 @@ void speed(void)
|
|||
}
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
if (raid_cpu_has_ssse3()) {
|
||||
SPEED_START {
|
||||
raid_par6_ssse3(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
|
@ -562,7 +563,7 @@ void speed(void)
|
|||
SPEED_START {
|
||||
for(j=0;j<nd;++j) {
|
||||
/* +1 to avoid PAR1 optimized case */
|
||||
raid_rec1_int8(1, id, ip + 1, nd, block_size, buffer, zero);
|
||||
raid_rec1_int8(1, id, ip + 1, nd, block_size, buffer);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -570,11 +571,11 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
if (raid_cpu_has_ssse3()) {
|
||||
SPEED_START {
|
||||
for(j=0;j<nd;++j) {
|
||||
/* +1 to avoid PAR1 optimized case */
|
||||
raid_rec1_ssse3(1, id, ip + 1, nd, block_size, buffer, zero);
|
||||
raid_rec1_ssse3(1, id, ip + 1, nd, block_size, buffer);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -589,8 +590,8 @@ void speed(void)
|
|||
|
||||
SPEED_START {
|
||||
for(j=0;j<nd;++j) {
|
||||
/* +1 to avoid PAR2 optimized case */
|
||||
raid_rec2_int8(2, id, ip + 1, nd, block_size, buffer, zero);
|
||||
/* +1 to avoid PAR1 optimized case */
|
||||
raid_rec2_int8(2, id, ip + 1, nd, block_size, buffer);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -598,11 +599,11 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
if (raid_cpu_has_ssse3()) {
|
||||
SPEED_START {
|
||||
for(j=0;j<nd;++j) {
|
||||
/* +1 to avoid PAR2 optimized case */
|
||||
raid_rec2_ssse3(2, id, ip + 1, nd, block_size, buffer, zero);
|
||||
/* +1 to avoid PAR1 optimized case */
|
||||
raid_rec2_ssse3(2, id, ip + 1, nd, block_size, buffer);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -617,7 +618,7 @@ void speed(void)
|
|||
|
||||
SPEED_START {
|
||||
for(j=0;j<nd;++j) {
|
||||
raid_recX_int8(3, id, ip, nd, block_size, buffer, zero);
|
||||
raid_recX_int8(3, id, ip, nd, block_size, buffer);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -625,10 +626,10 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
if (raid_cpu_has_ssse3()) {
|
||||
SPEED_START {
|
||||
for(j=0;j<nd;++j) {
|
||||
raid_recX_ssse3(3, id, ip, nd, block_size, buffer, zero);
|
||||
raid_recX_ssse3(3, id, ip, nd, block_size, buffer);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -643,7 +644,7 @@ void speed(void)
|
|||
|
||||
SPEED_START {
|
||||
for(j=0;j<nd;++j) {
|
||||
raid_recX_int8(4, id, ip, nd, block_size, buffer, zero);
|
||||
raid_recX_int8(4, id, ip, nd, block_size, buffer);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -651,10 +652,10 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
if (raid_cpu_has_ssse3()) {
|
||||
SPEED_START {
|
||||
for(j=0;j<nd;++j) {
|
||||
raid_recX_ssse3(4, id, ip, nd, block_size, buffer, zero);
|
||||
raid_recX_ssse3(4, id, ip, nd, block_size, buffer);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -669,7 +670,7 @@ void speed(void)
|
|||
|
||||
SPEED_START {
|
||||
for(j=0;j<nd;++j) {
|
||||
raid_recX_int8(5, id, ip, nd, block_size, buffer, zero);
|
||||
raid_recX_int8(5, id, ip, nd, block_size, buffer);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -677,10 +678,10 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
if (raid_cpu_has_ssse3()) {
|
||||
SPEED_START {
|
||||
for(j=0;j<nd;++j) {
|
||||
raid_recX_ssse3(5, id, ip, nd, block_size, buffer, zero);
|
||||
raid_recX_ssse3(5, id, ip, nd, block_size, buffer);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -695,7 +696,7 @@ void speed(void)
|
|||
|
||||
SPEED_START {
|
||||
for(j=0;j<nd;++j) {
|
||||
raid_recX_int8(6, id, ip, nd, block_size, buffer, zero);
|
||||
raid_recX_int8(6, id, ip, nd, block_size, buffer);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -703,10 +704,10 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
if (raid_cpu_has_ssse3()) {
|
||||
SPEED_START {
|
||||
for(j=0;j<nd;++j) {
|
||||
raid_recX_ssse3(6, id, ip, nd, block_size, buffer, zero);
|
||||
raid_recX_ssse3(6, id, ip, nd, block_size, buffer);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
|
|||
8
state.c
8
state.c
|
|
@ -125,8 +125,8 @@ static void state_config_check(struct snapraid_state* state, const char* path, t
|
|||
|
||||
/* check for parity level */
|
||||
if (state->raid_mode == RAID_MODE_VANDERMONDE) {
|
||||
if (state->level > RAID_PARITY_VANDERMONDE_MAX) {
|
||||
fprintf(stderr, "If you use the z-parity you cannot have more than %u parities.\n", RAID_PARITY_VANDERMONDE_MAX);
|
||||
if (state->level > 3) {
|
||||
fprintf(stderr, "If you use the z-parity you cannot have more than 3 parities.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
@ -283,7 +283,7 @@ static void state_config_check(struct snapraid_state* state, const char* path, t
|
|||
|
||||
/* check for speed */
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (!cpu_has_ssse3())
|
||||
if (!raid_cpu_has_ssse3())
|
||||
#endif
|
||||
if (state->raid_mode == RAID_MODE_CAUCHY) {
|
||||
if (state->level == 3) {
|
||||
|
|
@ -704,7 +704,7 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
|
|||
state->besthash = HASH_SPOOKY2;
|
||||
} else {
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (sizeof(void*) == 4 && !cpu_has_slowmult())
|
||||
if (sizeof(void*) == 4 && !raid_cpu_has_slowmult())
|
||||
state->besthash = HASH_MURMUR3;
|
||||
else
|
||||
state->besthash = HASH_SPOOKY2;
|
||||
|
|
|
|||
2
sync.c
2
sync.c
|
|
@ -44,7 +44,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
block_off_t i;
|
||||
unsigned j;
|
||||
void* buffer_alloc;
|
||||
unsigned char** buffer;
|
||||
void** buffer;
|
||||
unsigned buffermax;
|
||||
data_off_t countsize;
|
||||
block_off_t countpos;
|
||||
|
|
|
|||
14
tables.h
14
tables.h
|
|
@ -15,7 +15,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
const unsigned char __attribute__((aligned(256))) gfmul[256][256] =
|
||||
const uint8_t __attribute__((aligned(256))) gfmul[256][256] =
|
||||
{
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
|
@ -8723,7 +8723,7 @@ const unsigned char __attribute__((aligned(256))) gfmul[256][256] =
|
|||
},
|
||||
};
|
||||
|
||||
const unsigned char __attribute__((aligned(256))) gfexp2[256] =
|
||||
const uint8_t __attribute__((aligned(256))) gfexp[256] =
|
||||
{
|
||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
|
||||
0x1d, 0x3a, 0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26,
|
||||
|
|
@ -8759,7 +8759,7 @@ const unsigned char __attribute__((aligned(256))) gfexp2[256] =
|
|||
0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x01,
|
||||
};
|
||||
|
||||
const unsigned char __attribute__((aligned(256))) gfinv[256] =
|
||||
const uint8_t __attribute__((aligned(256))) gfinv[256] =
|
||||
{
|
||||
/* note that the first element is not significative */
|
||||
0x00, 0x01, 0x8e, 0xf4, 0x47, 0xa7, 0x7a, 0xba,
|
||||
|
|
@ -8804,7 +8804,7 @@ const unsigned char __attribute__((aligned(256))) gfinv[256] =
|
|||
* 01 02 04 08 10 20 40 80 1d 3a 74 e8 cd 87 13 26 4c 98 2d 5a b4 75 ea c9 8f 03 06 0c 18 30 60 c0 9d 27 4e 9c 25 4a 94 35 6a d4 b5 77 ee c1 9f 23 46 8c 05 0a 14 28 50 a0 5d ba 69 d2 b9 6f de a1 5f be 61 c2 99 2f 5e bc 65 ca 89 0f 1e 3c 78 f0 fd e7 d3 bb 6b d6 b1 7f fe e1 df a3 5b b6 71 e2 d9 af 43 86 11 22 44 88 0d 1a 34 68 d0 bd 67 ce 81 1f 3e 7c f8 ed c7 93 3b 76 ec c5 97 33 66 cc 85 17 2e 5c b8 6d da a9 4f 9e 21 42 84 15 2a 54 a8 4d 9a 29 52 a4 55 aa 49 92 39 72 e4 d5 b7 73 e6 d1 bf 63 c6 91 3f 7e fc e5 d7 b3 7b f6 f1 ff e3 db ab 4b 96 31 62 c4 95 37 6e dc a5 57 ae 41 82 19 32 64 c8 8d 07 0e 1c 38 70 e0 dd a7 53 a6 51 a2 59 b2 79 f2 f9 ef c3 9b 2b 56 ac 45 8a 09 12 24 48 90 3d 7a f4 f5 f7 f3 fb eb cb 8b 0b 16 2c 58 b0 7d fa e9 cf 83 1b 36 6c
|
||||
* 01 8e 47 ad d8 6c 36 1b 83 cf e9 fa 7d b0 58 2c 16 0b 8b cb eb fb f3 f7 f5 f4 7a 3d 90 48 24 12 09 8a 45 ac 56 2b 9b c3 ef f9 f2 79 b2 59 a2 51 a6 53 a7 dd e0 70 38 1c 0e 07 8d c8 64 32 19 82 41 ae 57 a5 dc 6e 37 95 c4 62 31 96 4b ab db e3 ff f1 f6 7b b3 d7 e5 fc 7e 3f 91 c6 63 bf d1 e6 73 b7 d5 e4 72 39 92 49 aa 55 a4 52 29 9a 4d a8 54 2a 15 84 42 21 9e 4f a9 da 6d b8 5c 2e 17 85 cc 66 33 97 c5 ec 76 3b 93 c7 ed f8 7c 3e 1f 81 ce 67 bd d0 68 34 1a 0d 88 44 22 11 86 43 af d9 e2 71 b6 5b a3 df e1 fe 7f b1 d6 6b bb d3 e7 fd f0 78 3c 1e 0f 89 ca 65 bc 5e 2f 99 c2 61 be 5f a1 de 6f b9 d2 69 ba 5d a0 50 28 14 0a 05 8c 46 23 9f c1 ee 77 b5 d4 6a 35 94 4a 25 9c 4e 27 9d c0 60 30 18 0c 06 03 8f c9 ea 75 b4 5a 2d 98 4c 26 13 87 cd e8 74 3a 1d 80 40 20
|
||||
*/
|
||||
const unsigned char __attribute__((aligned(256))) gfvandermonde[3][256] =
|
||||
const uint8_t __attribute__((aligned(256))) gfvandermonde[3][256] =
|
||||
{
|
||||
{
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
|
|
@ -8921,7 +8921,7 @@ const unsigned char __attribute__((aligned(256))) gfvandermonde[3][256] =
|
|||
* 01 97 7f 9c 7c 18 bd a2 58 1a da 74 70 a3 e5 47 29 07 f5 80 23 e9 fa 46 54 a0 99 95 53 9b 0b c7 09 c0 78 89 92 e3 0d b0 2a 8c fb 17 3f 26 65 87 27 5c 66 61 79 4d 32 b3 8d 52 e2 82 3d f9 c5 02 bc 4c 73 48 62 af ba 41 d9 c4 2f b1 33 b8 15 7d cf 3a a9 5f 84 6d 34 1b 44 94 72 81 42 be cc 4b 0a 6f 5a 22 36 b5 3c 9d 13 7e 08 dd d6 5e 04 fc 5b ec ef f1 6e 1e 77 24 e6 c6 aa cb fd 51 67 06 6a 4a 88 db b2 c2 5d 43 40 f7 50 a8 f2 7a 71 a4 d2 bf 31 90 19 9a 8e f6 c3 a6 e7 60 12 ee 2d de 38 e8 b7 98 c1 28 f3 05 96 63 d1 b9 14 9f 1d 83 68 75 ed 16 03 ce e4 df e0 10 ae 69 55 91 2e 4e fe 21 1f 9e e1 d5 cd ca f0 8b 2b c9 8a 93 bb 57 20 86 1c a1 4f 3e 25 d4 6c a5 6b a7 37 ff 39 35 0c f8 ea 56 45 8f 2c 59 ab 85 eb 49 0f dc d8 76 b6 f4 0e 11 b4 d0 30 d3 3b ad d7
|
||||
* 01 2b 3f cf 73 2c d6 ed cb 74 15 78 8a c1 17 c9 89 68 21 ab 76 3b 4b 5a 6e 0e b9 d3 b6 3e 36 86 bf a2 a7 30 14 eb c7 2d 96 67 20 b5 9a e0 a8 c6 80 04 8d fe 75 5e 23 ca 8f 48 99 0d df 8e b8 70 29 9c 44 69 3d a5 c2 90 d2 1c 9b 02 1d 98 93 ec 84 e8 64 4c 3a 8b 97 f3 e5 c0 7d 26 c8 08 a0 62 82 55 f7 33 f6 51 63 4d 77 da fd c3 38 6d ee 09 47 a3 05 de a6 f1 22 25 6a 0c 81 b2 6b 58 d5 b3 fc fb 28 7f 07 dc 7a 9e d0 37 b4 e1 1a 24 03 ae 94 ba 88 2f ea 2e 8c 5b bb 79 d1 11 ff a4 19 3c 2a 4e 52 e3 95 bd 31 5d 35 4a 41 c4 db 42 c5 0b 49 1b 7c e4 b0 9d 45 f0 a9 61 57 06 d4 40 91 56 13 fa 87 ac 27 54 dd 59 1f 71 39 43 6c f9 be 4f f4 1e 32 cd e9 7e 7b 66 5f ef e7 6f 0a 60 d7 b7 83 92 e2 af 72 f8 b1 50 10 ce 18 53 a1 cc ad 12 34 0f f5 aa 16 e6 f2 d8 85 9f bc
|
||||
*/
|
||||
const unsigned char __attribute__((aligned(256))) gfcauchy[6][256] =
|
||||
const uint8_t __attribute__((aligned(256))) gfcauchy[6][256] =
|
||||
{
|
||||
{
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
|
|
@ -9136,7 +9136,7 @@ const unsigned char __attribute__((aligned(256))) gfcauchy[6][256] =
|
|||
* Indexes are [DISK][PARITY - 2][LH].
|
||||
* Where DISK is from 0 to 250, PARITY from 2 to 5, LH from 0 to 1.
|
||||
*/
|
||||
const unsigned char __attribute__((aligned(256))) gfgenpshufb[251][4][2][16] =
|
||||
const uint8_t __attribute__((aligned(256))) gfcauchypshufb[251][4][2][16] =
|
||||
{
|
||||
{
|
||||
{
|
||||
|
|
@ -13666,7 +13666,7 @@ const unsigned char __attribute__((aligned(256))) gfgenpshufb[251][4][2][16] =
|
|||
* Indexes are [MULTIPLER][LH].
|
||||
* Where MULTIPLER is from 0 to 255, LH from 0 to 1.
|
||||
*/
|
||||
const unsigned char __attribute__((aligned(256))) gfmulpshufb[256][2][16] =
|
||||
const uint8_t __attribute__((aligned(256))) gfmulpshufb[256][2][16] =
|
||||
{
|
||||
{
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
|
||||
|
|
|
|||
31
util.c
31
util.c
|
|
@ -1133,7 +1133,7 @@ void crc32c_init(void)
|
|||
{
|
||||
crc32c = crc32c_gen;
|
||||
#if HAVE_CRC32B
|
||||
if (cpu_has_sse42()) {
|
||||
if (raid_cpu_has_sse42()) {
|
||||
crc32c = crc32c_x86;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1391,9 +1391,9 @@ void* malloc_nofail_align(size_t size, void** freeptr)
|
|||
*/
|
||||
#define MALLOC_DISPLACEMENT (7*256)
|
||||
|
||||
unsigned char** malloc_nofail_vector_align(size_t reverse, size_t count, size_t size, void** freeptr)
|
||||
void** malloc_nofail_vector_align(size_t reverse, size_t count, size_t size, void** freeptr)
|
||||
{
|
||||
unsigned char** buffer;
|
||||
void** buffer;
|
||||
unsigned char* buffer_aligned;
|
||||
size_t i;
|
||||
|
||||
|
|
@ -1416,8 +1416,9 @@ unsigned char** malloc_nofail_vector_align(size_t reverse, size_t count, size_t
|
|||
return buffer;
|
||||
}
|
||||
|
||||
void mtest_vector(unsigned char** buf, size_t count, size_t size)
|
||||
void mtest_vector(void** vv, size_t count, size_t size)
|
||||
{
|
||||
unsigned char** v = (unsigned char**)vv;
|
||||
size_t i;
|
||||
size_t j;
|
||||
unsigned k;
|
||||
|
|
@ -1428,7 +1429,7 @@ void mtest_vector(unsigned char** buf, size_t count, size_t size)
|
|||
d = 0;
|
||||
for(i=0;i<count;++i) {
|
||||
for(j=0;j<size;++j) {
|
||||
buf[i][j] = d;
|
||||
v[i][j] = d;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1440,9 +1441,9 @@ void mtest_vector(unsigned char** buf, size_t count, size_t size)
|
|||
/* forward fill */
|
||||
for(i=0;i<count;++i) {
|
||||
for(j=0;j<size;++j) {
|
||||
if (buf[i][j] != p)
|
||||
if (v[i][j] != p)
|
||||
goto fail;
|
||||
buf[i][j] = d;
|
||||
v[i][j] = d;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1451,9 +1452,9 @@ void mtest_vector(unsigned char** buf, size_t count, size_t size)
|
|||
/* backward fill with complement */
|
||||
for(i=0;i<count;++i) {
|
||||
for(j=size;j>0;--j) {
|
||||
if (buf[i][j-1] != p)
|
||||
if (v[i][j-1] != p)
|
||||
goto fail;
|
||||
buf[i][j-1] = d;
|
||||
v[i][j-1] = d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1466,6 +1467,18 @@ fail:
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
void mrand_vector(void** vv, size_t count, size_t size)
|
||||
{
|
||||
unsigned char** v = (unsigned char**)vv;
|
||||
size_t i;
|
||||
size_t j;
|
||||
|
||||
for(i=0;i<count;++i) {
|
||||
for(j=0;j<size;++j)
|
||||
v[i][j] = rand();
|
||||
}
|
||||
}
|
||||
|
||||
char* strdup_nofail(const char* str)
|
||||
{
|
||||
size_t size;
|
||||
|
|
|
|||
11
util.h
11
util.h
|
|
@ -470,13 +470,18 @@ void* malloc_nofail_align(size_t size, void** freeptr);
|
|||
* The first "reverse" pointers are put in reverse memory offset order.
|
||||
* If no memory is available, it aborts.
|
||||
*/
|
||||
unsigned char** malloc_nofail_vector_align(size_t reverse, size_t count, size_t size, void** freeptr);
|
||||
void** malloc_nofail_vector_align(size_t reverse, size_t count, size_t size, void** freeptr);
|
||||
|
||||
/**
|
||||
* Test the memory vector for RAM problems.
|
||||
* Tests the memory vector for RAM problems.
|
||||
* If a problem is found, it crashes.
|
||||
*/
|
||||
void mtest_vector(unsigned char** buf, size_t count, size_t size);
|
||||
void mtest_vector(void** vv, size_t count, size_t size);
|
||||
|
||||
/**
|
||||
* Fills the memory vector with random data.
|
||||
*/
|
||||
void mrand_vector(void** vv, size_t count, size_t size);
|
||||
|
||||
/**
|
||||
* Safe strdup.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue