mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-22 07:56:33 -05: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
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue