From c067eee9c2e5fd97de7e9d74bfd4521984d23e3e Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 24 May 2020 15:52:01 +0200 Subject: Minor fixes/cleanups in the block processor - Move the inode modifications out of do_block. The inode may be reallocated in parallel by the process_completed_block function, so it is not safe to store the fragment location in the do_block function which is used from the worker threads. - Move the accounting of fragment blocks to the process_completed_block function. Signed-off-by: David Oberhollenzer --- lib/sqfs/block_processor/common.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'lib/sqfs/block_processor/common.c') diff --git a/lib/sqfs/block_processor/common.c b/lib/sqfs/block_processor/common.c index 01f4cce..bd37068 100644 --- a/lib/sqfs/block_processor/common.c +++ b/lib/sqfs/block_processor/common.c @@ -92,6 +92,7 @@ int process_completed_block(sqfs_block_processor_t *proc, sqfs_block_t *blk) location, size); if (err) goto out; + proc->stats.frag_block_count += 1; } else { err = set_block_size(blk->inode, blk->index, size); if (err) @@ -132,13 +133,7 @@ int block_processor_do_block(sqfs_block_t *block, sqfs_compressor_t *cmp, memcpy(block->data + offset, it->data, it->size); block->flags |= (it->flags & SQFS_BLK_DONT_COMPRESS); - - sqfs_inode_set_frag_location(*(it->inode), - block->index, offset); } - - /* XXX: the block itself got promoted from a fragment */ - sqfs_inode_set_frag_location(*(block->inode), block->index, 0); } if (is_zero_block(block->data, block->size)) { @@ -215,7 +210,6 @@ int process_completed_fragment(sqfs_block_processor_t *proc, sqfs_block_t *frag, proc->frag_block->flags &= SQFS_BLK_DONT_COMPRESS; proc->frag_block->flags |= SQFS_BLK_FRAGMENT_BLOCK; proc->frag_block->frag_list = NULL; - proc->stats.frag_block_count += 1; } else { index = proc->frag_block->index; offset = proc->frag_block->size; @@ -231,6 +225,7 @@ int process_completed_fragment(sqfs_block_processor_t *proc, sqfs_block_t *frag, if (err) goto fail_outblk; + sqfs_inode_set_frag_location(*(frag->inode), index, offset); proc->stats.actual_frag_count += 1; return 0; fail: -- cgit v1.2.3