From 86f6309949a8769a38b9f8ab5e7929645c5f8760 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Thu, 26 Dec 2013 08:25:32 +0100 Subject: [PATCH] Supports the special case of a single data disk for all parity levels. --- raid.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ raid.h | 7 ------ selftest.c | 1 + state.c | 5 ----- 4 files changed, 65 insertions(+), 12 deletions(-) diff --git a/raid.c b/raid.c index df63498c..6432a11f 100644 --- a/raid.c +++ b/raid.c @@ -886,6 +886,14 @@ void raid_par3_ssse3(unsigned char** vbuf, unsigned data, unsigned size) q = vbuf[data+1]; r = vbuf[data+2]; + /* special case with only one data disk */ + if (l == 0) { + for(i=0;i<3;++i) + memcpy(vbuf[1+i], vbuf[0], size); + return; + } + + /* generic case with at least two data disks */ asm volatile("movdqa %0,%%xmm3" : : "m" (gfconst16.poly[0])); asm volatile("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0])); @@ -974,6 +982,14 @@ void raid_par3_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size) q = vbuf[data+1]; r = vbuf[data+2]; + /* special case with only one data disk */ + if (l == 0) { + for(i=0;i<3;++i) + memcpy(vbuf[1+i], vbuf[0], size); + return; + } + + /* generic case with at least two data disks */ asm volatile("movdqa %0,%%xmm3" : : "m" (gfconst16.poly[0])); asm volatile("movdqa %0,%%xmm11" : : "m" (gfconst16.low4[0])); @@ -1155,6 +1171,14 @@ void raid_par4_ssse3(unsigned char** vbuf, unsigned data, unsigned size) r = vbuf[data+2]; s = vbuf[data+3]; + /* special case with only one data disk */ + if (l == 0) { + for(i=0;i<4;++i) + memcpy(vbuf[1+i], vbuf[0], size); + return; + } + + /* generic case with at least two data disks */ for(i=0;ilevel > 1 && diskcount < RAID_DATA_MIN) { - fprintf(stderr, "Too few data disks. You must define at least %u.\n", RAID_DATA_MIN); - exit(EXIT_FAILURE); - } /* recommend number of parities */ if (diskcount >= 36 && state->level < 6) {