From 81d3b2ad78ae60c9c85de1909701565b2b15e74d Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Wed, 18 Sep 2013 23:16:39 +0200 Subject: [PATCH] Enforces the 21 data disk limit. --- raid.h | 9 +++++++-- selftest.c | 4 ++-- state.c | 12 +++++++++--- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/raid.h b/raid.h index 14fb1194..9a7c74ad 100644 --- a/raid.h +++ b/raid.h @@ -22,9 +22,14 @@ /* raid */ /** - * Max number of data disks for quad parity. + * Max number of data disks for RAID6. */ -#define RAID_QUAD_DATA_LIMIT 21 +#define RAID6_DATA_LIMIT 21 + +/** + * Max number of data disks for RAIDQP. + */ +#define RAIDQP_DATA_LIMIT 21 /** * Syndrome computation. diff --git a/selftest.c b/selftest.c index 3e2204b3..bbc99c66 100644 --- a/selftest.c +++ b/selftest.c @@ -168,8 +168,8 @@ static void raidtest(unsigned diskmax, unsigned block_size) unsigned char* c; unsigned char* p; - /* this is the point where quad parity fails over RAID_QUAD_DATA_LIMIT data disks */ - if (diskmax > RAID_QUAD_DATA_LIMIT && COMBO3[n].use[2] >= 3) + /* this is the point where quad parity fails over RAIDQP_DATA_LIMIT data disks */ + if (diskmax > RAIDQP_DATA_LIMIT && COMBO3[n].use[2] >= 3) continue; /* save */ diff --git a/state.c b/state.c index 320df9e1..d6942f50 100644 --- a/state.c +++ b/state.c @@ -23,6 +23,7 @@ #include "util.h" #include "parity.h" #include "cpu.h" +#include "raid.h" const char* lev_name(unsigned l) { @@ -176,9 +177,14 @@ static void state_config_check(struct snapraid_state* state, const char* path) ++diskcount; } - if (diskcount > 255) { - /* RAID6 P/Q parity works for up to 255 drives, no more */ - fprintf(stderr, "Too many disks. No more than 255.\n"); + if (state->level >= 2 && diskcount > RAID6_DATA_LIMIT) { + /* RAID6 parity works for up to 255 drives, no more */ + fprintf(stderr, "Too many disks for RAID6. No more than %u.\n", RAID6_DATA_LIMIT); + exit(EXIT_FAILURE); + } + if (state->level >= 4 && diskcount > RAIDQP_DATA_LIMIT) { + /* RAIDQP parity works for up to 21 drives, no more */ + fprintf(stderr, "Too many disks for RAIDQP. No more than %u.\n", RAIDQP_DATA_LIMIT); exit(EXIT_FAILURE); }