diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-24 03:45:30 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-24 04:01:10 +0200 |
commit | 8d9f24a65ef27a52615b3225776632de08462eba (patch) | |
tree | 76d64437a98e94b2749cbb2f48117f9d1b4af947 /lib/sqfs/blk_proc/serial.c | |
parent | 035cbdfe1bc5aea16cbcada5e3c00ecf5ac08c96 (diff) |
Move entire fragment processing from data writer to block processor
So far, this is mostly a direct port from the block processor. The
actual fragment checksumming is not done through the thread pool.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/blk_proc/serial.c')
-rw-r--r-- | lib/sqfs/blk_proc/serial.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/sqfs/blk_proc/serial.c b/lib/sqfs/blk_proc/serial.c index 06c811e..c7ec366 100644 --- a/lib/sqfs/blk_proc/serial.c +++ b/lib/sqfs/blk_proc/serial.c @@ -28,6 +28,7 @@ sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size, proc->devblksz = devblksz; proc->file = file; proc->max_blocks = INIT_BLOCK_COUNT; + proc->frag_list_max = INIT_BLOCK_COUNT; proc->blocks = alloc_array(sizeof(proc->blocks[0]), proc->max_blocks); if (proc->blocks == NULL) { @@ -35,11 +36,21 @@ sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size, return NULL; } + proc->frag_list = alloc_array(sizeof(proc->frag_list[0]), + proc->frag_list_max); + if (proc->frag_list == NULL) { + free(proc->blocks); + free(proc); + return NULL; + } + return proc; } void sqfs_block_processor_destroy(sqfs_block_processor_t *proc) { + free(proc->frag_block); + free(proc->frag_list); free(proc->fragments); free(proc->blocks); free(proc); @@ -48,6 +59,8 @@ void sqfs_block_processor_destroy(sqfs_block_processor_t *proc) int sqfs_block_processor_enqueue(sqfs_block_processor_t *proc, sqfs_block_t *block) { + sqfs_block_t *fragblk = NULL; + if (proc->status != 0) { free(block); return proc->status; @@ -59,6 +72,23 @@ int sqfs_block_processor_enqueue(sqfs_block_processor_t *proc, return proc->status; } + if (block->flags & SQFS_BLK_IS_FRAGMENT) { + block->checksum = crc32(0, block->data, block->size); + + proc->status = handle_fragment(proc, block, &fragblk); + free(block); + + if (proc->status != 0) { + free(fragblk); + return proc->status; + } + + if (fragblk == NULL) + return 0; + + block = fragblk; + } + proc->status = sqfs_block_process(block, proc->cmp, proc->scratch, proc->max_block_size); @@ -71,5 +101,16 @@ int sqfs_block_processor_enqueue(sqfs_block_processor_t *proc, int sqfs_block_processor_finish(sqfs_block_processor_t *proc) { + if (proc->status != 0 || proc->frag_block == NULL) + return proc->status; + + proc->status = sqfs_block_process(proc->frag_block, proc->cmp, + proc->scratch, proc->max_block_size); + + if (proc->status == 0) + proc->status = process_completed_block(proc, proc->frag_block); + + free(proc->frag_block); + proc->frag_block = NULL; return proc->status; } |