summaryrefslogtreecommitdiff
path: root/lib/sqfs/block_processor/fileapi.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-15 22:46:24 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-15 23:05:41 +0100
commit285ea3a807d6158b7d3381ad97205e8e43a5c5f4 (patch)
tree54140627da1bb515cea51f31df65efc0675607ba /lib/sqfs/block_processor/fileapi.c
parent9ac42164bc43bcdd47c0a8e5e59c662b2a136659 (diff)
Move block block accounting to the other end of the block pipeline
This commit moves all of the fragment/block accounting in the block processor over to the writing end of the pipeline. In order to do this, the sparse blocks are allowed to bubble through the pipeline. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/block_processor/fileapi.c')
-rw-r--r--lib/sqfs/block_processor/fileapi.c23
1 files changed, 3 insertions, 20 deletions
diff --git a/lib/sqfs/block_processor/fileapi.c b/lib/sqfs/block_processor/fileapi.c
index dbe3cf2..7ca189e 100644
--- a/lib/sqfs/block_processor/fileapi.c
+++ b/lib/sqfs/block_processor/fileapi.c
@@ -49,38 +49,22 @@ int sqfs_block_processor_begin_file(sqfs_block_processor_t *proc,
proc->inode = inode;
proc->blk_flags = flags | SQFS_BLK_FIRST_BLOCK;
- proc->blk_index = 0;
proc->blk_current = NULL;
return 0;
}
static int flush_block(sqfs_block_processor_t *proc, sqfs_block_t *block)
{
- block->index = proc->blk_index++;
block->flags = proc->blk_flags;
block->inode = proc->inode;
if (is_zero_block(block->data, block->size)) {
- sqfs_inode_make_extended(proc->inode);
- proc->inode->data.file_ext.sparse += block->size;
- proc->inode->num_file_blocks += 1;
- proc->inode->extra[block->index] = 0;
- free(block);
-
- proc->stats.sparse_block_count += 1;
- return 0;
- }
-
- if (block->size < proc->max_block_size &&
- !(block->flags & SQFS_BLK_DONT_FRAGMENT)) {
+ block->flags |= SQFS_BLK_IS_SPARSE;
+ } else if (block->size < proc->max_block_size &&
+ !(block->flags & SQFS_BLK_DONT_FRAGMENT)) {
block->flags |= SQFS_BLK_IS_FRAGMENT;
-
- proc->stats.total_frag_count += 1;
} else {
- proc->inode->num_file_blocks += 1;
proc->blk_flags &= ~SQFS_BLK_FIRST_BLOCK;
-
- proc->stats.data_block_count += 1;
}
return enqueue_block(proc, block);
@@ -162,6 +146,5 @@ int sqfs_block_processor_end_file(sqfs_block_processor_t *proc)
proc->inode = NULL;
proc->blk_flags = 0;
- proc->blk_index = 0;
return 0;
}