summaryrefslogtreecommitdiff
path: root/lib/sqfs/block_writer.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-16 00:00:40 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-16 00:23:15 +0100
commit8e52ed282e16cc0cc984d077377cd79d0f10308d (patch)
tree60fd399091e03eb489b425718da8445a9a7074a1 /lib/sqfs/block_writer.c
parent285ea3a807d6158b7d3381ad97205e8e43a5c5f4 (diff)
block processor: move sparse block detection into worker thread
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/block_writer.c')
-rw-r--r--lib/sqfs/block_writer.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/lib/sqfs/block_writer.c b/lib/sqfs/block_writer.c
index 63f8c61..73dcb14 100644
--- a/lib/sqfs/block_writer.c
+++ b/lib/sqfs/block_writer.c
@@ -191,14 +191,14 @@ int sqfs_block_writer_write(sqfs_block_writer_t *wr, sqfs_u32 size,
}
}
- if (size != 0) {
+ offset = wr->file->get_size(wr->file);
+ *location = offset;
+
+ if (size != 0 && !(flags & SQFS_BLK_IS_SPARSE)) {
out = size;
if (!(flags & SQFS_BLK_IS_COMPRESSED))
out |= 1 << 24;
- offset = wr->file->get_size(wr->file);
- *location = offset;
-
err = store_block_location(wr, offset, out, checksum);
if (err)
return err;
@@ -226,19 +226,24 @@ int sqfs_block_writer_write(sqfs_block_writer_t *wr, sqfs_u32 size,
}
count = wr->num_blocks - wr->file_start;
- start = deduplicate_blocks(wr, count);
- offset = wr->blocks[start].offset;
-
- *location = offset;
- if (start >= wr->file_start)
- return 0;
- offset = start + count;
- if (offset >= wr->file_start) {
- count = wr->num_blocks - offset;
- wr->num_blocks = offset;
+ if (count == 0) {
+ *location = 0;
} else {
- wr->num_blocks = wr->file_start;
+ start = deduplicate_blocks(wr, count);
+ offset = wr->blocks[start].offset;
+
+ *location = offset;
+ if (start >= wr->file_start)
+ return 0;
+
+ offset = start + count;
+ if (offset >= wr->file_start) {
+ count = wr->num_blocks - offset;
+ wr->num_blocks = offset;
+ } else {
+ wr->num_blocks = wr->file_start;
+ }
}
err = wr->file->truncate(wr->file, wr->start);