Cleanup and removes unnecessary optimization.

This commit is contained in:
Andrea Mazzoleni 2013-10-26 17:08:09 +02:00
parent 162650303c
commit bd486e8866

116
raid.c
View file

@ -120,7 +120,7 @@
* *
* This matrix can be extended to support any number of parities, just adding * This matrix can be extended to support any number of parities, just adding
* additional rows, (but removing one column for each row added), without * additional rows, (but removing one column for each row added), without
* the need to changes the already existing rows, and always maintaining the * the changing the already existing rows, and always maintaining the
* guarantee to always have all square submatrices not singular. * guarantee to always have all square submatrices not singular.
* (see mktables.c for more details in how the matrix is generated) * (see mktables.c for more details in how the matrix is generated)
* *
@ -135,11 +135,11 @@
* raidPP 513 4325 4629 * raidPP 513 4325 4629
* raidHP 428 3479 3866 * raidHP 428 3479 3866
* *
* Values are in MiB/s of data read and processed, not counting written parity. * Values are in MiB/s of data processed, not counting written parity.
* *
* For comparison, a similar implementation using the power coeffients approach * For comparison, a similar implementation using the power coeffients approach
* in the same condition, is only a little faster (16%) for RAIDTP with power * in the same condition, is only a little faster (16%) for RAIDTP with power
* coefficient "4", and equal for RAIDQP that gets faster (10%) only using * coefficient "4", and equal for RAIDQP, that gets faster (10%) only using
* AVX instructions. * AVX instructions.
* *
* int32 int64 sse2 sse2e ssse3 ssse3e avxe * int32 int64 sse2 sse2e ssse3 ssse3e avxe
@ -1832,12 +1832,11 @@ static void raid6_recov_2data(const int* d, const int* e, unsigned char** vbuf,
unsigned char* pa; unsigned char* pa;
unsigned char* q; unsigned char* q;
unsigned char* qa; unsigned char* qa;
const unsigned char* pyf; /* P factor to compute Dy */ const unsigned char* T[2];
const unsigned char* qyf; /* Q factor to compute Dy */
/* select tables */ /* select tables */
pyf = table( inv(pow2(d[1]-d[0]) ^ 1) ); T[0] = table( inv(pow2(d[1]-d[0]) ^ 1) );
qyf = table( inv(pow2(d[0]) ^ pow2(d[1])) ); T[1] = table( inv(pow2(d[0]) ^ pow2(d[1])) );
/* compute delta parity */ /* compute delta parity */
raid_delta_2data(d, e, vbuf, data, zero, size); raid_delta_2data(d, e, vbuf, data, zero, size);
@ -1852,14 +1851,8 @@ static void raid6_recov_2data(const int* d, const int* e, unsigned char** vbuf,
unsigned char Pd = p[i] ^ pa[i]; unsigned char Pd = p[i] ^ pa[i];
unsigned char Qd = q[i] ^ qa[i]; unsigned char Qd = q[i] ^ qa[i];
/* addends to reconstruct Dy */ /* reconstruct */
unsigned char pbm = pyf[Pd]; unsigned char Dy = T[0][Pd] ^ T[1][Qd];
unsigned char qbm = qyf[Qd];
/* reconstruct Dy */
unsigned char Dy = pbm ^ qbm;
/* reconstruct Dx */
unsigned char Dx = Pd ^ Dy; unsigned char Dx = Pd ^ Dy;
/* set */ /* set */
@ -1955,7 +1948,7 @@ static void raid_recov_1data(const int* d, const int* e, unsigned char** vbuf, u
unsigned i; unsigned i;
unsigned char* p; unsigned char* p;
unsigned char* pa; unsigned char* pa;
const unsigned char* T; /* P factor to compute Dx */ const unsigned char* T[1]; /* P factor to compute Dx */
/* if it's RAID5 uses the dedicated and fasteT[ ][2]unction */ /* if it's RAID5 uses the dedicated and fasteT[ ][2]unction */
if (e[0] == 0) { if (e[0] == 0) {
@ -1964,7 +1957,7 @@ static void raid_recov_1data(const int* d, const int* e, unsigned char** vbuf, u
} }
/* select tables */ /* select tables */
T = table( inv(A(e[0],d[0])) ); T[0] = table( inv(A(e[0],d[0])) );
/* compute delta parity */ /* compute delta parity */
raid_delta_1data(d, e, vbuf, data, zero, size); raid_delta_1data(d, e, vbuf, data, zero, size);
@ -1976,11 +1969,8 @@ static void raid_recov_1data(const int* d, const int* e, unsigned char** vbuf, u
/* delta */ /* delta */
unsigned char Pd = p[i] ^ pa[i]; unsigned char Pd = p[i] ^ pa[i];
/* addends to reconstruct Dx */ /* reconstruct */
unsigned char pxm = T[Pd]; unsigned char Dx = T[0][Pd];
/* reconstruct Dx */
unsigned char Dx = pxm;
/* set */ /* set */
pa[i] = Dx; pa[i] = Dx;
@ -2044,16 +2034,10 @@ static void raid_recov_2data(const int* d, const int* e, unsigned char** vbuf, u
/* delta */ /* delta */
unsigned char Pd = p[i] ^ pa[i]; unsigned char Pd = p[i] ^ pa[i];
unsigned char Qd = q[i] ^ qa[i]; unsigned char Qd = q[i] ^ qa[i];
unsigned char Dx, Dy;
Dy = T[1][0][Pd] ^ T[1][1][Qd]; /* reconstruct */
unsigned char Dx = T[0][0][Pd] ^ T[0][1][Qd];
/* if e[0] is P, take the fast way */ unsigned char Dy = T[1][0][Pd] ^ T[1][1][Qd];
if (e[0] == 0) {
Dx = Pd ^ Dy;
} else {
Dx = T[0][0][Pd] ^ T[0][1][Qd];
}
/* set */ /* set */
pa[i] = Dx; pa[i] = Dx;
@ -2118,17 +2102,11 @@ static void raid_recov_3data(const int* d, const int* e, unsigned char** vbuf, u
unsigned char Pd = p[i] ^ pa[i]; unsigned char Pd = p[i] ^ pa[i];
unsigned char Qd = q[i] ^ qa[i]; unsigned char Qd = q[i] ^ qa[i];
unsigned char Rd = r[i] ^ ra[i]; unsigned char Rd = r[i] ^ ra[i];
unsigned char Dx, Dy, Dz;
Dy = T[1][0][Pd] ^ T[1][1][Qd] ^ T[1][2][Rd]; /* reconstruct */
Dz = T[2][0][Pd] ^ T[2][1][Qd] ^ T[2][2][Rd]; unsigned char Dx = T[0][0][Pd] ^ T[0][1][Qd] ^ T[0][2][Rd];
unsigned char Dy = T[1][0][Pd] ^ T[1][1][Qd] ^ T[1][2][Rd];
/* if e[0] is P, take the fast way */ unsigned char Dz = T[2][0][Pd] ^ T[2][1][Qd] ^ T[2][2][Rd];
if (e[0] == 0) {
Dx = Pd ^ Dy ^ Dz;
} else {
Dx = T[0][0][Pd] ^ T[0][1][Qd] ^ T[0][2][Rd];
}
/* set */ /* set */
pa[i] = Dx; pa[i] = Dx;
@ -2200,18 +2178,12 @@ static void raid_recov_4data(const int* d, const int* e, unsigned char** vbuf, u
unsigned char Qd = q[i] ^ qa[i]; unsigned char Qd = q[i] ^ qa[i];
unsigned char Rd = r[i] ^ ra[i]; unsigned char Rd = r[i] ^ ra[i];
unsigned char Sd = s[i] ^ sa[i]; unsigned char Sd = s[i] ^ sa[i];
unsigned char Dx, Dy, Dz, Dh;
Dy = T[1][0][Pd] ^ T[1][1][Qd] ^ T[1][2][Rd] ^ T[1][3][Sd]; /* reconstruct */
Dz = T[2][0][Pd] ^ T[2][1][Qd] ^ T[2][2][Rd] ^ T[2][3][Sd]; unsigned char Dx = T[0][0][Pd] ^ T[0][1][Qd] ^ T[0][2][Rd] ^ T[0][3][Sd];
Dh = T[3][0][Pd] ^ T[3][1][Qd] ^ T[3][2][Rd] ^ T[3][3][Sd]; unsigned char Dy = T[1][0][Pd] ^ T[1][1][Qd] ^ T[1][2][Rd] ^ T[1][3][Sd];
unsigned char Dz = T[2][0][Pd] ^ T[2][1][Qd] ^ T[2][2][Rd] ^ T[2][3][Sd];
/* if e[0] is P, take the fast way */ unsigned char Dh = T[3][0][Pd] ^ T[3][1][Qd] ^ T[3][2][Rd] ^ T[3][3][Sd];
if (e[0] == 0) {
Dx = Pd ^ Dy ^ Dz ^ Dh;
} else {
Dx = T[0][0][Pd] ^ T[0][1][Qd] ^ T[0][2][Rd] ^ T[0][3][Sd];
}
/* set */ /* set */
pa[i] = Dx; pa[i] = Dx;
@ -2290,19 +2262,13 @@ static void raid_recov_5data(const int* d, const int* e, unsigned char** vbuf, u
unsigned char Rd = r[i] ^ ra[i]; unsigned char Rd = r[i] ^ ra[i];
unsigned char Sd = s[i] ^ sa[i]; unsigned char Sd = s[i] ^ sa[i];
unsigned char Td = t[i] ^ ta[i]; unsigned char Td = t[i] ^ ta[i];
unsigned char Dx, Dy, Dz, Dh, Dv;
Dy = T[1][0][Pd] ^ T[1][1][Qd] ^ T[1][2][Rd] ^ T[1][3][Sd] ^ T[1][4][Td]; /* reconstruct */
Dz = T[2][0][Pd] ^ T[2][1][Qd] ^ T[2][2][Rd] ^ T[2][3][Sd] ^ T[2][4][Td]; unsigned char Dx = T[0][0][Pd] ^ T[0][1][Qd] ^ T[0][2][Rd] ^ T[0][3][Sd] ^ T[0][4][Td];
Dh = T[3][0][Pd] ^ T[3][1][Qd] ^ T[3][2][Rd] ^ T[3][3][Sd] ^ T[3][4][Td]; unsigned char Dy = T[1][0][Pd] ^ T[1][1][Qd] ^ T[1][2][Rd] ^ T[1][3][Sd] ^ T[1][4][Td];
Dv = T[4][0][Pd] ^ T[4][1][Qd] ^ T[4][2][Rd] ^ T[4][3][Sd] ^ T[4][4][Td]; unsigned char Dz = T[2][0][Pd] ^ T[2][1][Qd] ^ T[2][2][Rd] ^ T[2][3][Sd] ^ T[2][4][Td];
unsigned char Dh = T[3][0][Pd] ^ T[3][1][Qd] ^ T[3][2][Rd] ^ T[3][3][Sd] ^ T[3][4][Td];
/* if e[0] is P, take the fast way */ unsigned char Dv = T[4][0][Pd] ^ T[4][1][Qd] ^ T[4][2][Rd] ^ T[4][3][Sd] ^ T[4][4][Td];
if (e[0] == 0) {
Dx = Pd ^ Dy ^ Dz ^ Dh ^ Dv;
} else {
Dx = T[0][0][Pd] ^ T[0][1][Qd] ^ T[0][2][Rd] ^ T[0][3][Sd] ^ T[0][4][Td];
}
/* set */ /* set */
pa[i] = Dx; pa[i] = Dx;
@ -2387,21 +2353,15 @@ static void raid_recov_6data(const int* d, const int* e, unsigned char** vbuf, u
unsigned char Rd = r[i] ^ ra[i]; unsigned char Rd = r[i] ^ ra[i];
unsigned char Sd = s[i] ^ sa[i]; unsigned char Sd = s[i] ^ sa[i];
unsigned char Td = t[i] ^ ta[i]; unsigned char Td = t[i] ^ ta[i];
unsigned char Od = u[i] ^ ua[i]; unsigned char Ud = u[i] ^ ua[i];
unsigned char Dx, Dy, Dz, Dh, Dv, Dw;
Dy = T[1][0][Pd] ^ T[1][1][Qd] ^ T[1][2][Rd] ^ T[1][3][Sd] ^ T[1][4][Td] ^ T[1][5][Od]; /* reconstruct */
Dz = T[2][0][Pd] ^ T[2][1][Qd] ^ T[2][2][Rd] ^ T[2][3][Sd] ^ T[2][4][Td] ^ T[2][5][Od]; unsigned char Dx = T[0][0][Pd] ^ T[0][1][Qd] ^ T[0][2][Rd] ^ T[0][3][Sd] ^ T[0][4][Td] ^ T[0][5][Ud];
Dh = T[3][0][Pd] ^ T[3][1][Qd] ^ T[3][2][Rd] ^ T[3][3][Sd] ^ T[3][4][Td] ^ T[3][5][Od]; unsigned char Dy = T[1][0][Pd] ^ T[1][1][Qd] ^ T[1][2][Rd] ^ T[1][3][Sd] ^ T[1][4][Td] ^ T[1][5][Ud];
Dv = T[4][0][Pd] ^ T[4][1][Qd] ^ T[4][2][Rd] ^ T[4][3][Sd] ^ T[4][4][Td] ^ T[4][5][Od]; unsigned char Dz = T[2][0][Pd] ^ T[2][1][Qd] ^ T[2][2][Rd] ^ T[2][3][Sd] ^ T[2][4][Td] ^ T[2][5][Ud];
Dw = T[5][0][Pd] ^ T[5][1][Qd] ^ T[5][2][Rd] ^ T[5][3][Sd] ^ T[5][4][Td] ^ T[5][5][Od]; unsigned char Dh = T[3][0][Pd] ^ T[3][1][Qd] ^ T[3][2][Rd] ^ T[3][3][Sd] ^ T[3][4][Td] ^ T[3][5][Ud];
unsigned char Dv = T[4][0][Pd] ^ T[4][1][Qd] ^ T[4][2][Rd] ^ T[4][3][Sd] ^ T[4][4][Td] ^ T[4][5][Ud];
/* if e[0] is P, take the fast way */ unsigned char Dw = T[5][0][Pd] ^ T[5][1][Qd] ^ T[5][2][Rd] ^ T[5][3][Sd] ^ T[5][4][Td] ^ T[5][5][Ud];
if (e[0] == 0) {
Dx = Pd ^ Dy ^ Dz ^ Dh ^ Dv ^ Dw;
} else {
Dx = T[0][0][Pd] ^ T[0][1][Qd] ^ T[0][2][Rd] ^ T[0][3][Sd] ^ T[0][4][Td] ^ T[0][5][Od];
}
/* set */ /* set */
pa[i] = Dx; pa[i] = Dx;