mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Renames some variables. No functional change.
This commit is contained in:
parent
9fa97f04fd
commit
b81e4a0141
5 changed files with 412 additions and 412 deletions
36
check.c
36
check.c
|
|
@ -147,8 +147,8 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
|
|||
unsigned i, n;
|
||||
int error;
|
||||
int has_hash;
|
||||
int d[LEV_MAX];
|
||||
int p[LEV_MAX];
|
||||
int id[LEV_MAX];
|
||||
int ip[LEV_MAX];
|
||||
|
||||
/* no fix required */
|
||||
if (failed_count == 0) {
|
||||
|
|
@ -167,7 +167,7 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
|
|||
|
||||
/* setup vector of failed disk indexes */
|
||||
for(i=0;i<failed_count;++i)
|
||||
d[i] = failed[failed_map[i]].index;
|
||||
id[i] = failed[failed_map[i]].index;
|
||||
|
||||
/* check if there is at least a failed block that can be checked for correctness using the hash */
|
||||
/* if there isn't, we have to sacrifice a parity block to check that the result is correct */
|
||||
|
|
@ -184,11 +184,11 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
|
|||
unsigned r = failed_count + 1;
|
||||
|
||||
/* all combinations (r of n) parities */
|
||||
combination_first(r, n, p);
|
||||
combination_first(r, n, ip);
|
||||
do {
|
||||
/* if a parity is missing, do nothing */
|
||||
for(i=0;i<r;++i) {
|
||||
if (buffer_recov[p[i]] == 0)
|
||||
if (buffer_recov[ip[i]] == 0)
|
||||
break;
|
||||
}
|
||||
if (i != r)
|
||||
|
|
@ -196,13 +196,13 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
|
|||
|
||||
/* copy the parities to use, one less because the last is used for checking */
|
||||
for(i=0;i<r-1;++i)
|
||||
memcpy(buffer[diskmax+p[i]], buffer_recov[p[i]], state->block_size);
|
||||
memcpy(buffer[diskmax+ip[i]], buffer_recov[ip[i]], state->block_size);
|
||||
|
||||
/* recover using one less parity, the p[r-1] one */
|
||||
raid_rec(r-1, d, p, diskmax, state->block_size, buffer, buffer_zero);
|
||||
/* recover using one less parity, the ip[r-1] one */
|
||||
raid_rec(r-1, id, ip, diskmax, state->block_size, buffer, buffer_zero);
|
||||
|
||||
/* use the remaining p[r-1] parity to check the result */
|
||||
if (is_parity_matching(state, diskmax, p[r-1], buffer, buffer_recov))
|
||||
/* use the remaining ip[r-1] parity to check the result */
|
||||
if (is_parity_matching(state, diskmax, ip[r-1], buffer, buffer_recov))
|
||||
return 0;
|
||||
|
||||
/* log */
|
||||
|
|
@ -210,11 +210,11 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
|
|||
for(i=0;i<r;++i) {
|
||||
if (i != 0)
|
||||
fprintf(stdlog, "/");
|
||||
fprintf(stdlog, "%s", lev_config_name(p[i]));
|
||||
fprintf(stdlog, "%s", lev_config_name(ip[i]));
|
||||
}
|
||||
fprintf(stdlog, ": Data error\n");
|
||||
++error;
|
||||
} while (combination_next(r, n, p));
|
||||
} while (combination_next(r, n, ip));
|
||||
}
|
||||
|
||||
/* if we have a hash, and enough parities */
|
||||
|
|
@ -224,11 +224,11 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
|
|||
unsigned r = failed_count;
|
||||
|
||||
/* all combinations (r of n) parities */
|
||||
combination_first(r, n, p);
|
||||
combination_first(r, n, ip);
|
||||
do {
|
||||
/* if a parity is missing, do nothing */
|
||||
for(i=0;i<r;++i) {
|
||||
if (buffer_recov[p[i]] == 0)
|
||||
if (buffer_recov[ip[i]] == 0)
|
||||
break;
|
||||
}
|
||||
if (i != r)
|
||||
|
|
@ -236,10 +236,10 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
|
|||
|
||||
/* copy the parities to use */
|
||||
for(i=0;i<r;++i)
|
||||
memcpy(buffer[diskmax+p[i]], buffer_recov[p[i]], state->block_size);
|
||||
memcpy(buffer[diskmax+ip[i]], buffer_recov[ip[i]], state->block_size);
|
||||
|
||||
/* recover */
|
||||
raid_rec(r, d, p, diskmax, state->block_size, buffer, buffer_zero);
|
||||
raid_rec(r, id, ip, diskmax, state->block_size, buffer, buffer_zero);
|
||||
|
||||
/* use the hash to check the result */
|
||||
if (is_hash_matching(state, rehash, diskmax, failed, failed_map, failed_count, buffer, buffer_zero))
|
||||
|
|
@ -250,11 +250,11 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
|
|||
for(i=0;i<r;++i) {
|
||||
if (i != 0)
|
||||
fprintf(stdlog, "/");
|
||||
fprintf(stdlog, "%s", lev_config_name(p[i]));
|
||||
fprintf(stdlog, "%s", lev_config_name(ip[i]));
|
||||
}
|
||||
fprintf(stdlog, ": Data error\n");
|
||||
++error;
|
||||
} while (combination_next(r, n, p));
|
||||
} while (combination_next(r, n, ip));
|
||||
}
|
||||
|
||||
/* return the number of failed attempts, or -1 if no strategy */
|
||||
|
|
|
|||
78
raid.h
78
raid.h
|
|
@ -73,28 +73,28 @@ void raid_set(unsigned mode);
|
|||
/**
|
||||
* Computes the parity.
|
||||
*
|
||||
* \param npar Number of parities to compute.
|
||||
* \param ndata Number of data disks.
|
||||
* \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 (::ndata + ::npar) elements. Each element points to a buffer of ::size bytes.
|
||||
* It has (::nd + ::np) elements. Each element points to a buffer of ::size bytes.
|
||||
*/
|
||||
void raid_par(unsigned npar, unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_par(unsigned np, unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
|
||||
/**
|
||||
* Recovers failures of data disks using the specified parities.
|
||||
*
|
||||
* Note that only the data blocks are recovered. The parity is destroyed.
|
||||
* \param nrec Number of failed disks to recover.
|
||||
* \param d[] Vector of indexes of the data disks to recover. Starting from 0.
|
||||
* \param c[] Vector of indexes of the checksum/parity to use for the recovering. Starting from 0.
|
||||
* \param ndata Number of data disks.
|
||||
* \param nr Number of failed 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 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 (::ndata + max(::c[] + 1)) elements. Each element points to a buffer of ::size bytes.
|
||||
* 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.
|
||||
*/
|
||||
void raid_rec(unsigned nrec, const int* d, const int* c, unsigned ndata, unsigned size, unsigned char** vbuf, unsigned char* zero);
|
||||
void raid_rec(unsigned nr, const int* id, const int* ip, unsigned nd, unsigned size, unsigned char** vbuf, unsigned char* zero);
|
||||
|
||||
/**
|
||||
* Gets the name of the selected function to compute the parity.
|
||||
|
|
@ -115,34 +115,34 @@ const char* raid_recX_tag(void);
|
|||
* Specialized parity computation.
|
||||
* Only for testing.
|
||||
*/
|
||||
void raid_par1_int32(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_par1_int64(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_par1_sse2(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_par2_int32(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_par2_int64(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_par2_sse2(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_par2_sse2ext(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_parz_int32(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_parz_int64(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_parz_sse2(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_parz_sse2ext(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_par3_int8(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_par3_ssse3(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_par3_ssse3ext(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_par4_int8(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_par4_ssse3(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_par4_ssse3ext(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_par5_int8(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_par5_ssse3(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_par5_ssse3ext(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_par6_int8(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_par6_ssse3(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_par6_ssse3ext(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void raid_rec1_int8(unsigned nrec, const int* d, const int* c, unsigned ndata, unsigned size, unsigned char** vbuf, unsigned char* zero);
|
||||
void raid_rec2_int8(unsigned nrec, const int* d, const int* c, unsigned ndata, unsigned size, unsigned char** vbuf, unsigned char* zero);
|
||||
void raid_recX_int8(unsigned nrec, const int* d, const int* c, unsigned ndata, unsigned size, unsigned char** vbuf, unsigned char* zero);
|
||||
void raid_rec1_ssse3(unsigned nrec, const int* d, const int* c, unsigned ndata, unsigned size, unsigned char** vbuf, unsigned char* zero);
|
||||
void raid_rec2_ssse3(unsigned nrec, const int* d, const int* c, unsigned ndata, unsigned size, unsigned char** vbuf, unsigned char* zero);
|
||||
void raid_recX_ssse3(unsigned nrec, const int* d, const int* c, unsigned ndata, unsigned size, unsigned char** vbuf, unsigned char* zero);
|
||||
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);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
96
selftest.c
96
selftest.c
|
|
@ -80,7 +80,7 @@ static void combotest(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void recovtest(unsigned mode, unsigned ndata, unsigned block_size)
|
||||
static void recovtest(unsigned mode, unsigned nd, unsigned block_size)
|
||||
{
|
||||
void* buffer_alloc;
|
||||
unsigned char** buffer;
|
||||
|
|
@ -92,31 +92,31 @@ static void recovtest(unsigned mode, unsigned ndata, unsigned block_size)
|
|||
unsigned char* zero;
|
||||
unsigned char* waste;
|
||||
unsigned buffermax;
|
||||
int d[LEV_MAX];
|
||||
int c[LEV_MAX];
|
||||
int id[LEV_MAX];
|
||||
int ip[LEV_MAX];
|
||||
unsigned i;
|
||||
unsigned j;
|
||||
unsigned nrec;
|
||||
void (*map[LEV_MAX][4])(unsigned nrec, const int* d, const int* c, unsigned ndata, unsigned size, unsigned char** vbuf, unsigned char* zero);
|
||||
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);
|
||||
unsigned mac[LEV_MAX];
|
||||
unsigned npar;
|
||||
unsigned np;
|
||||
|
||||
raid_set(mode);
|
||||
if (mode == RAID_MODE_CAUCHY)
|
||||
npar = RAID_PARITY_CAUCHY_MAX;
|
||||
np = RAID_PARITY_CAUCHY_MAX;
|
||||
else
|
||||
npar = RAID_PARITY_VANDERMONDE_MAX;
|
||||
np = RAID_PARITY_VANDERMONDE_MAX;
|
||||
|
||||
buffermax = ndata + npar * 2 + 2;
|
||||
buffermax = nd + np * 2 + 2;
|
||||
|
||||
buffer = malloc_nofail_vector_align(ndata, buffermax, block_size, &buffer_alloc);
|
||||
buffer = malloc_nofail_vector_align(nd, buffermax, block_size, &buffer_alloc);
|
||||
mtest_vector(buffer, buffermax, block_size);
|
||||
|
||||
data = buffer;
|
||||
parity = buffer + ndata;
|
||||
test = buffer + ndata + npar;
|
||||
parity = buffer + nd;
|
||||
test = buffer + nd + np;
|
||||
|
||||
for(i=0;i<npar;++i)
|
||||
for(i=0;i<np;++i)
|
||||
parity_save[i] = parity[i];
|
||||
|
||||
zero = buffer[buffermax-2];
|
||||
|
|
@ -125,13 +125,13 @@ static void recovtest(unsigned mode, unsigned ndata, unsigned block_size)
|
|||
waste = buffer[buffermax-1];
|
||||
|
||||
/* fill data disk with random */
|
||||
for(i=0;i<ndata;++i) {
|
||||
for(i=0;i<nd;++i) {
|
||||
for(j=0;j<block_size;++j)
|
||||
data[i][j] = rand();
|
||||
}
|
||||
|
||||
/* setup recov functions */
|
||||
for(i=0;i<npar;++i) {
|
||||
for(i=0;i<np;++i) {
|
||||
mac[i] = 0;
|
||||
if (i == 0) {
|
||||
map[i][mac[i]++] = raid_rec1_int8;
|
||||
|
|
@ -158,36 +158,36 @@ static void recovtest(unsigned mode, unsigned ndata, unsigned block_size)
|
|||
}
|
||||
|
||||
/* compute the parity */
|
||||
raid_par(npar, ndata, block_size, buffer);
|
||||
raid_par(np, nd, block_size, buffer);
|
||||
|
||||
/* set all the parity to the waste buffer */
|
||||
for(i=0;i<npar;++i)
|
||||
for(i=0;i<np;++i)
|
||||
parity[i] = waste;
|
||||
|
||||
/* all parity levels */
|
||||
for(nrec=1;nrec<=npar;++nrec) {
|
||||
/* all combinations (nrec of ndata) disks */
|
||||
combination_first(nrec, ndata, d);
|
||||
for(nr=1;nr<=np;++nr) {
|
||||
/* all combinations (nr of nd) disks */
|
||||
combination_first(nr, nd, id);
|
||||
do {
|
||||
/* all combinations (nrec of npar) parities */
|
||||
combination_first(nrec, npar, c);
|
||||
/* all combinations (nr of np) parities */
|
||||
combination_first(nr, np, ip);
|
||||
do {
|
||||
/* for each recover function */
|
||||
for(j=0;j<mac[nrec-1];++j) {
|
||||
for(j=0;j<mac[nr-1];++j) {
|
||||
/* set */
|
||||
for(i=0;i<nrec;++i) {
|
||||
for(i=0;i<nr;++i) {
|
||||
/* remove the missing data */
|
||||
data_save[i] = data[d[i]];
|
||||
data[d[i]] = test[i];
|
||||
data_save[i] = data[id[i]];
|
||||
data[id[i]] = test[i];
|
||||
/* set the parity to use */
|
||||
parity[c[i]] = parity_save[c[i]];
|
||||
parity[ip[i]] = parity_save[ip[i]];
|
||||
}
|
||||
|
||||
/* recover */
|
||||
map[nrec-1][0](nrec, d, c, ndata, block_size, buffer, zero);
|
||||
map[nr-1][0](nr, id, ip, nd, block_size, buffer, zero);
|
||||
|
||||
/* check */
|
||||
for(i=0;i<nrec;++i) {
|
||||
for(i=0;i<nr;++i) {
|
||||
if (memcmp(test[i], data_save[i], block_size) != 0) {
|
||||
fprintf(stderr, "Failed RECOV test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
@ -195,54 +195,54 @@ static void recovtest(unsigned mode, unsigned ndata, unsigned block_size)
|
|||
}
|
||||
|
||||
/* restore */
|
||||
for(i=0;i<nrec;++i) {
|
||||
for(i=0;i<nr;++i) {
|
||||
/* restore the data */
|
||||
data[d[i]] = data_save[i];
|
||||
data[id[i]] = data_save[i];
|
||||
/* restore the parity */
|
||||
parity[c[i]] = waste;
|
||||
parity[ip[i]] = waste;
|
||||
}
|
||||
}
|
||||
} while (combination_next(nrec, npar, c));
|
||||
} while (combination_next(nrec, ndata, d));
|
||||
} while (combination_next(nr, np, ip));
|
||||
} while (combination_next(nr, nd, id));
|
||||
}
|
||||
|
||||
free(buffer_alloc);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
static void gentest(unsigned mode, unsigned ndata, unsigned block_size)
|
||||
static void gentest(unsigned mode, unsigned nd, unsigned block_size)
|
||||
{
|
||||
void* buffer_alloc;
|
||||
unsigned char** buffer;
|
||||
unsigned buffermax;
|
||||
unsigned i, j;
|
||||
void (*map[64])(unsigned ndata, unsigned size, unsigned char** vbuf);
|
||||
void (*map[64])(unsigned nd, unsigned size, unsigned char** vbuf);
|
||||
unsigned mac;
|
||||
unsigned npar;
|
||||
unsigned np;
|
||||
|
||||
raid_set(mode);
|
||||
if (mode == RAID_MODE_CAUCHY)
|
||||
npar = RAID_PARITY_CAUCHY_MAX;
|
||||
np = RAID_PARITY_CAUCHY_MAX;
|
||||
else
|
||||
npar = RAID_PARITY_VANDERMONDE_MAX;
|
||||
np = RAID_PARITY_VANDERMONDE_MAX;
|
||||
|
||||
buffermax = ndata + npar * 2;
|
||||
buffermax = nd + np * 2;
|
||||
|
||||
buffer = malloc_nofail_vector_align(ndata, buffermax, block_size, &buffer_alloc);
|
||||
buffer = malloc_nofail_vector_align(nd, buffermax, block_size, &buffer_alloc);
|
||||
mtest_vector(buffer, buffermax, block_size);
|
||||
|
||||
/* fill with random */
|
||||
for(i=0;i<ndata;++i) {
|
||||
for(i=0;i<nd;++i) {
|
||||
for(j=0;j<block_size;++j)
|
||||
buffer[i][j] = rand();
|
||||
}
|
||||
|
||||
/* compute the parity */
|
||||
raid_par(npar, ndata, block_size, buffer);
|
||||
raid_par(np, nd, block_size, buffer);
|
||||
|
||||
/* copy in back buffers */
|
||||
for(i=0;i<npar;++i)
|
||||
memcpy(buffer[ndata + npar + i], buffer[ndata + i], block_size);
|
||||
for(i=0;i<np;++i)
|
||||
memcpy(buffer[nd + np + i], buffer[nd + i], block_size);
|
||||
|
||||
/* load all the available functions */
|
||||
mac = 0;
|
||||
|
|
@ -296,11 +296,11 @@ static void gentest(unsigned mode, unsigned ndata, unsigned block_size)
|
|||
/* check all the functions */
|
||||
for(j=0;j<mac;++j) {
|
||||
/* compute parity */
|
||||
map[j](ndata, block_size, buffer);
|
||||
map[j](nd, block_size, buffer);
|
||||
|
||||
/* check it */
|
||||
for(i=0;i<npar;++i) {
|
||||
if (memcmp(buffer[ndata + npar + i], buffer[ndata + i], block_size) != 0) {
|
||||
for(i=0;i<np;++i) {
|
||||
if (memcmp(buffer[nd + np + i], buffer[nd + i], block_size) != 0) {
|
||||
fprintf(stderr, "Failed GEN test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
|
|||
126
speed.c
126
speed.c
|
|
@ -47,7 +47,7 @@ static int64_t diffgettimeofday(struct timeval* start, struct timeval* stop)
|
|||
count += delta; \
|
||||
gettimeofday(&stop, 0); \
|
||||
} while (diffgettimeofday(&start, &stop) < 1000000LL); \
|
||||
ds = block_size * (int64_t)count * ndata; \
|
||||
ds = block_size * (int64_t)count * nd; \
|
||||
dt = diffgettimeofday(&start, &stop);
|
||||
|
||||
void speed(void)
|
||||
|
|
@ -59,30 +59,30 @@ void speed(void)
|
|||
unsigned i, j;
|
||||
unsigned char digest[HASH_SIZE];
|
||||
unsigned char seed[HASH_SIZE];
|
||||
int d[LEV_MAX];
|
||||
int c[LEV_MAX];
|
||||
int id[LEV_MAX];
|
||||
int ip[LEV_MAX];
|
||||
unsigned count;
|
||||
unsigned delta = 10;
|
||||
unsigned block_size = 256 * 1024;
|
||||
unsigned ndata = 8;
|
||||
unsigned nd = 8;
|
||||
unsigned buffermax;
|
||||
void* buffer_alloc;
|
||||
unsigned char** buffer;
|
||||
unsigned char* zero;
|
||||
|
||||
/* we need disk + 1 for each parity buffers + 1 zero buffer */
|
||||
buffermax = ndata + LEV_MAX + 1;
|
||||
buffermax = nd + LEV_MAX + 1;
|
||||
|
||||
buffer = malloc_nofail_vector_align(ndata, buffermax, block_size, &buffer_alloc);
|
||||
buffer = malloc_nofail_vector_align(nd, buffermax, block_size, &buffer_alloc);
|
||||
mtest_vector(buffer, buffermax, block_size);
|
||||
|
||||
/* initialize disks with fixed data */
|
||||
for(i=0;i<ndata;++i) {
|
||||
for(i=0;i<nd;++i) {
|
||||
memset(buffer[i], i, block_size);
|
||||
}
|
||||
|
||||
/* zero buffer */
|
||||
zero = buffer[ndata+LEV_MAX];
|
||||
zero = buffer[nd+LEV_MAX];
|
||||
memset(zero, 0, block_size);
|
||||
|
||||
/* hash seed */
|
||||
|
|
@ -92,8 +92,8 @@ void speed(void)
|
|||
|
||||
/* basic disks and parity mapping */
|
||||
for(i=0;i<LEV_MAX;++i) {
|
||||
d[i] = i;
|
||||
c[i] = i;
|
||||
id[i] = i;
|
||||
ip[i] = i;
|
||||
}
|
||||
|
||||
printf(PACKAGE " v" VERSION " by Andrea Mazzoleni, " PACKAGE_URL "\n");
|
||||
|
|
@ -142,7 +142,7 @@ void speed(void)
|
|||
|
||||
printf("\n");
|
||||
|
||||
printf("Speed test using %u buffers of %u bytes, for a total of %u KiB.\n", ndata, block_size, ndata * block_size / 1024);
|
||||
printf("Speed test using %u buffers of %u bytes, for a total of %u KiB.\n", nd, block_size, nd * block_size / 1024);
|
||||
printf("The reported value is the sustainable aggregate bandwidth of all data disks in MiB/s (not counting parity disks).\n");
|
||||
printf("\n");
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
SPEED_START {
|
||||
for(j=0;j<ndata;++j) {
|
||||
for(j=0;j<nd;++j) {
|
||||
memset(buffer[j], j, block_size);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
|
@ -167,7 +167,7 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
SPEED_START {
|
||||
for(j=0;j<ndata;++j) {
|
||||
for(j=0;j<nd;++j) {
|
||||
crc32c_gen(0, buffer[j], block_size);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
|
@ -181,7 +181,7 @@ void speed(void)
|
|||
#if HAVE_CRC32B
|
||||
if (cpu_has_sse42()) {
|
||||
SPEED_START {
|
||||
for(j=0;j<ndata;++j) {
|
||||
for(j=0;j<nd;++j) {
|
||||
crc32c_x86(0, buffer[j], block_size);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
|
@ -216,7 +216,7 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
SPEED_START {
|
||||
for(j=0;j<ndata;++j) {
|
||||
for(j=0;j<nd;++j) {
|
||||
memhash(HASH_MURMUR3, seed, digest, buffer[j], block_size);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
|
@ -225,7 +225,7 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
SPEED_START {
|
||||
for(j=0;j<ndata;++j) {
|
||||
for(j=0;j<nd;++j) {
|
||||
memhash(HASH_SPOOKY2, seed, digest, buffer[j], block_size);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
|
@ -261,14 +261,14 @@ void speed(void)
|
|||
printf("%8s", "");
|
||||
|
||||
SPEED_START {
|
||||
raid_par1_int32(ndata, block_size, buffer);
|
||||
raid_par1_int32(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
fflush(stdout);
|
||||
|
||||
SPEED_START {
|
||||
raid_par1_int64(ndata, block_size, buffer);
|
||||
raid_par1_int64(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
|
|
@ -277,7 +277,7 @@ void speed(void)
|
|||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_sse2()) {
|
||||
SPEED_START {
|
||||
raid_par1_sse2(ndata, block_size, buffer);
|
||||
raid_par1_sse2(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
|
|
@ -294,14 +294,14 @@ void speed(void)
|
|||
printf("%8s", "");
|
||||
|
||||
SPEED_START {
|
||||
raid_par2_int32(ndata, block_size, buffer);
|
||||
raid_par2_int32(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
fflush(stdout);
|
||||
|
||||
SPEED_START {
|
||||
raid_par2_int64(ndata, block_size, buffer);
|
||||
raid_par2_int64(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
|
|
@ -310,7 +310,7 @@ void speed(void)
|
|||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_sse2()) {
|
||||
SPEED_START {
|
||||
raid_par2_sse2(ndata, block_size, buffer);
|
||||
raid_par2_sse2(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
|
|
@ -318,7 +318,7 @@ void speed(void)
|
|||
|
||||
#if defined(__x86_64__)
|
||||
SPEED_START {
|
||||
raid_par2_sse2ext(ndata, block_size, buffer);
|
||||
raid_par2_sse2ext(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
|
|
@ -336,14 +336,14 @@ void speed(void)
|
|||
printf("%8s", "");
|
||||
|
||||
SPEED_START {
|
||||
raid_parz_int32(ndata, block_size, buffer);
|
||||
raid_parz_int32(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
fflush(stdout);
|
||||
|
||||
SPEED_START {
|
||||
raid_parz_int64(ndata, block_size, buffer);
|
||||
raid_parz_int64(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
|
|
@ -352,7 +352,7 @@ void speed(void)
|
|||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_sse2()) {
|
||||
SPEED_START {
|
||||
raid_parz_sse2(ndata, block_size, buffer);
|
||||
raid_parz_sse2(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
|
|
@ -360,7 +360,7 @@ void speed(void)
|
|||
|
||||
#if defined(__x86_64__)
|
||||
SPEED_START {
|
||||
raid_parz_sse2ext(ndata, block_size, buffer);
|
||||
raid_parz_sse2ext(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
|
|
@ -376,7 +376,7 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
SPEED_START {
|
||||
raid_par3_int8(ndata, block_size, buffer);
|
||||
raid_par3_int8(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
|
|
@ -396,7 +396,7 @@ void speed(void)
|
|||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
SPEED_START {
|
||||
raid_par3_ssse3(ndata, block_size, buffer);
|
||||
raid_par3_ssse3(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
|
|
@ -404,7 +404,7 @@ void speed(void)
|
|||
|
||||
#if defined(__x86_64__)
|
||||
SPEED_START {
|
||||
raid_par3_ssse3ext(ndata, block_size, buffer);
|
||||
raid_par3_ssse3ext(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
|
|
@ -420,7 +420,7 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
SPEED_START {
|
||||
raid_par4_int8(ndata, block_size, buffer);
|
||||
raid_par4_int8(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
|
|
@ -440,7 +440,7 @@ void speed(void)
|
|||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
SPEED_START {
|
||||
raid_par4_ssse3(ndata, block_size, buffer);
|
||||
raid_par4_ssse3(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
|
|
@ -448,7 +448,7 @@ void speed(void)
|
|||
|
||||
#if defined(__x86_64__)
|
||||
SPEED_START {
|
||||
raid_par4_ssse3ext(ndata, block_size, buffer);
|
||||
raid_par4_ssse3ext(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
|
|
@ -464,7 +464,7 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
SPEED_START {
|
||||
raid_par5_int8(ndata, block_size, buffer);
|
||||
raid_par5_int8(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
|
|
@ -484,7 +484,7 @@ void speed(void)
|
|||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
SPEED_START {
|
||||
raid_par5_ssse3(ndata, block_size, buffer);
|
||||
raid_par5_ssse3(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
|
|
@ -492,7 +492,7 @@ void speed(void)
|
|||
|
||||
#if defined(__x86_64__)
|
||||
SPEED_START {
|
||||
raid_par5_ssse3ext(ndata, block_size, buffer);
|
||||
raid_par5_ssse3ext(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
|
|
@ -508,7 +508,7 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
SPEED_START {
|
||||
raid_par6_int8(ndata, block_size, buffer);
|
||||
raid_par6_int8(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
|
|
@ -528,7 +528,7 @@ void speed(void)
|
|||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
SPEED_START {
|
||||
raid_par6_ssse3(ndata, block_size, buffer);
|
||||
raid_par6_ssse3(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
|
|
@ -536,7 +536,7 @@ void speed(void)
|
|||
|
||||
#if defined(__x86_64__)
|
||||
SPEED_START {
|
||||
raid_par6_ssse3ext(ndata, block_size, buffer);
|
||||
raid_par6_ssse3ext(nd, block_size, buffer);
|
||||
} SPEED_STOP
|
||||
|
||||
printf("%8"PRIu64, ds / dt);
|
||||
|
|
@ -560,9 +560,9 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
SPEED_START {
|
||||
for(j=0;j<ndata;++j) {
|
||||
for(j=0;j<nd;++j) {
|
||||
/* +1 to avoid PAR1 optimized case */
|
||||
raid_rec1_int8(1, d, c + 1, ndata, block_size, buffer, zero);
|
||||
raid_rec1_int8(1, id, ip + 1, nd, block_size, buffer, zero);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -572,9 +572,9 @@ void speed(void)
|
|||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
SPEED_START {
|
||||
for(j=0;j<ndata;++j) {
|
||||
for(j=0;j<nd;++j) {
|
||||
/* +1 to avoid PAR1 optimized case */
|
||||
raid_rec1_ssse3(1, d, c + 1, ndata, block_size, buffer, zero);
|
||||
raid_rec1_ssse3(1, id, ip + 1, nd, block_size, buffer, zero);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -588,9 +588,9 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
SPEED_START {
|
||||
for(j=0;j<ndata;++j) {
|
||||
for(j=0;j<nd;++j) {
|
||||
/* +1 to avoid PAR2 optimized case */
|
||||
raid_rec2_int8(2, d, c + 1, ndata, block_size, buffer, zero);
|
||||
raid_rec2_int8(2, id, ip + 1, nd, block_size, buffer, zero);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -600,9 +600,9 @@ void speed(void)
|
|||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
SPEED_START {
|
||||
for(j=0;j<ndata;++j) {
|
||||
for(j=0;j<nd;++j) {
|
||||
/* +1 to avoid PAR2 optimized case */
|
||||
raid_rec2_ssse3(2, d, c + 1, ndata, block_size, buffer, zero);
|
||||
raid_rec2_ssse3(2, id, ip + 1, nd, block_size, buffer, zero);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -616,8 +616,8 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
SPEED_START {
|
||||
for(j=0;j<ndata;++j) {
|
||||
raid_recX_int8(3, d, c, ndata, block_size, buffer, zero);
|
||||
for(j=0;j<nd;++j) {
|
||||
raid_recX_int8(3, id, ip, nd, block_size, buffer, zero);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -627,8 +627,8 @@ void speed(void)
|
|||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
SPEED_START {
|
||||
for(j=0;j<ndata;++j) {
|
||||
raid_recX_ssse3(3, d, c, ndata, block_size, buffer, zero);
|
||||
for(j=0;j<nd;++j) {
|
||||
raid_recX_ssse3(3, id, ip, nd, block_size, buffer, zero);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -642,8 +642,8 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
SPEED_START {
|
||||
for(j=0;j<ndata;++j) {
|
||||
raid_recX_int8(4, d, c, ndata, block_size, buffer, zero);
|
||||
for(j=0;j<nd;++j) {
|
||||
raid_recX_int8(4, id, ip, nd, block_size, buffer, zero);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -653,8 +653,8 @@ void speed(void)
|
|||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
SPEED_START {
|
||||
for(j=0;j<ndata;++j) {
|
||||
raid_recX_ssse3(4, d, c, ndata, block_size, buffer, zero);
|
||||
for(j=0;j<nd;++j) {
|
||||
raid_recX_ssse3(4, id, ip, nd, block_size, buffer, zero);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -668,8 +668,8 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
SPEED_START {
|
||||
for(j=0;j<ndata;++j) {
|
||||
raid_recX_int8(5, d, c, ndata, block_size, buffer, zero);
|
||||
for(j=0;j<nd;++j) {
|
||||
raid_recX_int8(5, id, ip, nd, block_size, buffer, zero);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -679,8 +679,8 @@ void speed(void)
|
|||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
SPEED_START {
|
||||
for(j=0;j<ndata;++j) {
|
||||
raid_recX_ssse3(5, d, c, ndata, block_size, buffer, zero);
|
||||
for(j=0;j<nd;++j) {
|
||||
raid_recX_ssse3(5, id, ip, nd, block_size, buffer, zero);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -694,8 +694,8 @@ void speed(void)
|
|||
fflush(stdout);
|
||||
|
||||
SPEED_START {
|
||||
for(j=0;j<ndata;++j) {
|
||||
raid_recX_int8(6, d, c, ndata, block_size, buffer, zero);
|
||||
for(j=0;j<nd;++j) {
|
||||
raid_recX_int8(6, id, ip, nd, block_size, buffer, zero);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
@ -705,8 +705,8 @@ void speed(void)
|
|||
#if defined(__i386__) || defined(__x86_64__)
|
||||
if (cpu_has_ssse3()) {
|
||||
SPEED_START {
|
||||
for(j=0;j<ndata;++j) {
|
||||
raid_recX_ssse3(6, d, c, ndata, block_size, buffer, zero);
|
||||
for(j=0;j<nd;++j) {
|
||||
raid_recX_ssse3(6, id, ip, nd, block_size, buffer, zero);
|
||||
}
|
||||
} SPEED_STOP
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue