In fixing not recoverable files are renamed adding the ".unrecoverable" extension.

This commit is contained in:
Andrea Mazzoleni 2011-10-10 20:42:52 +02:00
parent 191dcdf3d4
commit 966bdf75ad
10 changed files with 62 additions and 17 deletions

View file

@ -24,6 +24,8 @@ SnapRAID HISTORY
* Added a new option '--find-by-name' to allow to sync using only the
file path and not the inode. This is useful to avoid long sync
when you replace one disk with another copying manually the files.
* If 'fix' cannot recover a file, it's renamed adding the '.unrecoverable'
extension.
1.6 2011/9 - THIS UPDATE IS HIGHLY RECOMMENDED!
===============================================

View file

@ -157,7 +157,7 @@ check-local:
mkdir test/disk1
rm -r test/disk2
mkdir test/disk2
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self --test-expect-unrecoverable -c $(srcdir)/test-raid5.conf check 2>> test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self --test-expect-unrecoverable -c $(srcdir)/test-raid5.conf fix 2>> test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self --test-expect-recoverable -c $(srcdir)/test-raid6.conf check 2>> test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -c $(srcdir)/test-raid6.conf fix 2>> test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -c $(srcdir)/test-raid5.conf check
@ -204,7 +204,7 @@ check-local:
rm -r test/disk2/_b
rm -r test/disk3/_a
rm -r test/disk3/_b
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self --test-expect-unrecoverable -c $(srcdir)/test-raid5.conf check 2>> test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self --test-expect-unrecoverable -c $(srcdir)/test-raid5.conf fix 2>> test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self --test-expect-recoverable -c $(srcdir)/test-raid6.conf check 2>> test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -c $(srcdir)/test-raid6.conf fix 2>> test.log
$(TESTENV) ./snapraid$(EXEEXT) $(CHECKFLAGS) --test-skip-self -c $(srcdir)/test-raid6.conf check

29
TODO
View file

@ -7,20 +7,17 @@ This is the list of TODO items for SnapRAID.
* When scanning, ensure that each file is in the expected disk.
* If fix fails for unrecoverable parts, rename such files adding ".unrecoverable".
* Check and fix also empty files.
* Check and fix also empty file.
* When fixing, before overwriting the present file, make a copy of it just in
case that the original file cannot be completely recovered.
We can always open files in read-only mode, if a write is required, we close it,
rename it to with a .bak extension, and rewrite it up to the required size.
The same for symlink if a file with the same name exist or viceversa.
* Put a note about configuring readahead size in Linux to improve performance.
Check https://sourceforge.net/projects/snapraid/forums/forum/1677233/topic/4747452/index/page/1
- v1.8
* Check why saving the content files is so slow. fprintf() is the bottleneck.
* Save all the content files in parallel using multiple threads.
* Put the content files in the data disks in the default configuration file.
* Easy way to find duplicates using the computed hash.
@ -37,6 +34,11 @@ in Unix files starting with '.'.
* Remove the old MD5 support.
* A new 'init' command to differentiate the first 'sync' operation.
This 'init' will work also without a content file, and parity files.
Instead 'sync' will require all of them.
This will also help when running with the parity filesystem unmounted.
* Implement an "undelete" command to recover missing files, without the
integrity check of the existing ones.
It should restore only missing files, without recovering modified ones
@ -45,6 +47,17 @@ or check validity of data of existing ones.
* Rename sync->backup and fix->restore. It seems to me a naming expressing
better the meaning of the commands. But not yet sure.
* When fixing, before overwriting the present file, make a copy of it just in
case that the original file cannot be completely recovered.
We can always open files in read-only mode, if a write is required, we close it,
rename it to with a .bak extension, and rewrite it up to the required size.
The same for symlink if a file with the same name exist or viceversa.
* Triple parity also called RAID-TP. We can implement it in a compatible way
with the existing RAID-5 and RAID-6 definining a new r-parity file.
See http://blogs.oracle.com/ahl/entry/triple_parity_raid_z and
http://thread.gmane.org/gmane.linux.raid/34195/focus=34236
* Allow to filter the files to check/fix based on the drive where they reside.
* Filtered out files should be opened in read-only mode.

29
check.c
View file

@ -552,10 +552,31 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
/* nothing to do */
continue;
}
/* if the file is not fixed or if it's not fixable */
if (!file_flag_has(handle[j].file, FILE_IS_FIXED)
|| file_flag_has(handle[j].file, FILE_IS_DAMAGED)) {
/* if the file is damaged, meaning that a fix failed */
if (file_flag_has(handle[j].file, FILE_IS_DAMAGED)) {
/* rename it */
char path_from[PATH_MAX];
char path_to[PATH_MAX];
pathprint(path_from, sizeof(path_from), "%s%s", handle[j].disk->dir, handle[j].file->sub);
pathprint(path_to, sizeof(path_to), "%s%s.unrecoverable", handle[j].disk->dir, handle[j].file->sub);
ret = rename(path_from, path_to);
if (ret != 0) {
fprintf(stderr, "Error renaming '%s' to '%s'. %s.\n", path_from, path_to, strerror(errno));
fprintf(stderr, "WARNING! Without a working data disk, it isn't possible to fix errors on it.\n");
printf("Stopping at block %u\n", i);
++unrecoverable_error;
goto bail;
}
/* and do not set the time */
continue;
}
/* if the file is not fixed */
if (!file_flag_has(handle[j].file, FILE_IS_FIXED)) {
/* nothing to do */
continue;
}

View file

@ -318,6 +318,9 @@ disk array at the previous \(a"sync\(a" command.
After a successful \(a"fix\(a", you should also run a \(a"sync\(a"
command to update the new state of the files.
.PP
All the files that cannot be fixed are renamed adding
the \(cq.unrecoverable\(cq extension.
.PP
The \(a"content\(a" file is NOT modified.
The \(a"parity\(a" and \(a"q\(hyparity\(a" files are modified if necessary.
The files in the array are modified if necessary.

View file

@ -207,6 +207,9 @@ Commands
After a successful "fix", you should also run a "sync"
command to update the new state of the files.
All the files that cannot be fixed are renamed adding
the '.unrecoverable' extension.
The "content" file is NOT modified.
The "parity" and "q-parity" files are modified if necessary.
The files in the array are modified if necessary.

View file

@ -231,6 +231,9 @@ disk array at the previous "sync" command.
After a successful "fix", you should also run a "sync"
command to update the new state of the files.
All the files that cannot be fixed are renamed adding
the '.unrecoverable' extension.
The "content" file is NOT modified.
The "parity" and "q-parity" files are modified if necessary.
The files in the array are modified if necessary.

View file

@ -5,4 +5,4 @@ content test/p-content
disk d1 test/disk1/
disk d2 test/disk2/
disk d3 test/disk3/
exclude *.unrecoverable

View file

@ -6,4 +6,4 @@ content test/p-content
content test/q-content
disk d1 test/disk1/
disk d3 test/disk3/
exclude *.unrecoverable

View file

@ -7,4 +7,4 @@ content test/q-content
disk d1 test/disk1/
disk d2 test/disk2/
disk d3 test/disk3/
exclude *.unrecoverable