mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-04 05:40:14 -05:00
Enforce mode parity limits
This commit is contained in:
parent
114c5ab5b8
commit
5325c11b10
4 changed files with 16 additions and 6 deletions
|
|
@ -115,7 +115,7 @@ int raid_check(int nr, int *ir, int nd, int np, size_t size, void **v)
|
||||||
|
|
||||||
/* enforce limit on number of failures */
|
/* enforce limit on number of failures */
|
||||||
BUG_ON(nr >= np); /* >= because we check with extra parity */
|
BUG_ON(nr >= np); /* >= because we check with extra parity */
|
||||||
BUG_ON(np > RAID_PARITY_MAX);
|
BUG_ON(np > RAID_PARITY_MAX || (raid_mode_active == RAID_MODE_VANDERMONDE_RAID && np > 3));
|
||||||
|
|
||||||
/* enforce order in index vector */
|
/* enforce order in index vector */
|
||||||
BUG_ON(nr >= 2 && ir[0] >= ir[1]);
|
BUG_ON(nr >= 2 && ir[0] >= ir[1]);
|
||||||
|
|
|
||||||
|
|
@ -373,6 +373,7 @@ extern uint32_t raid_poly_32;
|
||||||
extern uint64_t raid_poly_64;
|
extern uint64_t raid_poly_64;
|
||||||
extern uint32_t raid_inv2_32;
|
extern uint32_t raid_inv2_32;
|
||||||
extern uint64_t raid_inv2_64;
|
extern uint64_t raid_inv2_64;
|
||||||
|
extern int raid_mode_active;
|
||||||
|
|
||||||
#include "gf.h"
|
#include "gf.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ static struct raid_rec_algo raid_rec_algo_aes[RAID_PARITY_MAX];
|
||||||
static struct raid_gen_algo *raid_gen_algo;
|
static struct raid_gen_algo *raid_gen_algo;
|
||||||
static struct raid_rec_algo *raid_rec_algo;
|
static struct raid_rec_algo *raid_rec_algo;
|
||||||
|
|
||||||
static int raid_mode_active = RAID_MODE_GET;
|
int raid_mode_active = RAID_MODE_GET;
|
||||||
|
|
||||||
const uint8_t(*raid_gfmul)[256];
|
const uint8_t(*raid_gfmul)[256];
|
||||||
const uint8_t *raid_gfexp;
|
const uint8_t *raid_gfexp;
|
||||||
|
|
@ -80,8 +80,9 @@ void raid_gen(int nd, int np, size_t size, void **v)
|
||||||
|
|
||||||
/* enforce limit on number of failures */
|
/* enforce limit on number of failures */
|
||||||
BUG_ON(np < 1);
|
BUG_ON(np < 1);
|
||||||
BUG_ON(np > RAID_PARITY_MAX);
|
BUG_ON(np > RAID_PARITY_MAX || (raid_mode_active == RAID_MODE_VANDERMONDE_RAID && np > 3));
|
||||||
|
|
||||||
|
BUG_ON(raid_gen_ptr[np - 1] == 0);
|
||||||
raid_gen_ptr[np - 1](nd, size, v);
|
raid_gen_ptr[np - 1](nd, size, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,7 +105,7 @@ void raid_rec(int nr, int *ir, int nd, int np, size_t size, void **v)
|
||||||
|
|
||||||
/* enforce limit on number of failures */
|
/* enforce limit on number of failures */
|
||||||
BUG_ON(nr > np);
|
BUG_ON(nr > np);
|
||||||
BUG_ON(np > RAID_PARITY_MAX);
|
BUG_ON(np > RAID_PARITY_MAX || (raid_mode_active == RAID_MODE_VANDERMONDE_RAID && np > 3));
|
||||||
|
|
||||||
/* enforce order in index vector */
|
/* enforce order in index vector */
|
||||||
BUG_ON(nr >= 2 && ir[0] >= ir[1]);
|
BUG_ON(nr >= 2 && ir[0] >= ir[1]);
|
||||||
|
|
@ -183,9 +184,14 @@ void raid_data(int nr, int *id, int *ip, int nd, size_t size, void **v)
|
||||||
BUG_ON(nr >= 5 && ip[3] >= ip[4]);
|
BUG_ON(nr >= 5 && ip[3] >= ip[4]);
|
||||||
BUG_ON(nr >= 6 && ip[4] >= ip[5]);
|
BUG_ON(nr >= 6 && ip[4] >= ip[5]);
|
||||||
|
|
||||||
|
/* enforce limit on index vector for parity */
|
||||||
|
BUG_ON(nr > 0 && (ip[nr - 1] >= RAID_PARITY_MAX || (raid_mode_active == RAID_MODE_VANDERMONDE_RAID && ip[nr - 1] >= 3)));
|
||||||
|
|
||||||
/* if failed data is present */
|
/* if failed data is present */
|
||||||
if (nr != 0)
|
if (nr != 0) {
|
||||||
raid_rec_algo[nr - 1].rec(nr, id, ip, nd, size, v);
|
BUG_ON(raid_rec_ptr[nr - 1] == 0);
|
||||||
|
raid_rec_ptr[nr - 1](nr, id, ip, nd, size, v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * raid_gen_tag(int na)
|
const char * raid_gen_tag(int na)
|
||||||
|
|
|
||||||
|
|
@ -295,6 +295,9 @@ void raid_delta_gen(int nr, int *id, int *ip, int nd, size_t size, void **v)
|
||||||
int np;
|
int np;
|
||||||
void *latest;
|
void *latest;
|
||||||
|
|
||||||
|
/* zero buffer must be initialized prior to delta recovery */
|
||||||
|
BUG_ON(raid_zero_block == 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Total number of parities we are going to process
|
* Total number of parities we are going to process
|
||||||
* they are both the used and the unused ones
|
* they are both the used and the unused ones
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue