/* * Copyright (C) 2011 Andrea Mazzoleni * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __RAID_H #define __RAID_H /****************************************************************************/ /* raid */ /** * Max number of data disks for RAID6. */ #define RAID6_DATA_LIMIT 255 /** * Max number of data disks for RAIDQP. */ #define RAIDQP_DATA_LIMIT 21 /** * Initializes the RAID system. */ void raid_init(void); /** * Computes the specified number of parities. * \param level Number of parities to compute. * \param vbuf Vector of pointers to the blocks for disks and parities. * It has (::data + ::level) elements. Each element points to a buffer of ::size bytes. * \param data Number of data disks. * \param size Size of the blocks pointed by vbuf. */ void raid_gen(unsigned level, unsigned char** vbuf, unsigned data, unsigned size); /* * Recovers failure of one data block x using parity i. * Note that only the data block is recovered. The full parity is instead destroyed. * \param x Index of the data disk to recover. Starting from 0. * \param i Index of the parity to use for the recovering. Starting from 0. * \param vbuf Vector of pointers to the blocks for disks and parities. * It has (::data + ::i + 1) elements. Each element points to a buffer of ::size bytes. * \param data Number of data disks. * \param zero Buffer filled with 0 of ::size bytes. * This buffer is not modified. * \param size Size of the blocks pointed by vbuf. */ void raid_recov_1data(int x, int i, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size); /* * Recovers failure of two data blocks x,y using parity i,j. * Note that only the data blocks are recovered. The full parity is instead destroyed. */ void raid_recov_2data(int x, int y, int i, int j, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size); /* * Recovers failure of three data blocks x,y,z using parity i,j,k. * Note that only the data blocks are recovered. The full parity is instead destroyed. */ void raid_recov_3data(int x, int y, int z, int i, int j, int k, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size); /* * Recovers failure of four data blocks x,y,z,v using parity i,j,k,l. * Note that only the data blocks are recovered. The full parity is instead destroyed. */ void raid_recov_4data(int x, int y, int z, int v, int i, int j, int k, int l, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size); /** * Gets the name of the selected function to compute parity. */ const char* raid5_tag(void); const char* raid6_tag(void); const char* raidTP_tag(void); const char* raidQP_tag(void); /** * Internal specialized parity computation. * Only for testing. */ void raid5_int32(unsigned char** vbuf, unsigned data, unsigned size); void raid5_int64(unsigned char** vbuf, unsigned data, unsigned size); void raid5_mmx(unsigned char** vbuf, unsigned data, unsigned size); void raid5_sse2(unsigned char** vbuf, unsigned data, unsigned size); void raid5_sse2ext(unsigned char** vbuf, unsigned data, unsigned size); void raid6_int32(unsigned char** vbuf, unsigned data, unsigned size); void raid6_int64(unsigned char** vbuf, unsigned data, unsigned size); void raid6_mmx(unsigned char** vbuf, unsigned data, unsigned size); void raid6_sse2(unsigned char** vbuf, unsigned data, unsigned size); void raid6_sse2ext(unsigned char** vbuf, unsigned data, unsigned size); void raidTP_int32(unsigned char** vbuf, unsigned data, unsigned size); void raidTP_int64(unsigned char** vbuf, unsigned data, unsigned size); void raidTP_mmx(unsigned char** vbuf, unsigned data, unsigned size); void raidTP_sse2(unsigned char** vbuf, unsigned data, unsigned size); void raidTP_sse2ext(unsigned char** vbuf, unsigned data, unsigned size); void raidTP_ssse3(unsigned char** vbuf, unsigned data, unsigned size); void raidTP_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size); void raidQP_int32(unsigned char** vbuf, unsigned data, unsigned size); void raidQP_int64(unsigned char** vbuf, unsigned data, unsigned size); void raidQP_mmx(unsigned char** vbuf, unsigned data, unsigned size); void raidQP_sse2(unsigned char** vbuf, unsigned data, unsigned size); void raidQP_sse2ext(unsigned char** vbuf, unsigned data, unsigned size); void raidQP_ssse3(unsigned char** vbuf, unsigned data, unsigned size); void raidQP_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size); void raidQP_avxext(unsigned char** vbuf, unsigned data, unsigned size); #endif