summaryrefslogtreecommitdiffstats
path: root/src/server/integrity.c
diff options
context:
space:
mode:
authorSimon Rettberg2015-12-10 16:15:21 +0100
committerSimon Rettberg2015-12-10 16:15:21 +0100
commit6d6455b271ac99c5862691620e1217ed7b3b78b4 (patch)
tree685312fb9a92b70778c8e128f1b1a86c569828cb /src/server/integrity.c
parent[FUSE] Make valgrind happy by initializing memory and not calling close() on -1 (diff)
downloaddnbd3-6d6455b271ac99c5862691620e1217ed7b3b78b4.tar.gz
dnbd3-6d6455b271ac99c5862691620e1217ed7b3b78b4.tar.xz
dnbd3-6d6455b271ac99c5862691620e1217ed7b3b78b4.zip
[SERVER] Nullpad images virtually at runtime instead of padding the actual file
Diffstat (limited to 'src/server/integrity.c')
-rw-r--r--src/server/integrity.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/server/integrity.c b/src/server/integrity.c
index 407bed2..ef909aa 100644
--- a/src/server/integrity.c
+++ b/src/server/integrity.c
@@ -124,11 +124,11 @@ static void* integrity_main(void * data UNUSED)
if ( image == NULL ) continue;
// We have the image. Call image_release() some time
spin_lock( &image->lock );
- if ( image->crc32 != NULL && image->filesize != 0 ) {
+ if ( image->crc32 != NULL && image->realFilesize != 0 ) {
int const blocks[2] = { checkQueue[i].block, -1 };
pthread_mutex_unlock( &integrityQueueLock );
- const uint64_t fileSize = image->filesize;
- const size_t required = IMGSIZE_TO_HASHBLOCKS(image->filesize) * sizeof(uint32_t);
+ const uint64_t fileSize = image->realFilesize;
+ const size_t required = IMGSIZE_TO_HASHBLOCKS(fileSize) * sizeof(uint32_t);
if ( required > bufferSize ) {
bufferSize = required;
if ( buffer != NULL ) free( buffer );
@@ -136,9 +136,7 @@ static void* integrity_main(void * data UNUSED)
}
memcpy( buffer, image->crc32, required );
spin_unlock( &image->lock );
- if ( image_checkBlocksCrc32( image->readFd, (uint32_t*)buffer, blocks, fileSize ) ) {
- //logadd( LOG_DEBUG] CRC check of block %d for %s succeeded :-)\n", blocks[0, ", image->lower_name );
- } else {
+ if ( !image_checkBlocksCrc32( image->readFd, (uint32_t*)buffer, blocks, fileSize ) ) {
logadd( LOG_WARNING, "Hash check for block %d of %s failed!", blocks[0], image->lower_name );
image_updateCachemap( image, blocks[0] * HASH_BLOCK_SIZE, (blocks[0] + 1) * HASH_BLOCK_SIZE, false );
}