Renames parity level from RAID to PAR.

This commit is contained in:
Andrea Mazzoleni 2013-11-13 21:35:44 +01:00
parent 5c061e1dca
commit 915c3b9202
24 changed files with 656 additions and 659 deletions

View file

@ -75,7 +75,7 @@ EXTRA_DIST = \
noautomake.sh \
README AUTHORS HISTORY INSTALL COPYING TODO TEST INSTALL.windows \
snapraid.d snapraid.1 snapraid.txt \
test-raid5.conf test-raid6.conf test-raidS3.conf test-raidS4.conf test-raidS5.conf test-raidS6.conf test-raidS6-hole.conf \
test-par1.conf test-par2.conf test-par3.conf test-par4.conf test-par5.conf test-par6.conf test-par6-hole.conf \
snapraid.conf.example \
configure.windows-x86 configure.windows-x64 snapraid.conf.example.windows \
acinclude.m4
@ -99,14 +99,14 @@ maintainer-clean-local:
CHECKFLAGS = --test-skip-device --test-skip-self -q
CHECKCOUNT = 2000
CHECKSIZE = 4000
CONF = $(srcdir)/test-raidS6.conf
HOLE = $(srcdir)/test-raidS6-hole.conf
RAID5 = $(srcdir)/test-raid5.conf
RAID6 = $(srcdir)/test-raid6.conf
RAIDTP = $(srcdir)/test-raidS3.conf
RAIDQP = $(srcdir)/test-raidS4.conf
RAIDPP = $(srcdir)/test-raidS5.conf
RAIDHP = $(srcdir)/test-raidS6.conf
CONF = $(srcdir)/test-par6.conf
HOLE = $(srcdir)/test-par6-hole.conf
PAR1 = $(srcdir)/test-par1.conf
PAR2 = $(srcdir)/test-par2.conf
PAR3 = $(srcdir)/test-par3.conf
PAR4 = $(srcdir)/test-par4.conf
PAR5 = $(srcdir)/test-par5.conf
PAR6 = $(srcdir)/test-par6.conf
check-local:
rm -rf test
@ -130,7 +130,7 @@ check-local:
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) --test-force-murmur3 sync
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) status
if HAVE_SYMLINK
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID5) pool
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR1) pool
endif
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) -a check
@ -146,9 +146,9 @@ endif
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -v -c $(CONF) list -l test.log > output.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) status -l test.log
if HAVE_SYMLINK
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID5) pool
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR1) pool
endif
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID5) check
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR1) check
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) -a check
echo --- Delete some files and sync
@ -157,7 +157,7 @@ endif
rm test/disk6/9*
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
echo --- Create some more files, hardlinks and empty directories, delete others, sync RAID5 and check
echo --- Create some more files, hardlinks and empty directories, delete others, sync PAR1 and check
rm test/disk4/8*
rm test/disk5/8*
rm test/disk6/8*
@ -176,20 +176,20 @@ endif
echo 3 > test/disk3/file_hardlink1
ln test/disk3/file_hardlink1 test/disk3/file_hardlink2
ln test/disk3/file_hardlink1 test/disk3/file_hardlink3
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -v -c $(RAID5) diff > output.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-fallocate -c $(RAID5) --test-force-order-inode sync
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -v -c $(PAR1) diff > output.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-fallocate -c $(PAR1) --test-force-order-inode sync
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) status
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-sequential -c $(RAID5) check
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-sequential -c $(PAR1) check
echo --- Some commands with a not empty array
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -v -c $(RAID5) dup
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -v -c $(RAID5) list > output.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -v -c $(PAR1) dup
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -v -c $(PAR1) list > output.log
if HAVE_SYMLINK
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID5) pool
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR1) pool
endif
echo --- Extend RAID5 to max parity with fix and check
echo --- Extend PAR1 to max parity with fix and check
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(CONF) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID5) check
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR1) check
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
echo --- Dry
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) dry
@ -246,36 +246,36 @@ endif
mv test/disk4/7* test/disk4/_a/
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
echo --- Delete one disk, fix and check with RAID5
echo --- Delete one disk, fix and check with PAR1
rm -r test/disk3
mkdir test/disk3
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(RAID5) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID5) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(PAR1) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR1) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
echo --- Delete two disks, fix and check with RAID6
echo --- Delete two disks, fix and check with PAR2
rm -r test/disk1
mkdir test/disk1
rm -r test/disk2
mkdir test/disk2
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(RAID5) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(RAID6) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID6) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(PAR1) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(PAR2) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR2) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
echo --- Delete three disks, fix and check with RAIDTP
echo --- Delete three disks, fix and check with PAR3
rm -r test/disk1
mkdir test/disk1
rm -r test/disk2
mkdir test/disk2
rm -r test/disk3
mkdir test/disk3
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(RAID6) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(RAIDTP) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAIDTP) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(PAR2) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(PAR3) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR3) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
echo --- Delete four disks, fix and check with RAIDQP
echo --- Delete four disks, fix and check with PAR4
rm -r test/disk3
mkdir test/disk3
rm -r test/disk4
@ -284,12 +284,12 @@ endif
mkdir test/disk5
rm -r test/disk6
mkdir test/disk6
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(RAIDTP) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(RAIDQP) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAIDQP) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(PAR3) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(PAR4) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR4) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
echo --- Delete five disks, fix and check with RAIDPP
echo --- Delete five disks, fix and check with PAR5
rm -r test/disk1
mkdir test/disk1
rm -r test/disk2
@ -300,12 +300,12 @@ endif
mkdir test/disk5
rm -r test/disk6
mkdir test/disk6
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(RAIDQP) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(RAIDPP) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAIDPP) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(PAR4) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(PAR5) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR5) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
echo --- Delete six disks, fix and check with RAIDHP
echo --- Delete six disks, fix and check with PAR6
rm -r test/disk1
mkdir test/disk1
rm -r test/disk2
@ -318,9 +318,9 @@ endif
mkdir test/disk5
rm -r test/disk6
mkdir test/disk6
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(RAIDPP) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(RAIDHP) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAIDHP) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(PAR5) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(PAR6) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR6) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
echo --- Delete some files and create some new, sync and check in multiple steps using text content
@ -349,35 +349,35 @@ endif
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) --test-force-scrub-even scrub
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) status
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
echo --- Delete files from three disks and fix with import in RAID6
echo --- Delete files from three disks and fix with import in PAR2
rm -r test/disk1/_a
rm -r test/disk1/_b
rm -r test/disk2/_a
rm -r test/disk2/_b
mv test/disk3/_a test/_a
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(RAID6) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -i test/_a -c $(RAID6) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(PAR2) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -i test/_a -c $(PAR2) fix -l test.log
rm -r test/_a
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
echo --- Abort sync late with additions, delete them and recover with RAID6
echo --- Abort sync late with additions, delete them and recover with PAR2
echo --- This triggers the recovering with q using p to check the validity
cp -pR test/disk1/_a test/disk1/_c
cp -pR test/disk1/_a test/disk1/_d
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-kill-after-sync -c $(CONF) sync
rm -r test/disk1/_c
rm -r test/disk1/_d
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID6) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR2) fix -l test.log
rm -r test/disk1/_c
rm -r test/disk1/_d
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
echo --- Abort sync early with additions, delete them and recover with RAID6
echo --- Abort sync early with additions, delete them and recover with PAR2
echo --- This triggers the recovering with q using p to check the validity, but failing for new block being filled with zero
cp -pR test/disk1/_a test/disk1/_c
cp -pR test/disk1/_a test/disk1/_d
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -t 1 --test-kill-after-sync -c $(CONF) sync
rm -r test/disk1/_c
rm -r test/disk1/_d
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(RAID6) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(PAR2) fix -l test.log
rm -r test/disk1/_c
rm -r test/disk1/_d
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
@ -390,24 +390,24 @@ endif
rm -r test/disk2/_c
rm -r test/disk3/_c
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
echo --- Abort sync late with additions and then delete some unchanged stuff and fix with RAID5
echo --- Abort sync late with additions and then delete some unchanged stuff and fix with PAR1
cp -pR test/disk1/_b test/disk1/_c
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID5) --test-kill-after-sync sync
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR1) --test-kill-after-sync sync
rm -r test/disk2
mkdir test/disk2
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID5) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR1) fix -l test.log
echo --- Fixes again to restore all the parity
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) fix -l test.log
rm -r test/disk1/_c
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
echo --- Abort sync late with more deletions than additions and then delete some unchanged stuff and fix with RAID5
echo --- Abort sync late with more deletions than additions and then delete some unchanged stuff and fix with PAR1
cp -pR test/disk1/_a test/disk1/_c
mv test/disk1/_a test/_a
mv test/disk1/_b test/_b
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) --test-kill-after-sync sync
rm -r test/disk2
mkdir test/disk2
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID5) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR1) fix -l test.log
echo --- Fixes again to restore all the parity
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) fix -l test.log
-rm -r test/disk1/_a
@ -417,15 +417,15 @@ endif
mv test/_b test/disk1/_b
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
echo --- Abort sync early with more deletions than additions and then delete some unchanged stuff and fix with RAID6
echo --- Abort sync early with more deletions than additions and then delete some unchanged stuff and fix with PAR2
cp -pR test/disk1/_a test/disk1/_c
mv test/disk1/_a test/_a
mv test/disk1/_b test/_b
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) -t 1 --test-kill-after-sync sync
rm -r test/disk2
mkdir test/disk2
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(RAID5) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID6) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(PAR1) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR2) fix -l test.log
-rm -r test/disk1/_a
-rm -r test/disk1/_b
rm -r test/disk1/_c
@ -433,10 +433,10 @@ endif
mv test/_b test/disk1/_b
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
echo --- Delete some files, fix with -m and check with RAID5
echo --- Delete some files, fix with -m and check with PAR1
rm test/disk1/8*
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(RAID5) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID5) -m fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(PAR1) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR1) -m fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
echo --- Delete some dirs in six disk, fix with -m and check
rm -r test/disk1/_a
@ -451,63 +451,63 @@ endif
rm -r test/disk5/_b
rm -r test/disk6/_a
rm -r test/disk6/_b
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(RAIDPP) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(PAR5) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(CONF) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) -m fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
echo --- Delete some dirs in two disks, fix and check with RAID6 using the -d option for each disk
echo --- Delete some dirs in two disks, fix and check with PAR2 using the -d option for each disk
rm -r test/disk2/_a
rm -r test/disk2/_b
rm -r test/disk5/_a
rm -r test/disk5/_b
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(RAID5) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID6) -d disk2 fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID6) -d disk5 fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(PAR1) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR2) -d disk2 fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR2) -d disk5 fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
echo --- Delete the parity, fix and check with RAID5
echo --- Delete the parity, fix and check with PAR1
rm test/parity
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID5) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID5) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR1) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR1) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
echo --- Delete the parity and the q-parity, fix and check with RAID6
echo --- Delete the parity and the q-parity, fix and check with PAR2
rm test/parity
rm test/q-parity
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID6) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR2) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
echo --- Delete the parity and a disk, fix and check with RAID6
echo --- Delete the parity and a disk, fix and check with PAR2
rm test/parity
rm -r test/disk2/_a
rm -r test/disk2/_b
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID6) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR2) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
echo --- Delete the q-parity and a disk, fix and check with RAID6
echo --- Delete the q-parity and a disk, fix and check with PAR2
rm test/q-parity
rm -r test/disk3/_a
rm -r test/disk3/_b
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID6) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR2) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
echo --- Corrupt the parity, fix and check with RAID5
echo --- Corrupt the parity, fix and check with PAR1
$(TESTENV) ./mktest$(EXEEXT) damage 1 100 10000 test/parity
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(RAID5) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID5) -a check
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID5) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(PAR1) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR1) -a check
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR1) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
echo --- Corrupt the parity and the q-parity, fix and check with RAID6
echo --- Corrupt the parity and the q-parity, fix and check with PAR2
$(TESTENV) ./mktest$(EXEEXT) damage 2 100 10000 test/parity
$(TESTENV) ./mktest$(EXEEXT) damage 2 100 10000 test/q-parity
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(RAID6) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(PAR2) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) -a check
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID6) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR2) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
echo --- Corrupt some files, fix and check with RAID5
echo --- Corrupt some files, fix and check with PAR1
$(TESTENV) ./mktest$(EXEEXT) damage 3 1 500 test/disk2/b*
$(TESTENV) ./mktest$(EXEEXT) append 3 500 test/disk2/c*
$(TESTENV) ./mktest$(EXEEXT) truncate 3 500 test/disk2/d*
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(RAID5) -a check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(RAID5) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID5) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(PAR1) -a check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(PAR1) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR1) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
echo --- Corrupt some files, fix and check with RAID6
echo --- Corrupt some files, fix and check with PAR2
$(TESTENV) ./mktest$(EXEEXT) damage 4 1 500 test/disk2/_a/_a/*
$(TESTENV) ./mktest$(EXEEXT) damage 4 1 500 test/disk3/_a/_a/*
$(TESTENV) ./mktest$(EXEEXT) damage 4 1 500 test/disk2/_a/_b/*
@ -516,12 +516,12 @@ endif
$(TESTENV) ./mktest$(EXEEXT) append 4 500 test/disk3/_b/_a/*
$(TESTENV) ./mktest$(EXEEXT) truncate 4 500 test/disk2/_b/_b/*
$(TESTENV) ./mktest$(EXEEXT) truncate 4 500 test/disk3/_b/_b/*
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(RAID6) -a check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(RAID5) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(RAID6) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID6) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(PAR2) -a check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(PAR1) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(PAR2) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR2) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
echo --- Corrupt some files, fix and check with RAID6
echo --- Corrupt some files, fix and check with PAR2
$(TESTENV) ./mktest$(EXEEXT) damage 5 2 50 test/disk2/_a/_a/*
$(TESTENV) ./mktest$(EXEEXT) damage 5 2 50 test/disk3/_a/_a/*
$(TESTENV) ./mktest$(EXEEXT) append 5 500 test/disk2/_a/_a/*
@ -532,29 +532,29 @@ endif
$(TESTENV) ./mktest$(EXEEXT) append 5 1500 test/disk3/_b/_a/*
$(TESTENV) ./mktest$(EXEEXT) truncate 5 1500 test/disk2/_b/_b/*
$(TESTENV) ./mktest$(EXEEXT) truncate 5 1500 test/disk3/_b/_b/*
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(RAID5) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(RAID6) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID6) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(PAR1) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(PAR2) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR2) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
echo --- Corrupt the parity and some files, fix and check with RAID6
echo --- Corrupt the parity and some files, fix and check with PAR2
$(TESTENV) ./mktest$(EXEEXT) damage 6 100 10000 test/parity
$(TESTENV) ./mktest$(EXEEXT) damage 6 1 500 test/disk1/_a/_a/*
$(TESTENV) ./mktest$(EXEEXT) damage 6 1 500 test/disk1/_a/_b/*
$(TESTENV) ./mktest$(EXEEXT) append 6 500 test/disk1/_b/_a/*
$(TESTENV) ./mktest$(EXEEXT) truncate 6 500 test/disk1/_b/_b/*
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(RAID5) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(RAID6) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID6) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-unrecoverable -c $(PAR1) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(PAR2) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR2) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
echo --- Corrupt the q-parity and some files, fix and check with RAID6
echo --- Corrupt the q-parity and some files, fix and check with PAR2
$(TESTENV) ./mktest$(EXEEXT) damage 7 100 10000 test/q-parity
$(TESTENV) ./mktest$(EXEEXT) damage 7 1 500 test/disk1/_a/_a/*
$(TESTENV) ./mktest$(EXEEXT) damage 7 1 500 test/disk1/_a/_b/*
$(TESTENV) ./mktest$(EXEEXT) append 7 500 test/disk1/_b/_a/*
$(TESTENV) ./mktest$(EXEEXT) truncate 7 500 test/disk1/_b/_b/*
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(RAID5) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(RAID6) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(RAID6) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(PAR1) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-expect-recoverable -c $(PAR2) check -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(PAR2) fix -l test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) check
echo --- Sync after all the fixes
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) -c $(CONF) sync
@ -563,7 +563,7 @@ endif
# Manual testing
MANUAL = ./snapraid --test-skip-device -c test-raid5.conf sync
MANUAL = ./snapraid --test-skip-device -c test-par1.conf sync
valgrind:
valgrind \

14
check.c
View file

@ -112,7 +112,7 @@ static int is_hash_matching(struct snapraid_state* state, int rehash, unsigned d
/* if we checked something, and no block failed the check */
if (hash_checked && j==failed_count) {
/* recompute all the redundancy information */
raid_gen(state->level, buffer, diskmax, state->block_size);
raid_par(state->level, buffer, diskmax, state->block_size);
return 1;
}
@ -125,12 +125,12 @@ static int is_hash_matching(struct snapraid_state* state, int rehash, unsigned d
static int is_parity_matching(struct snapraid_state* state, unsigned diskmax, unsigned i, unsigned char** buffer, unsigned char** buffer_recov)
{
/* recompute parity, note that we don't need parity over i */
raid_gen(i + 1, buffer, diskmax, state->block_size);
raid_par(i + 1, buffer, diskmax, state->block_size);
/* if the recovered parity block matches */
if (memcmp(buffer[diskmax+i], buffer_recov[i], state->block_size) == 0) {
/* recompute all the redundancy information */
raid_gen(state->level, buffer, diskmax, state->block_size);
raid_par(state->level, buffer, diskmax, state->block_size);
return 1;
}
@ -153,7 +153,7 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
/* no fix required */
if (failed_count == 0) {
/* recompute only the parity */
raid_gen(state->level, buffer, diskmax, state->block_size);
raid_par(state->level, buffer, diskmax, state->block_size);
return 0;
}
@ -199,7 +199,7 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
memcpy(buffer[diskmax+p[i]], buffer_recov[p[i]], state->block_size);
/* recover using one less parity, the p[r-1] one */
raid_recov(r-1, d, p, buffer, diskmax, buffer_zero, state->block_size);
raid_rec(r-1, d, p, buffer, diskmax, buffer_zero, state->block_size);
/* use the remaining p[r-1] parity to check the result */
if (is_parity_matching(state, diskmax, p[r-1], buffer, buffer_recov))
@ -239,7 +239,7 @@ static int repair_step(struct snapraid_state* state, int rehash, unsigned pos, u
memcpy(buffer[diskmax+p[i]], buffer_recov[p[i]], state->block_size);
/* recover */
raid_recov(r, d, p, buffer, diskmax, buffer_zero, state->block_size);
raid_rec(r, d, p, buffer, diskmax, buffer_zero, state->block_size);
/* use the hash to check the result */
if (is_hash_matching(state, rehash, diskmax, failed, failed_map, failed_count, buffer, buffer_zero))
@ -324,7 +324,7 @@ static int repair(struct snapraid_state* state, int rehash, unsigned pos, unsign
/* if nothing to fix */
if (!something_to_recover) {
/* recompute only the parity */
raid_gen(state->level, buffer, diskmax, state->block_size);
raid_par(state->level, buffer, diskmax, state->block_size);
return 0;
}

192
cpu.h
View file

@ -148,15 +148,15 @@ static inline int cpu_has_slowmult(void)
* memset0 1849 [MB/s]
* HASH Murmur3 378 [MB/s] (extremely slower than Spooky2)
* HASH Spooky2 3413 [MB/s]
* RAID5 int32x2 707 [MB/s]
* RAID5 mmxx2 1264 [MB/s]
* RAID5 mmxx4 1910 [MB/s]
* RAID5 sse2x2 2204 [MB/s]
* RAID5 sse2x4 2980 [MB/s]
* RAID6 int32x2 296 [MB/s]
* RAID6 mmxx2 543 [MB/s]
* RAID6 sse2x2 1068 [MB/s]
* RAID6 sse2x4 1601 [MB/s]
* PAR1 int32x2 707 [MB/s]
* PAR1 mmxx2 1264 [MB/s]
* PAR1 mmxx4 1910 [MB/s]
* PAR1 sse2x2 2204 [MB/s]
* PAR1 sse2x4 2980 [MB/s]
* PAR2 int32x2 296 [MB/s]
* PAR2 mmxx2 543 [MB/s]
* PAR2 sse2x2 1068 [MB/s]
* PAR2 sse2x4 1601 [MB/s]
*/
if (family == 6 && model == 28)
return 1;
@ -191,30 +191,30 @@ static inline int cpu_has_slowpshufb(void)
* CRC table 316 [MB/s]
* HASH Murmur3 378 [MB/s]
* HASH Spooky2 3389 [MB/s]
* RAID5 int32 1800 [MB/s]
* RAID5 int64 2938 [MB/s]
* RAID5 mmx 2946 [MB/s]
* RAID5 sse2 3429 [MB/s]
* RAID5 sse2ext 3447 [MB/s]
* RAID6 int32 519 [MB/s]
* RAID6 int64 944 [MB/s]
* RAID6 mmx 1160 [MB/s]
* RAID6 sse2 2082 [MB/s]
* RAID6 sse2ext 2481 [MB/s]
* RAIDZ3 int32 236 [MB/s]
* RAIDZ3 int64 456 [MB/s]
* RAIDZ3 mmx 576 [MB/s]
* RAIDZ3 sse2 1109 [MB/s]
* RAIDZ3 sse2ext 1527 [MB/s]
* RAIDZ3 ssse3 931 [MB/s] (slower than sse2ext)
* RAIDZ3 ssse3ext 932 [MB/s] (slower than sse2ext)
* RAIDZ4 int32 144 [MB/s]
* RAIDZ4 int64 271 [MB/s]
* RAIDZ4 mmx 431 [MB/s]
* RAIDZ4 sse2 843 [MB/s]
* RAIDZ4 sse2ext 1086 [MB/s]
* RAIDZ4 ssse3 732 [MB/s] (slower than sse2ext)
* RAIDZ4 ssse3ext 571 [MB/s] (slower than sse2ext)
* PAR1 int32 1800 [MB/s]
* PAR1 int64 2938 [MB/s]
* PAR1 mmx 2946 [MB/s]
* PAR1 sse2 3429 [MB/s]
* PAR1 sse2ext 3447 [MB/s]
* PAR2 int32 519 [MB/s]
* PAR2 int64 944 [MB/s]
* PAR2 mmx 1160 [MB/s]
* PAR2 sse2 2082 [MB/s]
* PAR2 sse2ext 2481 [MB/s]
* PAR3z int32 236 [MB/s]
* PAR3z int64 456 [MB/s]
* PAR3z mmx 576 [MB/s]
* PAR3z sse2 1109 [MB/s]
* PAR3z sse2ext 1527 [MB/s]
* PAR3z ssse3 931 [MB/s] (slower than sse2ext)
* PAR3z ssse3ext 932 [MB/s] (slower than sse2ext)
* PAR4z int32 144 [MB/s]
* PAR4z int64 271 [MB/s]
* PAR4z mmx 431 [MB/s]
* PAR4z sse2 843 [MB/s]
* PAR4z sse2ext 1086 [MB/s]
* PAR4z ssse3 732 [MB/s] (slower than sse2ext)
* PAR4z ssse3ext 571 [MB/s] (slower than sse2ext)
*/
if (family == 6 && model == 28)
return 1;
@ -251,16 +251,16 @@ static inline int cpu_has_slowextendedreg(void)
* CRC intel-crc32 2845 [MB/s]
* HASH Murmur3 2970 [MB/s]
* HASH Spooky2 7503 [MB/s]
* RAID5 int32x2 4595 [MB/s]
* RAID5 mmxx2 5856 [MB/s]
* RAID5 mmxx4 6157 [MB/s]
* RAID5 sse2x2 7151 [MB/s]
* RAID5 sse2x4 8447 [MB/s]
* RAID5 sse2x8 8155 [MB/s] (slower than sse2x4)
* RAID6 int32x2 1892 [MB/s]
* RAID6 mmxx2 3744 [MB/s]
* RAID6 sse2x2 4922 [MB/s]
* RAID6 sse2x4 4464 [MB/s] (slower than sse2x2)
* PAR1 int32x2 4595 [MB/s]
* PAR1 mmxx2 5856 [MB/s]
* PAR1 mmxx4 6157 [MB/s]
* PAR1 sse2x2 7151 [MB/s]
* PAR1 sse2x4 8447 [MB/s]
* PAR1 sse2x8 8155 [MB/s] (slower than sse2x4)
* PAR2 int32x2 1892 [MB/s]
* PAR2 mmxx2 3744 [MB/s]
* PAR2 sse2x2 4922 [MB/s]
* PAR2 sse2x4 4464 [MB/s] (slower than sse2x2)
*/
if (family == 21)
return 1;
@ -278,12 +278,12 @@ static inline int cpu_has_slowextendedreg(void)
* memset0 34685 [MB/s]
* Murmur3 4170 [MB/s]
* Spooky2 2599 [MB/s]
* RAID5 int32x2 8919 [MB/s]
* RAID5 mmxx2 17170 [MB/s]
* RAID5 sse2x2 27478 [MB/s]
* RAID6 int32x2 1953 [MB/s]
* RAID6 mmxx2 7560 [MB/s]
* RAID6 sse2x2 13930 [MB/s]
* PAR1 int32x2 8919 [MB/s]
* PAR1 mmxx2 17170 [MB/s]
* PAR1 sse2x2 27478 [MB/s]
* PAR2 int32x2 1953 [MB/s]
* PAR2 mmxx2 7560 [MB/s]
* PAR2 sse2x2 13930 [MB/s]
*/
/* Intel(R) Core(TM) i7-3740QM CPU @ 2.70GHz
@ -293,12 +293,12 @@ static inline int cpu_has_slowextendedreg(void)
* memset0 26164 [MB/s]
* Murmur3 4469 [MB/s]
* Spooky2 12834 [MB/s]
* RAID5 int32x2 10775 [MB/s]
* RAID5 mmxx2 19644 [MB/s]
* RAID5 sse2x2 29168 [MB/s]
* RAID6 int32x2 3288 [MB/s]
* RAID6 mmxx2 8374 [MB/s]
* RAID6 sse2x2 15547 [MB/s]
* PAR1 int32x2 10775 [MB/s]
* PAR1 mmxx2 19644 [MB/s]
* PAR1 sse2x2 29168 [MB/s]
* PAR2 int32x2 3288 [MB/s]
* PAR2 mmxx2 8374 [MB/s]
* PAR2 sse2x2 15547 [MB/s]
*/
/* Intel(R) Core(TM) i5 CPU 650 @ 3.20GHz
@ -308,12 +308,12 @@ static inline int cpu_has_slowextendedreg(void)
* memset0 25468 [MB/s]
* Murmur3 3357 [MB/s]
* Spooky2 1861 [MB/s]
* RAID5 int32x2 5043 [MB/s]
* RAID5 mmxx2 9864 [MB/s]
* RAID5 sse2x2 16896 [MB/s]
* RAID6 int32x2 1100 [MB/s]
* RAID6 mmxx2 5056 [MB/s]
* RAID6 sse2x2 8726 [MB/s]
* PAR1 int32x2 5043 [MB/s]
* PAR1 mmxx2 9864 [MB/s]
* PAR1 sse2x2 16896 [MB/s]
* PAR2 int32x2 1100 [MB/s]
* PAR2 mmxx2 5056 [MB/s]
* PAR2 sse2x2 8726 [MB/s]
*/
/* AMD Athlon(tm) 64 X2 Dual Core Processor 3600+ 1913.377 MHz
@ -323,12 +323,12 @@ static inline int cpu_has_slowextendedreg(void)
* memset 2414 [MB/s]
* Murmur3 1213 [MB/s]
* Spooky2 947 [MB/s]
* RAID5 int32x2 532 [MB/s]
* RAID5 mmxx2 1121 [MB/s]
* RAID5 sse2x2 2061 [MB/s]
* RAID6 int32x2 280 [MB/s]
* RAID6 mmxx2 632 [MB/s]
* RAID6 sse2x2 909 [MB/s]
* PAR1 int32x2 532 [MB/s]
* PAR1 mmxx2 1121 [MB/s]
* PAR1 sse2x2 2061 [MB/s]
* PAR2 int32x2 280 [MB/s]
* PAR2 mmxx2 632 [MB/s]
* PAR2 sse2x2 909 [MB/s]
*/
/* ARM Feroceon 88FR131 rev 1 (v5l)
@ -338,8 +338,8 @@ static inline int cpu_has_slowextendedreg(void)
* memset 763 [MB/s]
* Murmur3 237 [MB/s]
* Spooky2 216 [MB/s]
* RAID5 int32x2 233 [MB/s]
* RAID6 int32x2 103 [MB/s]
* PAR1 int32x2 233 [MB/s]
* PAR2 int32x2 103 [MB/s]
*/
/* Intel(R) Xeon(R) CPU E3-1270 V2 @ 3.50GHz $
@ -349,12 +349,12 @@ static inline int cpu_has_slowextendedreg(void)
* memset 27842 [MB/s]
* Murmur3 4884 [MB/s]
* Spooky2 14039 [MB/s]
* RAID5 int32x2 11038 [MB/s]
* RAID5 mmxx2 20055 [MB/s]
* RAID5 sse2x2 30703 [MB/s]
* RAID6 int32x2 3267 [MB/s]
* RAID6 mmxx2 8883 [MB/s]
* RAID6 sse2x2 16433 [MB/s]
* PAR1 int32x2 11038 [MB/s]
* PAR1 mmxx2 20055 [MB/s]
* PAR1 sse2x2 30703 [MB/s]
* PAR2 int32x2 3267 [MB/s]
* PAR2 mmxx2 8883 [MB/s]
* PAR2 sse2x2 16433 [MB/s]
*/
/* Bobcat/Zacade (info from x264 -> full family 20)
@ -365,12 +365,12 @@ static inline int cpu_has_slowextendedreg(void)
* memset 2137 [MB/s]
* Murmur3 1140 [MB/s]
* Spooky2 2326 [MB/s]
* RAID5 int32x2 1853 [MB/s]
* RAID5 mmxx2 2019 [MB/s]
* RAID5 sse2x2 2908 [MB/s]
* RAID6 int32x2 884 [MB/s]
* RAID6 mmxx2 1502 [MB/s]
* RAID6 sse2x2 1168 [MB/s] (slow version with prefetchnta)
* PAR1 int32x2 1853 [MB/s]
* PAR1 mmxx2 2019 [MB/s]
* PAR1 sse2x2 2908 [MB/s]
* PAR2 int32x2 884 [MB/s]
* PAR2 mmxx2 1502 [MB/s]
* PAR2 sse2x2 1168 [MB/s] (slow version with prefetchnta)
*/
/* AMD Turion(tm) II Neo N40L Dual-Core Processor (info from user)
@ -380,13 +380,13 @@ static inline int cpu_has_slowextendedreg(void)
* memset 4910 [MB/s]
* Murmur3 1160 [MB/s]
* Spooky2 3994 [MB/s]
* RAID5 int32x2 530 [MB/s]
* RAID5 mmxx2 1114 [MB/s]
* RAID5 sse2x1 2127 [MB/s]
* RAID5 sse2x2 2804 [MB/s]
* RAID6 int32x2 316 [MB/s]
* RAID6 mmxx2 655 [MB/s]
* RAID6 sse2x2 639 [MB/s] (slow version with prefetchnta)
* PAR1 int32x2 530 [MB/s]
* PAR1 mmxx2 1114 [MB/s]
* PAR1 sse2x1 2127 [MB/s]
* PAR1 sse2x2 2804 [MB/s]
* PAR2 int32x2 316 [MB/s]
* PAR2 mmxx2 655 [MB/s]
* PAR2 sse2x2 639 [MB/s] (slow version with prefetchnta)
*/
/* AMD Athlon(tm) II X4 620 (info from user)
@ -398,12 +398,12 @@ static inline int cpu_has_slowextendedreg(void)
* Murmur3x64 3500 [MB/s]
* Spooky2 4362 [MB/s]
* Spooky2x86 4000 [MB/s]
* RAID5 int32x2 1064 [MB/s]
* RAID5 mmxx2 2064 [MB/s]
* RAID5 sse2x2 3289 [MB/s]
* RAID6 int32x2 639 [MB/s]
* RAID6 mmxx2 1325 [MB/s]
* RAID6 sse2x2 915 [MB/s] (slow version with prefetchnta)
* PAR1 int32x2 1064 [MB/s]
* PAR1 mmxx2 2064 [MB/s]
* PAR1 sse2x2 3289 [MB/s]
* PAR2 int32x2 639 [MB/s]
* PAR2 mmxx2 1325 [MB/s]
* PAR2 sse2x2 915 [MB/s] (slow version with prefetchnta)
*/
/* ARM @ 1.2GHz (info from user)
@ -426,8 +426,8 @@ static inline int cpu_has_slowextendedreg(void)
* Murmur3 237 [MB/s]
* Spooky2 216 [MB/s]
* Spooky2x86 418 [MB/s] (dropped experiment of a new hash)
* RAID5 int32x2 233 [MB/s]
* RAID6 int32x2 103 [MB/s]
* PAR1 int32x2 233 [MB/s]
* PAR2 int32x2 103 [MB/s]
*/
#endif

View file

@ -271,7 +271,7 @@ int main(void)
printf("\n");
}
printf(" */\n");
printf("const unsigned char __attribute__((aligned(256))) gfpower[%u][256] =\n", 3);
printf("const unsigned char __attribute__((aligned(256))) gfvandermonde[%u][256] =\n", 3);
printf("{\n");
for(p=0;p<3;++p) {
printf("\t{\n");
@ -303,7 +303,7 @@ int main(void)
printf("\n");
}
printf(" */\n");
printf("const unsigned char __attribute__((aligned(256))) gfgen[%u][256] =\n", PARITY);
printf("const unsigned char __attribute__((aligned(256))) gfcauchy[%u][256] =\n", PARITY);
printf("{\n");
for(p=0;p<PARITY;++p) {
printf("\t{\n");

465
raid.c
View file

@ -31,17 +31,21 @@
*/
/*
* The RAID5 and RAID6 support is implemented like the Linux Kernel RAID
* following the Anvin's paper "The mathematics of RAID-6" [1].
* The RAID5 and RAID6 support is implemented using the Galois Field
* GF(2^8) with the primitive polynomial x^8 + x^4 + x^3 + x^2 + 1
* (285 decimal).
*
* We compute the parity in the Galois Field GF(2^8) with the primitive
* polynomial x^8 + x^4 + x^3 + x^2 + 1 (285 decimal), starting from a set
* of N disk Di with 0<=i<N, using the equations:
* The parity P and Q of a set of N disk Di with 0<=i<N, is computed
* using the equations:
*
* P = sum(Di)
* Q = sum(2^i * Di) with 0<=i<N
*
* To support triple parity, it was first evaluated, and then dropped, an
* This approach is the same used by the Linux Kernel RAID, and by ZFS
* RAIDZ2, better described in the H. Peter Anvin paper "The mathematics
* of RAID-6" [1].
*
* To support triple parity, it was first evaluated and then dropped, an
* extension of the same approach, with additional parity coefficients set
* as powers of 2^-1, with equations:
*
@ -50,8 +54,11 @@
* R = sum(2^-i * Di) with 0<=i<N
*
* This approach works well for triple parity and it's very efficient,
* because we can implement very fast parallele multiplication and
* division by 2 in GF(2^8).
* because we can implement very fast parallel multiplications and
* divisions by 2 in GF(2^8).
*
* It's also similar at the approach used by ZFS RAIDZ3, with the
* difference that ZFS uses powers of 4 instead of 2^-1.
*
* Unfortunately it doesn't work beyond triple parity, because whatever
* value we choose to generate the power coefficients to compute other
@ -63,14 +70,14 @@
* [2, Chap 11, Problem 7] and this is a requirement to have
* a MDS (Maximum Distance Separable) code [2, Chap 11, Theorem 8].
*
* To overcome this limitation, we instead use a Cauchy matrix [3][4] to
* compute the parity. A Cauchy matrix has the property to have all the
* square submatrices not singular, resulting in always solvable equations,
* To overcome this limitation, we use a Cauchy matrix [3][4] to compute
* the parity. A Cauchy matrix has the property to have all the square
* submatrices not singular, resulting in always solvable equations,
* for any combination of missing disks.
*
* The problem of this approach is that it requires the use of
* multiplications by a generic value, and not only by 2 or 2^-1,
* potentially affecting badly the performance.
* generic multiplications, and not only by 2 or 2^-1, potentially
* affecting badly the performance.
*
* Hopefully there is a method to implement parallel multiplications
* using SSSE3 instructions [1][5]. Method competitive with the
@ -78,8 +85,8 @@
*
* Another important property of the Cauchy matrix is that we can setup
* the first two rows with coeffients equal at the RAID5 and RAID6 approach
* described in Anvin's paper [1], resulting in a compatible extension,
* and requiring SSSE3 instructions only if triple parity is used.
* decribed, resulting in a compatible extension, and requiring SSSE3
* instructions only if triple parity or beyond is used.
*
* The matrix is also adjusted, multipling each row by a constant factor
* to make the first column of all 1, to optimize the computation for
@ -148,12 +155,12 @@
* for a Core i7-3740QM CPU @ 2.7GHz is:
*
* int8 int32 int64 sse2 sse2e ssse3 ssse3e
* raid5 11927 22075 36004
* raid6 3378 5874 18235 19164
* raidS3 844 8814 9419
* raidS4 665 6836 7415
* raidS5 537 5388 5686
* raidS6 449 4307 4789
* par1 11927 22075 36004
* par2 3378 5874 18235 19164
* par3 844 8814 9419
* par4 665 6836 7415
* par5 537 5388 5686
* par6 449 4307 4789
*
* Values are in MiB/s of data processed, not counting generated parity.
*
@ -162,23 +169,23 @@
*
* For comparison, the triple parity computation using the power
* coeffients "1,2,2^-1" is only a little faster than the one based on
* the Cauchy matrix if SSSE3 is present. Instead, it's a lot faster if
* SSSE3 is not present.
* the Cauchy matrix if SSSE3 is present.
*
* int8 int32 int64 sse2 sse2e ssse3 ssse3e
* raidZ3 2112 3118 9589 10304
* par3z 2112 3118 9589 10304
*
*
* This makes the use of power coefficients still a good option to
* implement triple parity in CPUs without SSSE3.
* In conclusion, the use of power coefficients, and specifically powers
* of 1,2,2^-1, is the best option to implement triple parity in CPUs
* without SSSE3.
* But if a modern CPU with SSSE3 (or similar) is available, the Cauchy
* matrix is the best option because it provides a general approach
* working for any number of parities.
* matrix is the best option because it provides a fast and general
* approach working for any number of parities.
*
* References:
* [1] Anvin, "The mathematics of RAID-6", 2004
* [2] MacWilliams, Sloane, "The Theory of Error-Correcting Codes", 1977
* [3] Blömer, "An XOR-Based Erasure-Resilient Coding Scheme", 1995
* [3] Blomer, "An XOR-Based Erasure-Resilient Coding Scheme", 1995
* [4] Roth, "Introduction to Coding Theory", 2006
* [5] Plank, "Screaming Fast Galois Field Arithmetic Using Intel SIMD Instructions", 2013
*/
@ -208,9 +215,9 @@
/* specialized parity generation */
/*
* RAID5 32bit C implementation
* PAR1 (RAID5 with xor) 32bit C implementation
*/
void raid5_int32(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par1_int32(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
int d, l;
@ -237,9 +244,9 @@ void raid5_int32(unsigned char** vbuf, unsigned data, unsigned size)
}
/*
* RAID5 64bit C implementation
* PAR1 (RAID5 with xor) 64bit C implementation
*/
void raid5_int64(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par1_int64(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
int d, l;
@ -267,14 +274,14 @@ void raid5_int64(unsigned char** vbuf, unsigned data, unsigned size)
#if defined(__i386__) || defined(__x86_64__)
/*
* RAID5 SSE2 implementation
* PAR1 (RAID5 with xor) SSE2 implementation
*
* Note that we don't have the corresponding x64 sse2ext function using more
* registers because processing a block of 64 bytes already fills
* the typical cache block, and processing 128 bytes doesn't increase
* performance.
*/
void raid5_sse2(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par1_sse2(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
int d, l;
@ -363,9 +370,9 @@ static inline uint64_t d2_64(uint64_t v)
}
/*
* RAID6 32bit C implementation
* PAR2 (RAID6 with powers of 2) 32bit C implementation
*/
void raid6_int32(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par2_int32(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
unsigned char* q;
@ -403,9 +410,9 @@ void raid6_int32(unsigned char** vbuf, unsigned data, unsigned size)
}
/*
* RAID6 64bit C implementation
* PAR2 (RAID6 with powers of 2) 64bit C implementation
*/
void raid6_int64(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par2_int64(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
unsigned char* q;
@ -456,9 +463,9 @@ static const struct gfconst16 {
};
/*
* RAID6 SSE2 implementation
* PAR2 (RAID6 with powers of 2) SSE2 implementation
*/
void raid6_sse2(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par2_sse2(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
unsigned char* q;
@ -507,11 +514,11 @@ void raid6_sse2(unsigned char** vbuf, unsigned data, unsigned size)
#if defined(__x86_64__)
/*
* RAID6 SSE2 implementation
* PAR2 (RAID6 with powers of 2) SSE2 implementation
*
* Note that it uses 16 registers, meaning that x64 is required.
*/
void raid6_sse2ext(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par2_sse2ext(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
unsigned char* q;
@ -583,9 +590,9 @@ void raid6_sse2ext(unsigned char** vbuf, unsigned data, unsigned size)
#endif
/*
* RAIDZ3 with power coefficients 32bit C implementation
* PAR3z (triple parity with powers of 2^-1) 32bit C implementation
*/
void raidZ3_int32(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par3z_int32(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
unsigned char* q;
@ -633,9 +640,9 @@ void raidZ3_int32(unsigned char** vbuf, unsigned data, unsigned size)
}
/*
* RAIDZ3 with power coefficients 64bit C implementation
* PAR3z (triple parity with powers of 2^-1) 64bit C implementation
*/
void raidZ3_int64(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par3z_int64(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
unsigned char* q;
@ -684,9 +691,9 @@ void raidZ3_int64(unsigned char** vbuf, unsigned data, unsigned size)
#if defined(__i386__) || defined(__x86_64__)
/*
* RAIDZ3 with power coefficients SSE2 implementation
* PAR3z (triple parity with powers of 2^-1) SSE2 implementation
*/
void raidZ3_sse2(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par3z_sse2(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
unsigned char* q;
@ -739,11 +746,11 @@ void raidZ3_sse2(unsigned char** vbuf, unsigned data, unsigned size)
#if defined(__x86_64__)
/*
* RAIDZ3 with power coefficients SSE2 implementation
* PAR3z (triple parity with powers of 2^-1) SSE2 implementation
*
* Note that it uses 16 registers, meaning that x64 is required.
*/
void raidZ3_sse2ext(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par3z_sse2ext(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
unsigned char* q;
@ -817,14 +824,14 @@ void raidZ3_sse2ext(unsigned char** vbuf, unsigned data, unsigned size)
#endif
/*
* RAIDS3 8bit C implementation
* PAR3 (triple parity with Cauchy matrix) 8bit C implementation
*
* Note that instead of a generic multiplicationt table, likely resulting
* in multiple cache misses, a precomputed table could be used.
* But this is only a kind of reference function, and we are not really
* interested in speed.
*/
void raidS3_int8(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par3_int8(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
unsigned char* q;
@ -845,8 +852,8 @@ void raidS3_int8(unsigned char** vbuf, unsigned data, unsigned size)
d0 = v_8(vbuf[d][i]);
p0 ^= d0;
q0 ^= gfmul[d0][gfgen[1][d]];
r0 ^= gfmul[d0][gfgen[2][d]];
q0 ^= gfmul[d0][gfcauchy[1][d]];
r0 ^= gfmul[d0][gfcauchy[2][d]];
}
/* first disk with all coefficients at 1 */
@ -864,9 +871,9 @@ void raidS3_int8(unsigned char** vbuf, unsigned data, unsigned size)
#if defined(__i386__) || defined(__x86_64__)
/*
* RAIDS3 SSSE3 implementation
* PAR3 (triple parity with Cauchy matrix) SSSE3 implementation
*/
void raidS3_ssse3(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par3_ssse3(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
unsigned char* q;
@ -950,11 +957,11 @@ void raidS3_ssse3(unsigned char** vbuf, unsigned data, unsigned size)
#if defined(__x86_64__)
/*
* RAIDS3 SSSE3 implementation
* PAR3 (triple parity with Cauchy matrix) SSSE3 implementation
*
* Note that it uses 16 registers, meaning that x64 is required.
*/
void raidS3_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par3_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
unsigned char* q;
@ -1079,14 +1086,14 @@ void raidS3_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size)
#endif
/*
* RAIDS4 8bit C implementation
* PAR4 (quad parity with Cauchy matrix) 8bit C implementation
*
* Note that instead of a generic multiplicationt table, likely resulting
* in multiple cache misses, a precomputed table could be used.
* But this is only a kind of reference function, and we are not really
* interested in speed.
*/
void raidS4_int8(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par4_int8(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
unsigned char* q;
@ -1109,9 +1116,9 @@ void raidS4_int8(unsigned char** vbuf, unsigned data, unsigned size)
d0 = v_8(vbuf[d][i]);
p0 ^= d0;
q0 ^= gfmul[d0][gfgen[1][d]];
r0 ^= gfmul[d0][gfgen[2][d]];
s0 ^= gfmul[d0][gfgen[3][d]];
q0 ^= gfmul[d0][gfcauchy[1][d]];
r0 ^= gfmul[d0][gfcauchy[2][d]];
s0 ^= gfmul[d0][gfcauchy[3][d]];
}
/* first disk with all coefficients at 1 */
@ -1131,9 +1138,9 @@ void raidS4_int8(unsigned char** vbuf, unsigned data, unsigned size)
#if defined(__i386__) || defined(__x86_64__)
/*
* RAIDS4 SSSE3 implementation
* PAR4 (quad parity with Cauchy matrix) SSSE3 implementation
*/
void raidS4_ssse3(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par4_ssse3(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
unsigned char* q;
@ -1236,11 +1243,11 @@ void raidS4_ssse3(unsigned char** vbuf, unsigned data, unsigned size)
#if defined(__x86_64__)
/*
* RAIDS4 SSSE3 implementation
* PAR4 (quad parity with Cauchy matrix) SSSE3 implementation
*
* Note that it uses 16 registers, meaning that x64 is required.
*/
void raidS4_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par4_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
unsigned char* q;
@ -1397,14 +1404,14 @@ void raidS4_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size)
#endif
/*
* RAIDS5 8bit C implementation
* PAR5 (penta parity with Cauchy matrix) 8bit C implementation
*
* Note that instead of a generic multiplicationt table, likely resulting
* in multiple cache misses, a precomputed table could be used.
* But this is only a kind of reference function, and we are not really
* interested in speed.
*/
void raidS5_int8(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par5_int8(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
unsigned char* q;
@ -1429,10 +1436,10 @@ void raidS5_int8(unsigned char** vbuf, unsigned data, unsigned size)
d0 = v_8(vbuf[d][i]);
p0 ^= d0;
q0 ^= gfmul[d0][gfgen[1][d]];
r0 ^= gfmul[d0][gfgen[2][d]];
s0 ^= gfmul[d0][gfgen[3][d]];
t0 ^= gfmul[d0][gfgen[4][d]];
q0 ^= gfmul[d0][gfcauchy[1][d]];
r0 ^= gfmul[d0][gfcauchy[2][d]];
s0 ^= gfmul[d0][gfcauchy[3][d]];
t0 ^= gfmul[d0][gfcauchy[4][d]];
}
/* first disk with all coefficients at 1 */
@ -1454,13 +1461,13 @@ void raidS5_int8(unsigned char** vbuf, unsigned data, unsigned size)
#if defined(__i386__) || defined(__x86_64__)
/*
* RAIDS5 SSSE3 implementation
* PAR5 (penta parity with Cauchy matrix) SSSE3 implementation
*/
#ifdef _WIN32
/* ensures that stack is aligned at 16 bytes because we allocate SSE registers in it */
__attribute__((force_align_arg_pointer))
#endif
void raidS5_ssse3(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par5_ssse3(unsigned char** vbuf, unsigned data, unsigned size)
/* ensures that stack is aligned at 16 bytes because we allocate SSE registers in it */
{
unsigned char* p;
@ -1584,11 +1591,11 @@ void raidS5_ssse3(unsigned char** vbuf, unsigned data, unsigned size)
#if defined(__x86_64__)
/*
* RAIDS5 SSSE3 implementation
* PAR5 (penta parity with Cauchy matrix) SSSE3 implementation
*
* Note that it uses 16 registers, meaning that x64 is required.
*/
void raidS5_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par5_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
unsigned char* q;
@ -1705,14 +1712,14 @@ void raidS5_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size)
#endif
/*
* RAIDS6 8bit C implementation
* PAR6 (hexa parity with Cauchy matrix) 8bit C implementation
*
* Note that instead of a generic multiplicationt table, likely resulting
* in multiple cache misses, a precomputed table could be used.
* But this is only a kind of reference function, and we are not really
* interested in speed.
*/
void raidS6_int8(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par6_int8(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
unsigned char* q;
@ -1739,11 +1746,11 @@ void raidS6_int8(unsigned char** vbuf, unsigned data, unsigned size)
d0 = v_8(vbuf[d][i]);
p0 ^= d0;
q0 ^= gfmul[d0][gfgen[1][d]];
r0 ^= gfmul[d0][gfgen[2][d]];
s0 ^= gfmul[d0][gfgen[3][d]];
t0 ^= gfmul[d0][gfgen[4][d]];
u0 ^= gfmul[d0][gfgen[5][d]];
q0 ^= gfmul[d0][gfcauchy[1][d]];
r0 ^= gfmul[d0][gfcauchy[2][d]];
s0 ^= gfmul[d0][gfcauchy[3][d]];
t0 ^= gfmul[d0][gfcauchy[4][d]];
u0 ^= gfmul[d0][gfcauchy[5][d]];
}
/* first disk with all coefficients at 1 */
@ -1767,13 +1774,13 @@ void raidS6_int8(unsigned char** vbuf, unsigned data, unsigned size)
#if defined(__i386__) || defined(__x86_64__)
/*
* RAIDS6 SSSE3 implementation
* PAR6 (hexa parity with Cauchy matrix) SSSE3 implementation
*/
#ifdef _WIN32
/* ensures that stack is aligned at 16 bytes because we allocate SSE registers in it */
__attribute__((force_align_arg_pointer))
#endif
void raidS6_ssse3(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par6_ssse3(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
unsigned char* q;
@ -1918,11 +1925,11 @@ void raidS6_ssse3(unsigned char** vbuf, unsigned data, unsigned size)
#if defined(__x86_64__)
/*
* RAIDS6 SSSE3 implementation
* PAR6 (hexa parity with Cauchy matrix) SSSE3 implementation
*
* Note that it uses 16 registers, meaning that x64 is required.
*/
void raidS6_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size)
void raid_par6_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
unsigned char* q;
@ -2058,7 +2065,7 @@ void raidS6_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size)
/****************************************************************************/
/* mode */
static unsigned raid_mode = RAID_MODE_S; /**< RAID mode. */
static unsigned raid_mode = RAID_MODE_CAUCHY; /**< RAID mode. */
void raid_set(unsigned mode)
{
@ -2069,28 +2076,28 @@ void raid_set(unsigned mode)
/* parity generation */
/* internal forwarder */
static void (*raid5_gen)(unsigned char** vbuf, unsigned data, unsigned size);
static void (*raid6_gen)(unsigned char** vbuf, unsigned data, unsigned size);
static void (*raidZ3_gen)(unsigned char** vbuf, unsigned data, unsigned size);
static void (*raidS3_gen)(unsigned char** vbuf, unsigned data, unsigned size);
static void (*raidS4_gen)(unsigned char** vbuf, unsigned data, unsigned size);
static void (*raidS5_gen)(unsigned char** vbuf, unsigned data, unsigned size);
static void (*raidS6_gen)(unsigned char** vbuf, unsigned data, unsigned size);
static void (*raid_par1_ptr)(unsigned char** vbuf, unsigned data, unsigned size);
static void (*raid_par2_ptr)(unsigned char** vbuf, unsigned data, unsigned size);
static void (*raid_par3z_ptr)(unsigned char** vbuf, unsigned data, unsigned size);
static void (*raid_par3_ptr)(unsigned char** vbuf, unsigned data, unsigned size);
static void (*raid_par4_ptr)(unsigned char** vbuf, unsigned data, unsigned size);
static void (*raid_par5_ptr)(unsigned char** vbuf, unsigned data, unsigned size);
static void (*raid_par6_ptr)(unsigned char** vbuf, unsigned data, unsigned size);
void raid_gen(unsigned level, unsigned char** vbuf, unsigned data, unsigned size)
void raid_par(unsigned level, unsigned char** vbuf, unsigned data, unsigned size)
{
switch (level) {
case 1 : raid5_gen(vbuf, data, size); break;
case 2 : raid6_gen(vbuf, data, size); break;
case 1 : raid_par1_ptr(vbuf, data, size); break;
case 2 : raid_par2_ptr(vbuf, data, size); break;
case 3 :
if (raid_mode == RAID_MODE_S)
raidS3_gen(vbuf, data, size);
if (raid_mode == RAID_MODE_CAUCHY)
raid_par3_ptr(vbuf, data, size);
else
raidZ3_gen(vbuf, data, size);
raid_par3z_ptr(vbuf, data, size);
break;
case 4 : raidS4_gen(vbuf, data, size); break;
case 5 : raidS5_gen(vbuf, data, size); break;
case 6 : raidS6_gen(vbuf, data, size); break;
case 4 : raid_par4_ptr(vbuf, data, size); break;
case 5 : raid_par5_ptr(vbuf, data, size); break;
case 6 : raid_par6_ptr(vbuf, data, size); break;
default:
fprintf(stderr, "Invalid raid gen level\n");
exit(EXIT_FAILURE);
@ -2159,11 +2166,11 @@ static inline const unsigned char* table(unsigned char v)
*/
static inline void raid_delta_gen(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size)
{
unsigned char* p[RAID_PARITY_S_MAX];
unsigned char* pa[RAID_PARITY_S_MAX];
unsigned char* p[RAID_PARITY_CAUCHY_MAX];
unsigned char* pa[RAID_PARITY_CAUCHY_MAX];
unsigned i;
assert(level > 0 && level <= RAID_PARITY_S_MAX);
assert(level > 0 && level <= RAID_PARITY_CAUCHY_MAX);
for(i=0;i<level;++i) {
/* keep a copy of the parity buffer */
@ -2180,7 +2187,7 @@ static inline void raid_delta_gen(unsigned level, const int* d, const int* c, un
}
/* compute only for the level we really need */
raid_gen(c[level - 1] + 1, vbuf, data, size);
raid_par(c[level - 1] + 1, vbuf, data, size);
for(i=0;i<level;++i) {
/* restore disk buffers as before */
@ -2195,7 +2202,7 @@ static inline void raid_delta_gen(unsigned level, const int* d, const int* c, un
/* specialized raid recovering */
/**
* Recover failure of one data block for RAID5.
* Recover failure of one data block for PAR1.
*
* Starting from the equation:
*
@ -2205,12 +2212,12 @@ static inline void raid_delta_gen(unsigned level, const int* d, const int* c, un
*
* Dx = Pd
*/
static void raid5_recov1(const int* d, unsigned char** vbuf, unsigned data, unsigned size)
static void raid_rec1_par1(const int* d, unsigned char** vbuf, unsigned data, unsigned size)
{
unsigned char* p;
unsigned char* pa;
/* for RAID5 we can directly compute the mssing block */
/* for PAR1 we can directly compute the missing block */
/* and we don't need to use the zero buffer */
p = vbuf[data];
pa = vbuf[d[0]];
@ -2222,7 +2229,7 @@ static void raid5_recov1(const int* d, unsigned char** vbuf, unsigned data, unsi
vbuf[data] = pa;
/* compute */
raid5_gen(vbuf, data, size);
raid_par1_ptr(vbuf, data, size);
/* restore as before */
vbuf[d[0]] = pa;
@ -2230,7 +2237,7 @@ static void raid5_recov1(const int* d, unsigned char** vbuf, unsigned data, unsi
}
/**
* Recover failure of two data blocks for RAID6.
* Recover failure of two data blocks for PAR2.
*
* Starting from the equations:
*
@ -2252,7 +2259,7 @@ static void raid5_recov1(const int* d, unsigned char** vbuf, unsigned data, unsi
*
* That are always satisfied for any 0<=d[0]<d[1]<255.
*/
static void raid6_recov2(const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size)
static void raid_rec2_par2(const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size)
{
unsigned i;
unsigned char* p;
@ -2296,10 +2303,10 @@ static void raid6_recov2(const int* d, const int* c, unsigned char** vbuf, unsig
*/
static unsigned char A(unsigned p, unsigned d)
{
if (raid_mode == RAID_MODE_S)
return gfgen[p][d];
if (raid_mode == RAID_MODE_CAUCHY)
return gfcauchy[p][d];
else
return gfpower[p][d];
return gfvandermonde[p][d];
}
/**
@ -2373,7 +2380,7 @@ static inline void invert(unsigned char* M, unsigned char* V, unsigned n)
*
* Dx = A[c[0],d[0]]^-1 * Pd
*/
void raid_recov1_int8(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size)
void raid_rec1_int8(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size)
{
unsigned i;
unsigned char* p;
@ -2384,9 +2391,9 @@ void raid_recov1_int8(unsigned level, const int* d, const int* c, unsigned char*
(void)level; /* unused */
/* if it's RAID5 uses the dedicated and fastest function */
/* if it's PAR1 uses the dedicated and fastest function */
if (c[0] == 0) {
raid5_recov1(d, vbuf, data, size);
raid_rec1_par1(d, vbuf, data, size);
return;
}
@ -2424,7 +2431,7 @@ void raid_recov1_int8(unsigned level, const int* d, const int* c, unsigned char*
*
* we solve inverting the coefficients matrix.
*/
void raid_recov2_int8(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size)
void raid_rec2_int8(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size)
{
unsigned char* p;
unsigned char* pa;
@ -2438,9 +2445,9 @@ void raid_recov2_int8(unsigned level, const int* d, const int* c, unsigned char*
(void)level; /* unused */
/* if it's RAID6 uses the dedicated and fasteT[ ][2]unction */
/* if it's PAR2 uses the dedicated and fastest function */
if (c[0] == 0 && c[1] == 1) {
raid6_recov2(d, c, vbuf, data, zero, size);
raid_rec2_par2(d, c, vbuf, data, zero, size);
return;
}
@ -2493,13 +2500,13 @@ void raid_recov2_int8(unsigned level, const int* d, const int* c, unsigned char*
* PD[0] = Pd, PD[1] = Qd, PD[2] = Rd, ...
* D[0] = Dx, D[1] = Dy, D[2] = Dz, ...
*/
void raid_recovX_int8(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size)
void raid_recX_int8(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size)
{
unsigned char* p[RAID_PARITY_S_MAX];
unsigned char* pa[RAID_PARITY_S_MAX];
const unsigned char* T[RAID_PARITY_S_MAX][RAID_PARITY_S_MAX];
unsigned char G[RAID_PARITY_S_MAX*RAID_PARITY_S_MAX];
unsigned char V[RAID_PARITY_S_MAX*RAID_PARITY_S_MAX];
unsigned char* p[RAID_PARITY_CAUCHY_MAX];
unsigned char* pa[RAID_PARITY_CAUCHY_MAX];
const unsigned char* T[RAID_PARITY_CAUCHY_MAX][RAID_PARITY_CAUCHY_MAX];
unsigned char G[RAID_PARITY_CAUCHY_MAX*RAID_PARITY_CAUCHY_MAX];
unsigned char V[RAID_PARITY_CAUCHY_MAX*RAID_PARITY_CAUCHY_MAX];
unsigned i, j, k;
/* setup the coefficients matrix */
@ -2528,7 +2535,7 @@ void raid_recovX_int8(unsigned level, const int* d, const int* c, unsigned char*
}
for(i=0;i<size;++i) {
unsigned char PD[RAID_PARITY_S_MAX];
unsigned char PD[RAID_PARITY_CAUCHY_MAX];
/* delta */
for(j=0;j<level;++j)
@ -2548,7 +2555,7 @@ void raid_recovX_int8(unsigned level, const int* d, const int* c, unsigned char*
/*
* RAID recovering for one disk SSSE3 implementation
*/
void raid_recov1_ssse3(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size)
void raid_rec1_ssse3(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size)
{
unsigned char* p;
unsigned char* pa;
@ -2558,9 +2565,9 @@ void raid_recov1_ssse3(unsigned level, const int* d, const int* c, unsigned char
(void)level; /* unused */
/* if it's RAID5 uses the dedicated and fastest function */
/* if it's PAR1 uses the dedicated and fastest function */
if (c[0] == 0) {
raid5_recov1(d, vbuf, data, size);
raid_rec1_par1(d, vbuf, data, size);
return;
}
@ -2604,7 +2611,7 @@ void raid_recov1_ssse3(unsigned level, const int* d, const int* c, unsigned char
/*
* RAID recovering for two disks SSSE3 implementation
*/
void raid_recov2_ssse3(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size)
void raid_rec2_ssse3(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size)
{
const unsigned N = 2;
unsigned char* p[N];
@ -2708,13 +2715,13 @@ void raid_recov2_ssse3(unsigned level, const int* d, const int* c, unsigned char
/*
* RAID recovering SSSE3 implementation
*/
void raid_recovX_ssse3(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size)
void raid_recX_ssse3(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size)
{
unsigned N = level;
unsigned char* p[RAID_PARITY_S_MAX];
unsigned char* pa[RAID_PARITY_S_MAX];
unsigned char G[RAID_PARITY_S_MAX*RAID_PARITY_S_MAX];
unsigned char V[RAID_PARITY_S_MAX*RAID_PARITY_S_MAX];
unsigned char* p[RAID_PARITY_CAUCHY_MAX];
unsigned char* pa[RAID_PARITY_CAUCHY_MAX];
unsigned char G[RAID_PARITY_CAUCHY_MAX*RAID_PARITY_CAUCHY_MAX];
unsigned char V[RAID_PARITY_CAUCHY_MAX*RAID_PARITY_CAUCHY_MAX];
unsigned i, j, k;
/* setup the coefficients matrix */
@ -2738,7 +2745,7 @@ void raid_recovX_ssse3(unsigned level, const int* d, const int* c, unsigned char
asm volatile("movdqa %0,%%xmm7" : : "m" (gfconst16.low4[0]));
for(i=0;i<size;i+=16) {
unsigned char PD[RAID_PARITY_S_MAX][16] __attribute__((aligned(16)));
unsigned char PD[RAID_PARITY_CAUCHY_MAX][16] __attribute__((aligned(16)));
/* delta */
for(j=0;j<N;++j) {
@ -2780,24 +2787,24 @@ void raid_recovX_ssse3(unsigned level, const int* d, const int* c, unsigned char
#endif
/* internal forwarder */
static void (*raid_recov1)(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size);
static void (*raid_recov2)(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size);
static void (*raid_recovX)(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size);
static void (*raid_rec1_ptr)(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size);
static void (*raid_rec2_ptr)(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size);
static void (*raid_recX_ptr)(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size);
void raid_recov(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size)
void raid_rec(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size)
{
switch (level) {
case 1 :
raid_recov1(level, d, c, vbuf, data, zero, size);
raid_rec1_ptr(level, d, c, vbuf, data, zero, size);
break;
case 2 :
raid_recov2(level, d, c, vbuf, data, zero, size);
raid_rec2_ptr(level, d, c, vbuf, data, zero, size);
break;
case 3 :
case 4 :
case 5 :
case 6 :
raid_recovX(level, d, c, vbuf, data, zero, size);
raid_recX_ptr(level, d, c, vbuf, data, zero, size);
break;
default:
fprintf(stderr, "Invalid raid recov level\n");
@ -2810,57 +2817,57 @@ void raid_recov(unsigned level, const int* d, const int* c, unsigned char** vbuf
void raid_init(void)
{
raidS3_gen = raidS3_int8;
raidS4_gen = raidS4_int8;
raidS5_gen = raidS5_int8;
raidS6_gen = raidS6_int8;
raid_par3_ptr = raid_par3_int8;
raid_par4_ptr = raid_par4_int8;
raid_par5_ptr = raid_par5_int8;
raid_par6_ptr = raid_par6_int8;
if (sizeof(void*) == 4) {
raid5_gen = raid5_int32;
raid6_gen = raid6_int32;
raidZ3_gen = raidZ3_int32;
raid_par1_ptr = raid_par1_int32;
raid_par2_ptr = raid_par2_int32;
raid_par3z_ptr = raid_par3z_int32;
} else {
raid5_gen = raid5_int64;
raid6_gen = raid6_int64;
raidZ3_gen = raidZ3_int64;
raid_par1_ptr = raid_par1_int64;
raid_par2_ptr = raid_par2_int64;
raid_par3z_ptr = raid_par3z_int64;
}
raid_recov1 = raid_recov1_int8;
raid_recov2 = raid_recov2_int8;
raid_recovX = raid_recovX_int8;
raid_rec1_ptr = raid_rec1_int8;
raid_rec2_ptr = raid_rec2_int8;
raid_recX_ptr = raid_recX_int8;
#if defined(__i386__) || defined(__x86_64__)
if (cpu_has_sse2()) {
raid5_gen = raid5_sse2;
raid_par1_ptr = raid_par1_sse2;
#if defined(__x86_64__)
if (cpu_has_slowextendedreg()) {
raid6_gen = raid6_sse2;
raidZ3_gen = raidZ3_sse2;
raid_par2_ptr = raid_par2_sse2;
raid_par3z_ptr = raid_par3z_sse2;
} else {
raid6_gen = raid6_sse2ext;
raidZ3_gen = raidZ3_sse2ext;
raid_par2_ptr = raid_par2_sse2ext;
raid_par3z_ptr = raid_par3z_sse2ext;
}
#else
raid6_gen = raid6_sse2;
raidZ3_gen = raidZ3_sse2;
raid_par2_ptr = raid_par2_sse2;
raid_par3z_ptr = raid_par3z_sse2;
#endif
}
if (cpu_has_ssse3()) {
#if defined(__x86_64__)
raidS3_gen = raidS3_ssse3ext;
raidS4_gen = raidS4_ssse3ext;
raidS5_gen = raidS5_ssse3ext;
raidS6_gen = raidS6_ssse3ext;
raid_par3_ptr = raid_par3_ssse3ext;
raid_par4_ptr = raid_par4_ssse3ext;
raid_par5_ptr = raid_par5_ssse3ext;
raid_par6_ptr = raid_par6_ssse3ext;
#else
raidS3_gen = raidS3_ssse3;
raidS4_gen = raidS4_ssse3;
raidS5_gen = raidS5_ssse3;
raidS6_gen = raidS6_ssse3;
raid_par3_ptr = raid_par3_ssse3;
raid_par4_ptr = raid_par4_ssse3;
raid_par5_ptr = raid_par5_ssse3;
raid_par6_ptr = raid_par6_ssse3;
#endif
raid_recov1 = raid_recov1_ssse3;
raid_recov2 = raid_recov2_ssse3;
raid_recovX = raid_recovX_ssse3;
raid_rec1_ptr = raid_rec1_ssse3;
raid_rec2_ptr = raid_rec2_ssse3;
raid_recX_ptr = raid_recX_ssse3;
}
#endif
}
@ -2869,40 +2876,40 @@ static struct raid_func {
const char* name;
void* p;
} RAID_FUNC[] = {
{ "int8", raidS3_int8 },
{ "int8", raidS4_int8 },
{ "int8", raidS5_int8 },
{ "int8", raidS6_int8 },
{ "int32", raid5_int32 },
{ "int64", raid5_int64 },
{ "int32", raid6_int32 },
{ "int64", raid6_int64 },
{ "int32", raidZ3_int32 },
{ "int64", raidZ3_int64 },
{ "int8", raid_recov1_int8 },
{ "int8", raid_recov2_int8 },
{ "int8", raid_recovX_int8 },
{ "int8", raid_par3_int8 },
{ "int8", raid_par4_int8 },
{ "int8", raid_par5_int8 },
{ "int8", raid_par6_int8 },
{ "int32", raid_par1_int32 },
{ "int64", raid_par1_int64 },
{ "int32", raid_par2_int32 },
{ "int64", raid_par2_int64 },
{ "int32", raid_par3z_int32 },
{ "int64", raid_par3z_int64 },
{ "int8", raid_rec1_int8 },
{ "int8", raid_rec2_int8 },
{ "int8", raid_recX_int8 },
#if defined(__i386__) || defined(__x86_64__)
{ "sse2", raid5_sse2 },
{ "sse2", raid6_sse2 },
{ "sse2", raidZ3_sse2 },
{ "ssse3", raidS3_ssse3 },
{ "ssse3", raidS4_ssse3 },
{ "ssse3", raidS5_ssse3 },
{ "ssse3", raidS6_ssse3 },
{ "ssse3", raid_recov1_ssse3 },
{ "ssse3", raid_recov2_ssse3 },
{ "ssse3", raid_recovX_ssse3 },
{ "sse2", raid_par1_sse2 },
{ "sse2", raid_par2_sse2 },
{ "sse2", raid_par3z_sse2 },
{ "ssse3", raid_par3_ssse3 },
{ "ssse3", raid_par4_ssse3 },
{ "ssse3", raid_par5_ssse3 },
{ "ssse3", raid_par6_ssse3 },
{ "ssse3", raid_rec1_ssse3 },
{ "ssse3", raid_rec2_ssse3 },
{ "ssse3", raid_recX_ssse3 },
#endif
#if defined(__x86_64__)
{ "sse2e", raid6_sse2ext },
{ "sse2e", raidZ3_sse2ext },
{ "ssse3e", raidS3_ssse3ext },
{ "ssse3e", raidS4_ssse3ext },
{ "ssse3e", raidS5_ssse3ext },
{ "ssse3e", raidS6_ssse3ext },
{ "sse2e", raid_par2_sse2ext },
{ "sse2e", raid_par3z_sse2ext },
{ "ssse3e", raid_par3_ssse3ext },
{ "ssse3e", raid_par4_ssse3ext },
{ "ssse3e", raid_par5_ssse3ext },
{ "ssse3e", raid_par6_ssse3ext },
#endif
{ 0, 0 }
};
@ -2918,53 +2925,53 @@ static const char* raid_tag(void* func)
return "unknown";
}
const char* raid5_tag(void)
const char* raid_par1_tag(void)
{
return raid_tag(raid5_gen);
return raid_tag(raid_par1_ptr);
}
const char* raid6_tag(void)
const char* raid_par2_tag(void)
{
return raid_tag(raid6_gen);
return raid_tag(raid_par2_ptr);
}
const char* raidZ3_tag(void)
const char* raid_par3z_tag(void)
{
return raid_tag(raidZ3_gen);
return raid_tag(raid_par3z_ptr);
}
const char* raidS3_tag(void)
const char* raid_par3_tag(void)
{
return raid_tag(raidS3_gen);
return raid_tag(raid_par3_ptr);
}
const char* raidS4_tag(void)
const char* raid_par4_tag(void)
{
return raid_tag(raidS4_gen);
return raid_tag(raid_par4_ptr);
}
const char* raidS5_tag(void)
const char* raid_par5_tag(void)
{
return raid_tag(raidS5_gen);
return raid_tag(raid_par5_ptr);
}
const char* raidS6_tag(void)
const char* raid_par6_tag(void)
{
return raid_tag(raidS6_gen);
return raid_tag(raid_par6_ptr);
}
const char* raid_recov1_tag(void)
const char* raid_rec1_tag(void)
{
return raid_tag(raid_recov1);
return raid_tag(raid_rec1_ptr);
}
const char* raid_recov2_tag(void)
const char* raid_rec2_tag(void)
{
return raid_tag(raid_recov2);
return raid_tag(raid_rec2_ptr);
}
const char* raid_recovX_tag(void)
const char* raid_recX_tag(void)
{
return raid_tag(raid_recovX);
return raid_tag(raid_recX_ptr);
}

115
raid.h
View file

@ -24,31 +24,31 @@
/**
* RAID mode supporting up to 6 parities.
*
* It requires SSSE3 to get good performance with triple or more parities.
* It requires SSSE3 to get good performance with triple or more
* parities.
*
* This is the default mode used by SnapRAID.
*/
#define RAID_MODE_S 0
#define RAID_MODE_CAUCHY 0
/**
* RAID mode supporting up to 3 parities,
*
* It has a fast implementation not requiring SSSE3 for triple parity.
* This is mostly intended for low end CPUs like ARM and AMD Athlon II.
*
* This is similar at the mode used by Linux Kernel RAID6 and ZFS RAIDZ.
* It has a fast triple parity implementation even without SSSE3, but it
* cannot go beyond it.
* This is mostly intended for low end CPUs like ARM and AMD Athlon.
*/
#define RAID_MODE_Z 1
#define RAID_MODE_VANDERMONDE 1
/**
* Max level of parity supported for mode S.
* Max level of parity supported for RAID_MODE_CAUCHY.
*/
#define RAID_PARITY_S_MAX 6
#define RAID_PARITY_CAUCHY_MAX 6
/**
* Max level of parity supported for mode Z.
* Max level of parity supported for RAID_MODE_VANDERMONDE.
*/
#define RAID_PARITY_Z_MAX 3
#define RAID_PARITY_VANDERMONDE_MAX 3
/**
* Maximum number of data disks.
@ -58,6 +58,7 @@
/**
* Minimum number of data disks.
* Some optimizations require at least two disks.
*/
#define RAID_DATA_MIN 2
@ -69,7 +70,7 @@ void raid_init(void);
/**
* Set the RAID mode to use. One of RAID_MODE_*.
*
* You can change mode at any time, and it will affect next calls to raid_gen() and raid_recov().
* You can change mode at any time, and it will affect next calls to raid_par() and raid_rec().
*
* The two modes are compatible for the first two levels of parity. The third one is different.
*/
@ -82,9 +83,9 @@ void raid_set(unsigned mode);
* \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.
* \param size Size of the blocks pointed by vbuf. It must be a power of 2, and at least 64.
*/
void raid_gen(unsigned level, unsigned char** vbuf, unsigned data, unsigned size);
void raid_par(unsigned level, unsigned char** vbuf, unsigned data, unsigned size);
/**
* Recovers failures of data disks using the specified parities.
@ -97,59 +98,57 @@ void raid_gen(unsigned level, unsigned char** vbuf, unsigned data, unsigned size
* It has (::data + max(::c[] + 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.
* \param size Size of the blocks pointed by vbuf. It must be a power of 2, and at least 64.
*/
void raid_recov(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size);
void raid_rec(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size);
/**
* Gets the name of the selected function to compute parity.
* Gets the name of the selected function to compute the parity.
* Only for testing.
*/
const char* raid5_tag(void);
const char* raid6_tag(void);
const char* raidZ3_tag(void);
const char* raidS3_tag(void);
const char* raidS4_tag(void);
const char* raidS5_tag(void);
const char* raidS6_tag(void);
const char* raid_recov1_tag(void);
const char* raid_recov2_tag(void);
const char* raid_recovX_tag(void);
const char* raid_par1_tag(void);
const char* raid_par2_tag(void);
const char* raid_par3z_tag(void);
const char* raid_par3_tag(void);
const char* raid_par4_tag(void);
const char* raid_par5_tag(void);
const char* raid_par6_tag(void);
const char* raid_rec1_tag(void);
const char* raid_rec2_tag(void);
const char* raid_recX_tag(void);
/**
* 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_sse2(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_sse2(unsigned char** vbuf, unsigned data, unsigned size);
void raid6_sse2ext(unsigned char** vbuf, unsigned data, unsigned size);
void raidZ3_int32(unsigned char** vbuf, unsigned data, unsigned size);
void raidZ3_int64(unsigned char** vbuf, unsigned data, unsigned size);
void raidZ3_sse2(unsigned char** vbuf, unsigned data, unsigned size);
void raidZ3_sse2ext(unsigned char** vbuf, unsigned data, unsigned size);
void raidS3_int8(unsigned char** vbuf, unsigned data, unsigned size);
void raidS3_ssse3(unsigned char** vbuf, unsigned data, unsigned size);
void raidS3_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size);
void raidS4_int8(unsigned char** vbuf, unsigned data, unsigned size);
void raidS4_ssse3(unsigned char** vbuf, unsigned data, unsigned size);
void raidS4_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size);
void raidS5_int8(unsigned char** vbuf, unsigned data, unsigned size);
void raidS5_ssse3(unsigned char** vbuf, unsigned data, unsigned size);
void raidS5_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size);
void raidS6_int8(unsigned char** vbuf, unsigned data, unsigned size);
void raidS6_ssse3(unsigned char** vbuf, unsigned data, unsigned size);
void raidS6_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size);
void raid_recov1_int8(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size);
void raid_recov2_int8(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size);
void raid_recovX_int8(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size);
void raid_recov1_ssse3(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size);
void raid_recov2_ssse3(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size);
void raid_recovX_ssse3(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size);
void raid_par1_int32(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par1_int64(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par1_sse2(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par2_int32(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par2_int64(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par2_sse2(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par2_sse2ext(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par3z_int32(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par3z_int64(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par3z_sse2(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par3z_sse2ext(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par3_int8(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par3_ssse3(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par3_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par4_int8(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par4_ssse3(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par4_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par5_int8(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par5_ssse3(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par5_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par6_int8(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par6_ssse3(unsigned char** vbuf, unsigned data, unsigned size);
void raid_par6_ssse3ext(unsigned char** vbuf, unsigned data, unsigned size);
void raid_rec1_int8(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size);
void raid_rec2_int8(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size);
void raid_recX_int8(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size);
void raid_rec1_ssse3(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size);
void raid_rec2_ssse3(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size);
void raid_recX_ssse3(unsigned level, const int* d, const int* c, unsigned char** vbuf, unsigned data, unsigned char* zero, unsigned size);
#endif

View file

@ -317,7 +317,7 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
}
/* compute the parity */
raid_gen(state->level, buffer, diskmax, state->block_size);
raid_par(state->level, buffer, diskmax, state->block_size);
/* compare the parity */
for(l=0;l<state->level;++l) {

View file

@ -102,10 +102,10 @@ static void recovtest(unsigned mode, unsigned diskmax, unsigned block_size)
unsigned level;
raid_set(mode);
if (mode == RAID_MODE_S)
level = RAID_PARITY_S_MAX;
if (mode == RAID_MODE_CAUCHY)
level = RAID_PARITY_CAUCHY_MAX;
else
level = RAID_PARITY_Z_MAX;
level = RAID_PARITY_VANDERMONDE_MAX;
buffermax = diskmax + level * 2 + 2;
@ -134,31 +134,31 @@ static void recovtest(unsigned mode, unsigned diskmax, unsigned block_size)
for(i=0;i<level;++i) {
mac[i] = 0;
if (i == 0) {
map[i][mac[i]++] = raid_recov1_int8;
map[i][mac[i]++] = raid_rec1_int8;
#if defined(__i386__) || defined(__x86_64__)
if (cpu_has_ssse3()) {
map[i][mac[i]++] = raid_recov1_ssse3;
map[i][mac[i]++] = raid_rec1_ssse3;
}
#endif
} else if (i == 1) {
map[i][mac[i]++] = raid_recov2_int8;
map[i][mac[i]++] = raid_rec2_int8;
#if defined(__i386__) || defined(__x86_64__)
if (cpu_has_ssse3()) {
map[i][mac[i]++] = raid_recov2_ssse3;
map[i][mac[i]++] = raid_rec2_ssse3;
}
#endif
} else {
map[i][mac[i]++] = raid_recovX_int8;
map[i][mac[i]++] = raid_recX_int8;
#if defined(__i386__) || defined(__x86_64__)
if (cpu_has_ssse3()) {
map[i][mac[i]++] = raid_recovX_ssse3;
map[i][mac[i]++] = raid_recX_ssse3;
}
#endif
}
}
/* compute the parity */
raid_gen(level, buffer, diskmax, block_size);
raid_par(level, buffer, diskmax, block_size);
/* set all the parity to the waste buffer */
for(i=0;i<level;++i)
@ -221,10 +221,10 @@ static void gentest(unsigned mode, unsigned diskmax, unsigned block_size)
unsigned level;
raid_set(mode);
if (mode == RAID_MODE_S)
level = RAID_PARITY_S_MAX;
if (mode == RAID_MODE_CAUCHY)
level = RAID_PARITY_CAUCHY_MAX;
else
level = RAID_PARITY_Z_MAX;
level = RAID_PARITY_VANDERMONDE_MAX;
buffermax = diskmax + level * 2;
@ -238,7 +238,7 @@ static void gentest(unsigned mode, unsigned diskmax, unsigned block_size)
}
/* compute the parity */
raid_gen(level, buffer, diskmax, block_size);
raid_par(level, buffer, diskmax, block_size);
/* copy in back buffers */
for(i=0;i<level;++i)
@ -247,47 +247,47 @@ static void gentest(unsigned mode, unsigned diskmax, unsigned block_size)
/* load all the available functions */
mac = 0;
map[mac++] = raid5_int32;
map[mac++] = raid5_int64;
map[mac++] = raid6_int32;
map[mac++] = raid6_int64;
map[mac++] = raid_par1_int32;
map[mac++] = raid_par1_int64;
map[mac++] = raid_par2_int32;
map[mac++] = raid_par2_int64;
#if defined(__i386__) || defined(__x86_64__)
if (cpu_has_sse2()) {
map[mac++] = raid5_sse2;
map[mac++] = raid6_sse2;
map[mac++] = raid_par1_sse2;
map[mac++] = raid_par2_sse2;
#if defined(__x86_64__)
map[mac++] = raid6_sse2ext;
map[mac++] = raid_par2_sse2ext;
#endif
}
if (mode == RAID_MODE_S) {
map[mac++] = raidS3_int8;
map[mac++] = raidS4_int8;
map[mac++] = raidS5_int8;
map[mac++] = raidS6_int8;
if (mode == RAID_MODE_CAUCHY) {
map[mac++] = raid_par3_int8;
map[mac++] = raid_par4_int8;
map[mac++] = raid_par5_int8;
map[mac++] = raid_par6_int8;
if (cpu_has_ssse3()) {
map[mac++] = raidS3_ssse3;
map[mac++] = raidS4_ssse3;
map[mac++] = raidS5_ssse3;
map[mac++] = raidS6_ssse3;
map[mac++] = raid_par3_ssse3;
map[mac++] = raid_par4_ssse3;
map[mac++] = raid_par5_ssse3;
map[mac++] = raid_par6_ssse3;
#if defined(__x86_64__)
map[mac++] = raidS3_ssse3ext;
map[mac++] = raidS4_ssse3ext;
map[mac++] = raidS5_ssse3ext;
map[mac++] = raidS6_ssse3ext;
map[mac++] = raid_par3_ssse3ext;
map[mac++] = raid_par4_ssse3ext;
map[mac++] = raid_par5_ssse3ext;
map[mac++] = raid_par6_ssse3ext;
#endif
}
#endif
} else {
#if defined(__i386__) || defined(__x86_64__)
map[mac++] = raidZ3_int32;
map[mac++] = raidZ3_int64;
map[mac++] = raid_par3z_int32;
map[mac++] = raid_par3z_int64;
if (cpu_has_sse2()) {
map[mac++] = raidZ3_sse2;
map[mac++] = raid_par3z_sse2;
#if defined(__x86_64__)
map[mac++] = raidZ3_sse2ext;
map[mac++] = raid_par3z_sse2ext;
#endif
}
#endif
@ -425,9 +425,9 @@ void selftest()
hashtest();
crc32ctest();
combotest();
gentest(RAID_MODE_Z, 32, 256);
recovtest(RAID_MODE_Z, 12, 256);
gentest(RAID_MODE_S, 32, 256);
recovtest(RAID_MODE_S, 12, 256);
gentest(RAID_MODE_VANDERMONDE, 32, 256);
recovtest(RAID_MODE_VANDERMONDE, 12, 256);
gentest(RAID_MODE_CAUCHY, 32, 256);
recovtest(RAID_MODE_CAUCHY, 12, 256);
}

View file

@ -821,12 +821,11 @@ low end CPUs like ARM or AMD Phenom, Athlon and Opteron that don\(cqt
support the SSSE3 instructions set, and in such case it may provide
a better performance.
.PP
This format is similar at the one used by the Linux kernel RAID6 and
ZFS RAIDZ3, but it doesn\(cqt work for beyond triple parity.
This format is similar at the one used by the Linux Kernel RAID6 and
ZFS RAIDZ3, but it doesn\(cqt work beyond triple parity.
.PP
If you are using the \(cqr\(hyparity\(cq you will be warned at very run
if it\(cqs recommended to use the \(cqz\(hyparity\(cq format for a performance
increase.
When using \(cqr\(hyparity\(cq you will be warned if it\(cqs recommended to use
the \(cqz\(hyparity\(cq format for a performance improvment.
.PP
It\(cqs possible to convert from one format to another, adjusting
the configuraton file with the wanted z\(hyparity or r\(hyparity file,

View file

@ -614,12 +614,11 @@ Configuration
support the SSSE3 instructions set, and in such case it may provide
a better performance.
This format is similar at the one used by the Linux kernel RAID6 and
ZFS RAIDZ3, but it doesn't work for beyond triple parity.
This format is similar at the one used by the Linux Kernel RAID6 and
ZFS RAIDZ3, but it doesn't work beyond triple parity.
If you are using the 'r-parity' you will be warned at very run
if it's recommended to use the 'z-parity' format for a performance
increase.
When using 'r-parity' you will be warned if it's recommended to use
the 'z-parity' format for a performance improvment.
It's possible to convert from one format to another, adjusting
the configuraton file with the wanted z-parity or r-parity file,

View file

@ -670,12 +670,11 @@ low end CPUs like ARM or AMD Phenom, Athlon and Opteron that don't
support the SSSE3 instructions set, and in such case it may provide
a better performance.
This format is similar at the one used by the Linux kernel RAID6 and
ZFS RAIDZ3, but it doesn't work for beyond triple parity.
This format is similar at the one used by the Linux Kernel RAID6 and
ZFS RAIDZ3, but it doesn't work beyond triple parity.
If you are using the 'r-parity' you will be warned at very run
if it's recommended to use the 'z-parity' format for a performance
increase.
When using 'r-parity' you will be warned if it's recommended to use
the 'z-parity' format for a performance improvment.
It's possible to convert from one format to another, adjusting
the configuraton file with the wanted z-parity or r-parity file,

144
speed.c
View file

@ -253,22 +253,22 @@ void speed(void)
#endif
printf("\n");
/* RAID5 */
printf("%8s", "raid5");
printf("%8s", raid5_tag());
/* PAR1 */
printf("%8s", "par1");
printf("%8s", raid_par1_tag());
fflush(stdout);
printf("%8s", "");
SPEED_START {
raid5_int32(buffer, diskmax, block_size);
raid_par1_int32(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
fflush(stdout);
SPEED_START {
raid5_int64(buffer, diskmax, block_size);
raid_par1_int64(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
@ -277,7 +277,7 @@ void speed(void)
#if defined(__i386__) || defined(__x86_64__)
if (cpu_has_sse2()) {
SPEED_START {
raid5_sse2(buffer, diskmax, block_size);
raid_par1_sse2(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
@ -286,22 +286,22 @@ void speed(void)
#endif
printf("\n");
/* RAID6 */
printf("%8s", "raid6");
printf("%8s", raid6_tag());
/* PAR2 */
printf("%8s", "par2");
printf("%8s", raid_par2_tag());
fflush(stdout);
printf("%8s", "");
SPEED_START {
raid6_int32(buffer, diskmax, block_size);
raid_par2_int32(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
fflush(stdout);
SPEED_START {
raid6_int64(buffer, diskmax, block_size);
raid_par2_int64(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
@ -310,7 +310,7 @@ void speed(void)
#if defined(__i386__) || defined(__x86_64__)
if (cpu_has_sse2()) {
SPEED_START {
raid6_sse2(buffer, diskmax, block_size);
raid_par2_sse2(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
@ -318,7 +318,7 @@ void speed(void)
#if defined(__x86_64__)
SPEED_START {
raid6_sse2ext(buffer, diskmax, block_size);
raid_par2_sse2ext(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
@ -328,22 +328,22 @@ void speed(void)
#endif
printf("\n");
/* RAIDZ3 */
printf("%8s", "raidZ3");
printf("%8s", raidZ3_tag());
/* PAR3z */
printf("%8s", "par3z");
printf("%8s", raid_par3z_tag());
fflush(stdout);
printf("%8s", "");
SPEED_START {
raidZ3_int32(buffer, diskmax, block_size);
raid_par3z_int32(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
fflush(stdout);
SPEED_START {
raidZ3_int64(buffer, diskmax, block_size);
raid_par3z_int64(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
@ -352,7 +352,7 @@ void speed(void)
#if defined(__i386__) || defined(__x86_64__)
if (cpu_has_sse2()) {
SPEED_START {
raidZ3_sse2(buffer, diskmax, block_size);
raid_par3z_sse2(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
@ -360,7 +360,7 @@ void speed(void)
#if defined(__x86_64__)
SPEED_START {
raidZ3_sse2ext(buffer, diskmax, block_size);
raid_par3z_sse2ext(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
@ -370,13 +370,13 @@ void speed(void)
#endif
printf("\n");
/* RAIDS3 */
printf("%8s", "raidS3");
printf("%8s", raidS3_tag());
/* PAR3 */
printf("%8s", "par3");
printf("%8s", raid_par3_tag());
fflush(stdout);
SPEED_START {
raidS3_int8(buffer, diskmax, block_size);
raid_par3_int8(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
@ -396,7 +396,7 @@ void speed(void)
#if defined(__i386__) || defined(__x86_64__)
if (cpu_has_ssse3()) {
SPEED_START {
raidS3_ssse3(buffer, diskmax, block_size);
raid_par3_ssse3(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
@ -404,7 +404,7 @@ void speed(void)
#if defined(__x86_64__)
SPEED_START {
raidS3_ssse3ext(buffer, diskmax, block_size);
raid_par3_ssse3ext(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
@ -414,13 +414,13 @@ void speed(void)
#endif
printf("\n");
/* RAIDS4 */
printf("%8s", "raidS4");
printf("%8s", raidS4_tag());
/* PAR4 */
printf("%8s", "par4");
printf("%8s", raid_par4_tag());
fflush(stdout);
SPEED_START {
raidS4_int8(buffer, diskmax, block_size);
raid_par4_int8(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
@ -440,7 +440,7 @@ void speed(void)
#if defined(__i386__) || defined(__x86_64__)
if (cpu_has_ssse3()) {
SPEED_START {
raidS4_ssse3(buffer, diskmax, block_size);
raid_par4_ssse3(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
@ -448,7 +448,7 @@ void speed(void)
#if defined(__x86_64__)
SPEED_START {
raidS4_ssse3ext(buffer, diskmax, block_size);
raid_par4_ssse3ext(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
@ -458,13 +458,13 @@ void speed(void)
#endif
printf("\n");
/* RAIDS5 */
printf("%8s", "raidS5");
printf("%8s", raidS5_tag());
/* PAR5 */
printf("%8s", "par5");
printf("%8s", raid_par5_tag());
fflush(stdout);
SPEED_START {
raidS5_int8(buffer, diskmax, block_size);
raid_par5_int8(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
@ -484,7 +484,7 @@ void speed(void)
#if defined(__i386__) || defined(__x86_64__)
if (cpu_has_ssse3()) {
SPEED_START {
raidS5_ssse3(buffer, diskmax, block_size);
raid_par5_ssse3(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
@ -492,7 +492,7 @@ void speed(void)
#if defined(__x86_64__)
SPEED_START {
raidS5_ssse3ext(buffer, diskmax, block_size);
raid_par5_ssse3ext(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
@ -502,13 +502,13 @@ void speed(void)
#endif
printf("\n");
/* RAIDS6 */
printf("%8s", "raidS6");
printf("%8s", raidS6_tag());
/* PAR6 */
printf("%8s", "par6");
printf("%8s", raid_par6_tag());
fflush(stdout);
SPEED_START {
raidS6_int8(buffer, diskmax, block_size);
raid_par6_int8(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
@ -528,7 +528,7 @@ void speed(void)
#if defined(__i386__) || defined(__x86_64__)
if (cpu_has_ssse3()) {
SPEED_START {
raidS6_ssse3(buffer, diskmax, block_size);
raid_par6_ssse3(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
@ -536,7 +536,7 @@ void speed(void)
#if defined(__x86_64__)
SPEED_START {
raidS6_ssse3ext(buffer, diskmax, block_size);
raid_par6_ssse3ext(buffer, diskmax, block_size);
} SPEED_STOP
printf("%8"PRIu64, ds / dt);
@ -555,14 +555,14 @@ void speed(void)
printf("%8s", "ssse3");
printf("\n");
printf("%8s", "recov1");
printf("%8s", raid_recov1_tag());
printf("%8s", "rec1");
printf("%8s", raid_rec1_tag());
fflush(stdout);
SPEED_START {
for(j=0;j<diskmax;++j) {
/* +1 to avoid RAID5 optimized case */
raid_recov1_int8(1, d, e + 1, buffer, diskmax, zero, block_size);
/* +1 to avoid PAR1 optimized case */
raid_rec1_int8(1, d, e + 1, buffer, diskmax, zero, block_size);
}
} SPEED_STOP
@ -573,8 +573,8 @@ void speed(void)
if (cpu_has_ssse3()) {
SPEED_START {
for(j=0;j<diskmax;++j) {
/* +1 to avoid RAID5 optimized case */
raid_recov1_ssse3(1, d, e + 1, buffer, diskmax, zero, block_size);
/* +1 to avoid PAR1 optimized case */
raid_rec1_ssse3(1, d, e + 1, buffer, diskmax, zero, block_size);
}
} SPEED_STOP
@ -583,14 +583,14 @@ void speed(void)
#endif
printf("\n");
printf("%8s", "recov2");
printf("%8s", raid_recov2_tag());
printf("%8s", "rec2");
printf("%8s", raid_rec2_tag());
fflush(stdout);
SPEED_START {
for(j=0;j<diskmax;++j) {
/* +1 to avoid RAID6 optimized case */
raid_recov2_int8(2, d, e + 1, buffer, diskmax, zero, block_size);
/* +1 to avoid PAR2 optimized case */
raid_rec2_int8(2, d, e + 1, buffer, diskmax, zero, block_size);
}
} SPEED_STOP
@ -601,8 +601,8 @@ void speed(void)
if (cpu_has_ssse3()) {
SPEED_START {
for(j=0;j<diskmax;++j) {
/* +1 to avoid RAID6 optimized case */
raid_recov2_ssse3(2, d, e + 1, buffer, diskmax, zero, block_size);
/* +1 to avoid PAR2 optimized case */
raid_rec2_ssse3(2, d, e + 1, buffer, diskmax, zero, block_size);
}
} SPEED_STOP
@ -611,13 +611,13 @@ void speed(void)
#endif
printf("\n");
printf("%8s", "recov3");
printf("%8s", raid_recovX_tag());
printf("%8s", "rec3");
printf("%8s", raid_recX_tag());
fflush(stdout);
SPEED_START {
for(j=0;j<diskmax;++j) {
raid_recovX_int8(3, d, e, buffer, diskmax, zero, block_size);
raid_recX_int8(3, d, e, buffer, diskmax, zero, block_size);
}
} SPEED_STOP
@ -628,7 +628,7 @@ void speed(void)
if (cpu_has_ssse3()) {
SPEED_START {
for(j=0;j<diskmax;++j) {
raid_recovX_ssse3(3, d, e, buffer, diskmax, zero, block_size);
raid_recX_ssse3(3, d, e, buffer, diskmax, zero, block_size);
}
} SPEED_STOP
@ -637,13 +637,13 @@ void speed(void)
#endif
printf("\n");
printf("%8s", "recov4");
printf("%8s", raid_recovX_tag());
printf("%8s", "rec4");
printf("%8s", raid_recX_tag());
fflush(stdout);
SPEED_START {
for(j=0;j<diskmax;++j) {
raid_recovX_int8(4, d, e, buffer, diskmax, zero, block_size);
raid_recX_int8(4, d, e, buffer, diskmax, zero, block_size);
}
} SPEED_STOP
@ -654,7 +654,7 @@ void speed(void)
if (cpu_has_ssse3()) {
SPEED_START {
for(j=0;j<diskmax;++j) {
raid_recovX_ssse3(4, d, e, buffer, diskmax, zero, block_size);
raid_recX_ssse3(4, d, e, buffer, diskmax, zero, block_size);
}
} SPEED_STOP
@ -663,13 +663,13 @@ void speed(void)
#endif
printf("\n");
printf("%8s", "recov5");
printf("%8s", raid_recovX_tag());
printf("%8s", "rec5");
printf("%8s", raid_recX_tag());
fflush(stdout);
SPEED_START {
for(j=0;j<diskmax;++j) {
raid_recovX_int8(5, d, e, buffer, diskmax, zero, block_size);
raid_recX_int8(5, d, e, buffer, diskmax, zero, block_size);
}
} SPEED_STOP
@ -680,7 +680,7 @@ void speed(void)
if (cpu_has_ssse3()) {
SPEED_START {
for(j=0;j<diskmax;++j) {
raid_recovX_ssse3(5, d, e, buffer, diskmax, zero, block_size);
raid_recX_ssse3(5, d, e, buffer, diskmax, zero, block_size);
}
} SPEED_STOP
@ -689,13 +689,13 @@ void speed(void)
#endif
printf("\n");
printf("%8s", "recov6");
printf("%8s", raid_recovX_tag());
printf("%8s", "rec6");
printf("%8s", raid_recX_tag());
fflush(stdout);
SPEED_START {
for(j=0;j<diskmax;++j) {
raid_recovX_int8(6, d, e, buffer, diskmax, zero, block_size);
raid_recX_int8(6, d, e, buffer, diskmax, zero, block_size);
}
} SPEED_STOP
@ -706,7 +706,7 @@ void speed(void)
if (cpu_has_ssse3()) {
SPEED_START {
for(j=0;j<diskmax;++j) {
raid_recovX_ssse3(6, d, e, buffer, diskmax, zero, block_size);
raid_recX_ssse3(6, d, e, buffer, diskmax, zero, block_size);
}
} SPEED_STOP

38
state.c
View file

@ -56,15 +56,15 @@ const char* lev_config_name(unsigned l)
const char* lev_raid_name(unsigned mode, unsigned n)
{
switch (n) {
case 1 : return "raid5";
case 2 : return "raid6";
case 3 : if (mode == RAID_MODE_S)
return "raidS3";
case 1 : return "par1";
case 2 : return "par2";
case 3 : if (mode == RAID_MODE_CAUCHY)
return "par3";
else
return "raidZ3";
case 4 : return "raidS4";
case 5 : return "raidS5";
case 6 : return "raidS6";
return "par3z";
case 4 : return "par4";
case 5 : return "par5";
case 6 : return "par6";
}
return 0;
@ -78,7 +78,7 @@ void state_init(struct snapraid_state* state)
state->autosave = 0;
state->need_write = 0;
state->block_size = 256 * 1024; /* default 256 KiB */
state->raid_mode = RAID_MODE_S;
state->raid_mode = RAID_MODE_CAUCHY;
for(l=0;l<LEV_MAX;++l) {
state->parity_path[l][0] = 0;
state->parity_device[l] = 0;
@ -122,9 +122,9 @@ static void state_config_check(struct snapraid_state* state, const char* path, t
unsigned l;
/* check for parity level */
if (state->raid_mode == RAID_MODE_Z) {
if (state->level > RAID_PARITY_Z_MAX) {
fprintf(stderr, "If you use the z-parity you cannot have more than %u parities.\n", RAID_PARITY_Z_MAX);
if (state->raid_mode == RAID_MODE_VANDERMONDE) {
if (state->level > RAID_PARITY_VANDERMONDE_MAX) {
fprintf(stderr, "If you use the z-parity you cannot have more than %u parities.\n", RAID_PARITY_VANDERMONDE_MAX);
exit(EXIT_FAILURE);
}
}
@ -283,7 +283,7 @@ static void state_config_check(struct snapraid_state* state, const char* path, t
#if defined(__i386__) || defined(__x86_64__)
if (!cpu_has_ssse3())
#endif
if (state->raid_mode == RAID_MODE_S) {
if (state->raid_mode == RAID_MODE_CAUCHY) {
if (state->level == 3) {
fprintf(stderr, "WARNING! Your CPU doesn't have a fast implementation for triple parity.\n");
fprintf(stderr, "WARNING! It's recommended to switch to 'z-parity' instead than 'r-parity'.\n");
@ -405,7 +405,7 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
case 'u' : l = 5; break;
case 'z' :
l = 2;
state->raid_mode = RAID_MODE_Z;
state->raid_mode = RAID_MODE_VANDERMONDE;
break;
default:
fprintf(stderr, "Invalid '%s' specification in '%s' at line %u\n", tag, path, line);
@ -789,12 +789,6 @@ static void state_map(struct snapraid_state* state)
++hole;
}
if (hole > 255) {
/* RAID6 P/Q parity works for up to 255 drives, no more */
fprintf(stderr, "Too many disks. No more than 255.\n");
exit(EXIT_FAILURE);
}
/* insert the new mapping */
map = map_alloc(disk->name, hole, "");
@ -879,10 +873,10 @@ static void state_map(struct snapraid_state* state)
} else if (diskcount >= 27 && state->level < 5) {
fprintf(stderr, "WARNING! With %u disks it's recommended to use five parity levels.\n", diskcount);
} else if (diskcount >= 20 && state->level < 4) {
fprintf(stderr, "WARNING! With %u disks it's recommended to use four parity leveles.\n", diskcount);
fprintf(stderr, "WARNING! With %u disks it's recommended to use four parity levels.\n", diskcount);
} else if (diskcount >= 13 && state->level < 3) {
fprintf(stderr, "WARNING! With %u disks it's recommended to use three parity levels.\n", diskcount);
} else if (diskcount >= 6 && state->level < 2) {
} else if (diskcount >= 5 && state->level < 2) {
fprintf(stderr, "WARNING! With %u disks it's recommended to use two parity levels.\n", diskcount);
}
}

View file

@ -95,7 +95,7 @@ struct snapraid_state {
unsigned char hashseed[HASH_SIZE]; /**< Hash seed. Just after a uint64 to provide a minimal alignment. */
unsigned char prevhashseed[HASH_SIZE]; /**< Previous hash seed. In case of rehash. */
char lockfile[PATH_MAX]; /**< Path of the lock file to use. */
unsigned level; /**< Number of parity levels. 1 for RAID5, 2 for RAID6. */
unsigned level; /**< Number of parity levels. 1 for PAR1, 2 for PAR2. */
unsigned hash; /**< Hash kind used. */
unsigned prevhash; /**< Previous hash kind used. In case of rehash. */
unsigned besthash; /**< Best hash suggested. */

2
sync.c
View file

@ -381,7 +381,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
/* updates the parity only if really needed */
if (parity_needs_to_be_updated) {
/* compute the parity */
raid_gen(state->level, buffer, diskmax, state->block_size);
raid_par(state->level, buffer, diskmax, state->block_size);
/* write the parity */
for(l=0;l<state->level;++l) {

View file

@ -8804,7 +8804,7 @@ const unsigned char __attribute__((aligned(256))) gfinv[256] =
* 01 02 04 08 10 20 40 80 1d 3a 74 e8 cd 87 13 26 4c 98 2d 5a b4 75 ea c9 8f 03 06 0c 18 30 60 c0 9d 27 4e 9c 25 4a 94 35 6a d4 b5 77 ee c1 9f 23 46 8c 05 0a 14 28 50 a0 5d ba 69 d2 b9 6f de a1 5f be 61 c2 99 2f 5e bc 65 ca 89 0f 1e 3c 78 f0 fd e7 d3 bb 6b d6 b1 7f fe e1 df a3 5b b6 71 e2 d9 af 43 86 11 22 44 88 0d 1a 34 68 d0 bd 67 ce 81 1f 3e 7c f8 ed c7 93 3b 76 ec c5 97 33 66 cc 85 17 2e 5c b8 6d da a9 4f 9e 21 42 84 15 2a 54 a8 4d 9a 29 52 a4 55 aa 49 92 39 72 e4 d5 b7 73 e6 d1 bf 63 c6 91 3f 7e fc e5 d7 b3 7b f6 f1 ff e3 db ab 4b 96 31 62 c4 95 37 6e dc a5 57 ae 41 82 19 32 64 c8 8d 07 0e 1c 38 70 e0 dd a7 53 a6 51 a2 59 b2 79 f2 f9 ef c3 9b 2b 56 ac 45 8a 09 12 24 48 90 3d 7a f4 f5 f7 f3 fb eb cb 8b 0b 16 2c 58 b0 7d fa e9 cf 83 1b 36 6c
* 01 8e 47 ad d8 6c 36 1b 83 cf e9 fa 7d b0 58 2c 16 0b 8b cb eb fb f3 f7 f5 f4 7a 3d 90 48 24 12 09 8a 45 ac 56 2b 9b c3 ef f9 f2 79 b2 59 a2 51 a6 53 a7 dd e0 70 38 1c 0e 07 8d c8 64 32 19 82 41 ae 57 a5 dc 6e 37 95 c4 62 31 96 4b ab db e3 ff f1 f6 7b b3 d7 e5 fc 7e 3f 91 c6 63 bf d1 e6 73 b7 d5 e4 72 39 92 49 aa 55 a4 52 29 9a 4d a8 54 2a 15 84 42 21 9e 4f a9 da 6d b8 5c 2e 17 85 cc 66 33 97 c5 ec 76 3b 93 c7 ed f8 7c 3e 1f 81 ce 67 bd d0 68 34 1a 0d 88 44 22 11 86 43 af d9 e2 71 b6 5b a3 df e1 fe 7f b1 d6 6b bb d3 e7 fd f0 78 3c 1e 0f 89 ca 65 bc 5e 2f 99 c2 61 be 5f a1 de 6f b9 d2 69 ba 5d a0 50 28 14 0a 05 8c 46 23 9f c1 ee 77 b5 d4 6a 35 94 4a 25 9c 4e 27 9d c0 60 30 18 0c 06 03 8f c9 ea 75 b4 5a 2d 98 4c 26 13 87 cd e8 74 3a 1d 80 40 20
*/
const unsigned char __attribute__((aligned(256))) gfpower[3][256] =
const unsigned char __attribute__((aligned(256))) gfvandermonde[3][256] =
{
{
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
@ -8921,7 +8921,7 @@ const unsigned char __attribute__((aligned(256))) gfpower[3][256] =
* 01 97 7f 9c 7c 18 bd a2 58 1a da 74 70 a3 e5 47 29 07 f5 80 23 e9 fa 46 54 a0 99 95 53 9b 0b c7 09 c0 78 89 92 e3 0d b0 2a 8c fb 17 3f 26 65 87 27 5c 66 61 79 4d 32 b3 8d 52 e2 82 3d f9 c5 02 bc 4c 73 48 62 af ba 41 d9 c4 2f b1 33 b8 15 7d cf 3a a9 5f 84 6d 34 1b 44 94 72 81 42 be cc 4b 0a 6f 5a 22 36 b5 3c 9d 13 7e 08 dd d6 5e 04 fc 5b ec ef f1 6e 1e 77 24 e6 c6 aa cb fd 51 67 06 6a 4a 88 db b2 c2 5d 43 40 f7 50 a8 f2 7a 71 a4 d2 bf 31 90 19 9a 8e f6 c3 a6 e7 60 12 ee 2d de 38 e8 b7 98 c1 28 f3 05 96 63 d1 b9 14 9f 1d 83 68 75 ed 16 03 ce e4 df e0 10 ae 69 55 91 2e 4e fe 21 1f 9e e1 d5 cd ca f0 8b 2b c9 8a 93 bb 57 20 86 1c a1 4f 3e 25 d4 6c a5 6b a7 37 ff 39 35 0c f8 ea 56 45 8f 2c 59 ab 85 eb 49 0f dc d8 76 b6 f4 0e 11 b4 d0 30 d3 3b ad d7
* 01 2b 3f cf 73 2c d6 ed cb 74 15 78 8a c1 17 c9 89 68 21 ab 76 3b 4b 5a 6e 0e b9 d3 b6 3e 36 86 bf a2 a7 30 14 eb c7 2d 96 67 20 b5 9a e0 a8 c6 80 04 8d fe 75 5e 23 ca 8f 48 99 0d df 8e b8 70 29 9c 44 69 3d a5 c2 90 d2 1c 9b 02 1d 98 93 ec 84 e8 64 4c 3a 8b 97 f3 e5 c0 7d 26 c8 08 a0 62 82 55 f7 33 f6 51 63 4d 77 da fd c3 38 6d ee 09 47 a3 05 de a6 f1 22 25 6a 0c 81 b2 6b 58 d5 b3 fc fb 28 7f 07 dc 7a 9e d0 37 b4 e1 1a 24 03 ae 94 ba 88 2f ea 2e 8c 5b bb 79 d1 11 ff a4 19 3c 2a 4e 52 e3 95 bd 31 5d 35 4a 41 c4 db 42 c5 0b 49 1b 7c e4 b0 9d 45 f0 a9 61 57 06 d4 40 91 56 13 fa 87 ac 27 54 dd 59 1f 71 39 43 6c f9 be 4f f4 1e 32 cd e9 7e 7b 66 5f ef e7 6f 0a 60 d7 b7 83 92 e2 af 72 f8 b1 50 10 ce 18 53 a1 cc ad 12 34 0f f5 aa 16 e6 f2 d8 85 9f bc
*/
const unsigned char __attribute__((aligned(256))) gfgen[6][256] =
const unsigned char __attribute__((aligned(256))) gfcauchy[6][256] =
{
{
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,

12
util.c
View file

@ -1360,15 +1360,15 @@ void* malloc_nofail_align(size_t size, void** freeptr)
*
* With displacement (8 buffers, icore5, 32 bit):
*
* RAID5 sse2x4 21936 [MB/s]
* RAID6 sse2x2 11902 [MB/s]
* RAIDZ3 sse2x1 5838 [MB/s]
* PAR1 sse2x4 21936 [MB/s]
* PAR2 sse2x2 11902 [MB/s]
* PAR3z sse2x1 5838 [MB/s]
*
* Without displacement:
*
* RAID5 sse2x4 15368 [MB/s]
* RAID6 sse2x2 6814 [MB/s]
* RAIDZ3 sse2x1 3033 [MB/s]
* PAR1 sse2x4 15368 [MB/s]
* PAR2 sse2x2 6814 [MB/s]
* PAR3z sse2x1 3033 [MB/s]
*/
#define MALLOC_DISPLACEMENT (7*256)