From 2bea59f0420b24a873c668f48f883aa0d9657b49 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sat, 12 Mar 2011 23:21:32 +0100 Subject: [PATCH] Adds more extensive tests --- INSTALL | 5 +- Makefile.am | 27 +++++---- README | 22 ++++++- config.h | 6 +- configure.ac | 2 +- mktest.c | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++ snapraid.d | 45 +++++++++----- snapraid.html | 58 ++++++++++++------ snapraid.txt | 47 ++++++++++----- testgen.c | 76 ------------------------ 10 files changed, 308 insertions(+), 141 deletions(-) create mode 100644 mktest.c delete mode 100644 testgen.c diff --git a/INSTALL b/INSTALL index c5e0fccf..5c9af39d 100644 --- a/INSTALL +++ b/INSTALL @@ -11,9 +11,10 @@ type: make install -then change the example configuration file snapraid.conf to fit -your needs and copy it in /etc/snapraid.conf. +then change the example configuration file snapraid.conf.example +to fit your needs and copy it in /etc/snapraid.conf The documentation is in the man page: man snapraid + diff --git a/Makefile.am b/Makefile.am index 919e8c88..9f689613 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ bin_PROGRAMS = snapraid -check_PROGRAMS = testgen +check_PROGRAMS = mktest snapraid_SOURCES = \ snapraid.c \ @@ -33,8 +33,8 @@ noinst_HEADERS = \ tommyhashdyn.c \ tommylist.c -testgen_SOURCES = \ - testgen.c +mktest_SOURCES = \ + mktest.c EXTRA_DIST = \ autogen.sh \ @@ -63,29 +63,34 @@ check-local: mkdir test/disk1 mkdir test/disk2 mkdir test/disk3 - echo Create some files, sync and check - ./testgen 1 3 2000 + echo --- Create some files, sync and check + ./mktest generate 1 3 1000 4000 ./snapraid -c $(srcdir)/test.conf sync ./snapraid -c $(srcdir)/test.conf check - echo Create some more files, sync and check - ./testgen 2 3 2000 + echo --- Create some more files, sync and check + ./mktest generate 2 3 1000 4000 ./snapraid -c $(srcdir)/test.conf sync ./snapraid -c $(srcdir)/test.conf check - echo Delete some files, fix and check + echo --- Delete some files, fix and check rm test/disk1/a* ./snapraid -c $(srcdir)/test.conf check 2>/dev/null ./snapraid -c $(srcdir)/test.conf fix 2>/dev/null ./snapraid -c $(srcdir)/test.conf check - echo Delete the parity, fix and check + echo --- Delete the parity, fix and check rm test/parity ./snapraid -c $(srcdir)/test.conf check 2>/dev/null ./snapraid -c $(srcdir)/test.conf fix 2>/dev/null ./snapraid -c $(srcdir)/test.conf check - echo Corrupt the parity, fix and check - dd if=/dev/zero of=test/parity bs=1024 count=1000 seek=1000 conv=notrunc + echo --- Corrupt the parity, fix and check + ./mktest damage 1 10 10000 test/parity ./snapraid -c $(srcdir)/test.conf check 2>/dev/null ./snapraid -c $(srcdir)/test.conf fix 2>/dev/null ./snapraid -c $(srcdir)/test.conf check + echo --- Corrupt some files, fix and check + ./mktest damage 1 1 500 test/disk2/b* + ./snapraid -c $(srcdir)/test.conf check 2>/dev/null + ./snapraid -c $(srcdir)/test.conf fix 2>/dev/null + ./snapraid -c $(srcdir)/test.conf check echo Success! valgrind: diff --git a/README b/README index e8392241..a529d906 100644 --- a/README +++ b/README @@ -2,9 +2,29 @@ SnapRAID ======== SnapRAID is a backup program for a disk array using redundancy. -Just like a RAID system but based on snapshots. + +SnapRAID uses a disk of the array to store redundancy information, +and it allows to recover from a complete disk failure. + +SnapRAID is mainly targeted for a home media server, where you have +a lot of big files that rarely change. + +The main features of SnapRAID are: + +* You can start using SnapRAID with already filled disks. + You do not have to reformat or copy your data. +* The disks of the array can have different sizes. + You have only to use the biggest one for the redundancy data. +* If you accidentally delete some files in a disk, you can + recover them. +* If more than one disk fails, you lose the data only on the failed disks. + All the data in the other disks is safe. +* It doesn't lock-in your data. + You can stop using SnapRAID at any time. The official site of SnapRAID is: http://snapraid.sourceforge.net + + diff --git a/config.h b/config.h index eb91b443..b3e6c060 100644 --- a/config.h +++ b/config.h @@ -119,7 +119,7 @@ #define PACKAGE_NAME "snapraid" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "snapraid 0.1" +#define PACKAGE_STRING "snapraid 0.2" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "snapraid" @@ -128,7 +128,7 @@ #define PACKAGE_URL "http://snapraid.sourceforge.net" /* Define to the version of this package. */ -#define PACKAGE_VERSION "0.1" +#define PACKAGE_VERSION "0.2" /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 @@ -159,7 +159,7 @@ /* Version number of package */ -#define VERSION "0.1" +#define VERSION "0.2" /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ diff --git a/configure.ac b/configure.ac index 74c469bb..61181f04 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ([2.65]) -AC_INIT([snapraid], [0.1], [], [], [http://snapraid.sourceforge.net]) +AC_INIT([snapraid], [0.2], [], [], [http://snapraid.sourceforge.net]) AM_INIT_AUTOMAKE([foreign no-dependencies]) AC_CONFIG_SRCDIR([snapraid.c]) AC_CONFIG_HEADER([config.h]) diff --git a/mktest.c b/mktest.c new file mode 100644 index 00000000..98251f61 --- /dev/null +++ b/mktest.c @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2011 Andrea Mazzoleni + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "portable.h" + +/** + * Pseudo random number generator. + */ +unsigned long long seed = 0; + +unsigned rnd(unsigned max) +{ + seed = seed * 6364136223846793005LL + 1442695040888963407LL; + + return (seed >> 32) % max; +} + +void generate(int disk, int size) +{ + char path[PATH_MAX]; + char name[PATH_MAX]; + FILE* f; + int count; + int i; + int l; + + l = 1 + rnd(32); + + for(i=0;i SnapRAID uses a disk of the array to store redundancy information, -and it allows to recover from a complete disk failure. +and it allows to recover from a disk failure.

-SnapRAID is based on the snapshot concept like a backup program. -You decide the time to make the "sync" of the redundancy information, -and you are able to restore all the changes done at a disk of the array, -until the "sync". +SnapRAID is mainly targeted for a home media server, where you have +a lot of big files that rarely change.

The main features of SnapRAID are:

    @@ -40,29 +38,53 @@ The disks of the array can have different sizes. You have only to use the biggest one for the redundancy data.
  • -The data in the disks is not changed in any way. -It doesn't even need write access at the data. +If you accidentally delete some files in a disk, you can +recover them.
  • -If more than one disk fails, you lose the data only on the failed disks. -All the data in the other disks is safe. +If more than one disk fails, you lose the data only on the +failed disks. All the data in the other disks is safe.
  • It doesn't lock-in your data. -You can stop using SnapRAID at any time. +You can stop using SnapRAID at any time without the +need to reformat or move data.
+

+The official site of SnapRAID is: +

+
+
+http://snapraid.sourceforge.net
+
+

3 Limitations

SnapRAID is in between a RAID and a backup program trying to get the best -benefits of them. Altough it also has some downsides that you should -consider before using it: -
    -
  • -You have different filesystems for each disk. +benefits of them. Altought it also has some limitations that you should +consider before using it. +

    +The main one, is that if a disk fail, and you haven't recently synched, +you may not able to do a complete recover. +More specifically, you may be unable to recover up to the size of the +amount of the changed or deleted files, from the last sync operation. +This happens even if the files changed or deleted are not in the +failed disk. +New added files don't prevent the recovering of the already existing +files. You may only lose the just added files, if they were on the failed +disk. +

    +This is the reason because SnapRAID is better suited for data that +rarely change. +

    +Other limitations are: +* You have different filesystems for each disk. +
    Using a RAID you have only a big filesystem. - +
    +

    • It doesn't stripe data. With RAID you get a speed boost with striping. @@ -81,7 +103,7 @@ failure of the whole disk array. Getting Started To use SnapRAID you need first to mount all the disks of your disk -array and select which one to dedicate as redundancy information. +array and select which one to dedicate at the redundancy information.

      This disk will be dedicated to this pourpuse only, and you should not store any other data on it. @@ -123,7 +145,7 @@ snapraid sync

      This process will take some hours at best the first time, depending on -the size of the data already present in the data disks. +the size of the data already present in the disks. If the disks are empty the process is immediate. You can stop it at any time pressing Ctrl+C, and at the next run it will start where interrupted. diff --git a/snapraid.txt b/snapraid.txt index 4b8520c2..1451a9e7 100644 --- a/snapraid.txt +++ b/snapraid.txt @@ -19,12 +19,10 @@ snapraid [-V, --version] [-h, --help] SnapRAID is a backup program for a disk array using redundancy. SnapRAID uses a disk of the array to store redundancy information, -and it allows to recover from a complete disk failure. +and it allows to recover from a disk failure. -SnapRAID is based on the snapshot concept like a backup program. -You decide the time to make the "sync" of the redundancy information, -and you are able to restore all the changes done at a disk of the array, -until the "sync". +SnapRAID is mainly targeted for a home media server, where you have +a lot of big files that rarely change. The main features of SnapRAID are: @@ -32,23 +30,42 @@ The main features of SnapRAID are: You do not have to reformat or copy your data. * The disks of the array can have different sizes. You have only to use the biggest one for the redundancy data. -* The data in the disks is not changed in any way. - It doesn't even need write access at the data. -* If more than one disk fails, you lose the data only on the failed disks. - All the data in the other disks is safe. +* If you accidentally delete some files in a disk, you can + recover them. +* If more than one disk fails, you lose the data only on the + failed disks. All the data in the other disks is safe. * It doesn't lock-in your data. - You can stop using SnapRAID at any time. + You can stop using SnapRAID at any time without the + need to reformat or move data. + +The official site of SnapRAID is: + + http://snapraid.sourceforge.net 3 LIMITATIONS ============= SnapRAID is in between a RAID and a backup program trying to get the best -benefits of them. Altough it also has some downsides that you should -consider before using it: +benefits of them. Altought it also has some limitations that you should +consider before using it. +The main one, is that if a disk fail, and you haven't recently synched, +you may not able to do a complete recover. +More specifically, you may be unable to recover up to the size of the +amount of the changed or deleted files, from the last sync operation. +This happens even if the files changed or deleted are not in the +failed disk. +New added files don't prevent the recovering of the already existing +files. You may only lose the just added files, if they were on the failed +disk. + +This is the reason because SnapRAID is better suited for data that +rarely change. + +Other limitations are: * You have different filesystems for each disk. - Using a RAID you have only a big filesystem. + Using a RAID you have only a big filesystem. * It doesn't stripe data. With RAID you get a speed boost with striping. * It doesn't support realtime recovery. @@ -62,7 +79,7 @@ consider before using it: ================= To use SnapRAID you need first to mount all the disks of your disk -array and select which one to dedicate as redundancy information. +array and select which one to dedicate at the redundancy information. This disk will be dedicated to this pourpuse only, and you should not store any other data on it. @@ -92,7 +109,7 @@ redundancy information. snapraid sync This process will take some hours at best the first time, depending on -the size of the data already present in the data disks. +the size of the data already present in the disks. If the disks are empty the process is immediate. You can stop it at any time pressing Ctrl+C, and at the next run it will start where interrupted. diff --git a/testgen.c b/testgen.c deleted file mode 100644 index e7b6b790..00000000 --- a/testgen.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2011 Andrea Mazzoleni - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "portable.h" - -void gen(int disk, int size) -{ - char path[PATH_MAX]; - char name[PATH_MAX]; - FILE* f; - int i; - int l; - - l = 1 + rand() % 32; - - for(i=0;i