mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Add extra assertions and consistency checks
This commit is contained in:
parent
903ced679f
commit
6b55d2a292
3 changed files with 26 additions and 4 deletions
|
|
@ -287,6 +287,7 @@ endif
|
|||
$(TESTENV) ./mktest$(EXEEXT) generate 1 6 $(CHECKCOUNT) $(CHECKSIZE)
|
||||
echo DUP > bench/disk1/DUP1
|
||||
echo DUP > bench/disk1/DUP2
|
||||
head -c 0 /dev/zero > bench/disk1/ZERO
|
||||
echo --- Some commands with a not empty array
|
||||
# Run a sync using physical offset
|
||||
$(FAILENV) ./snapraid$(EXEEXT) $(CHECKFLAGS_PHYSICAL) -c $(CONF) --test-expect-need-sync diff > output.log
|
||||
|
|
|
|||
|
|
@ -607,6 +607,9 @@ struct snapraid_chunk* chunk_alloc(block_off_t parity_pos, struct snapraid_file*
|
|||
{
|
||||
struct snapraid_chunk* chunk;
|
||||
|
||||
assert(count != 0);
|
||||
assert(file_pos + count <= file->blockmax);
|
||||
|
||||
chunk = malloc_nofail(sizeof(struct snapraid_chunk));
|
||||
chunk->parity_pos = parity_pos;
|
||||
chunk->file = file;
|
||||
|
|
@ -858,6 +861,15 @@ void chunk_parity_check_foreach(void* void_arg, void* void_obj)
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (obj->count == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency in parity count zero for file '%s' at '%u'\n",
|
||||
obj->file->sub, obj->parity_pos);
|
||||
++arg->result;
|
||||
return;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
/* check only if there is a previous block */
|
||||
if (!prev)
|
||||
return;
|
||||
|
|
@ -899,6 +911,15 @@ void chunk_file_check_foreach(void* void_arg, void* void_obj)
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (obj->count == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency in file count zero for file '%s' at '%u'\n",
|
||||
obj->file->sub, obj->file_pos);
|
||||
++arg->result;
|
||||
return;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
/* note that for deleted files, some chunks may be missing */
|
||||
|
||||
/* if the files are different */
|
||||
|
|
@ -1130,7 +1151,7 @@ block_off_t fs_file2par_get_ts(struct snapraid_disk* disk, struct snapraid_chunk
|
|||
chunk = fs_file2chunk_get_ts(disk, fs_last, file, file_pos);
|
||||
if (!chunk) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency when resolving file '%s' at position '%u' in disk '%s'\n", file->sub, file_pos, disk->name);
|
||||
log_fatal("Internal inconsistency when resolving file '%s' at position '%u/%u' in disk '%s'\n", file->sub, file_pos, file->blockmax, disk->name);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1152,7 +1173,7 @@ void fs_allocate(struct snapraid_disk* disk, block_off_t parity_pos, struct snap
|
|||
/* ensure that we are extending the chunk at the end */
|
||||
if (file_pos != chunk->file_pos + chunk->count) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency when allocating file '%s' at position '%u' in the middle of chunk '%u:%u' in disk '%s'\n", file->sub, file_pos, chunk->file_pos, chunk->count, disk->name);
|
||||
log_fatal("Internal inconsistency when allocating file '%s' at position '%u/%u' in the middle of chunk '%u:%u' in disk '%s'\n", file->sub, file_pos, file->blockmax, chunk->file_pos, chunk->count, disk->name);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1173,7 +1194,7 @@ void fs_allocate(struct snapraid_disk* disk, block_off_t parity_pos, struct snap
|
|||
|
||||
if (parity_chunk != chunk || file_chunk != chunk) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency when allocating file '%s' at position '%u' for existing chunk '%u:%u' in disk '%s'\n", file->sub, file_pos, chunk->file_pos, chunk->count, disk->name);
|
||||
log_fatal("Internal inconsistency when allocating file '%s' at position '%u/%u' for existing chunk '%u:%u' in disk '%s'\n", file->sub, file_pos, file->blockmax, chunk->file_pos, chunk->count, disk->name);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ static void scan_file_allocate(struct snapraid_scan* scan, struct snapraid_file*
|
|||
|
||||
/**
|
||||
* Remove the specified file from the parity.
|
||||
* The file is then inserted in the deleted set, and it should no be deallocated.
|
||||
* The file is then inserted in the deleted set, and it should not be deallocated.
|
||||
*/
|
||||
static void scan_file_deallocate(struct snapraid_scan* scan, struct snapraid_file* file)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue