aboutsummaryrefslogtreecommitdiff
path: root/lib/sqfs/block_processor
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-03-24 13:59:12 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-03-24 14:05:18 +0100
commit14d0d4d55ed579c471ec24c03cb3808d4d721a79 (patch)
tree2857fa7b8c00b2fe72919b34ed04256ad4ffb737 /lib/sqfs/block_processor
parentbee01b78fa0199a6568cc88b0cfdb5611504c3e0 (diff)
Fix block processor queue accounting
Dequeuing won't work if we have a backlog of 1 or 2 and the blocks are used for internal buffering. Take that into account, similar to the sync code. Also bump the minimum backlog to 3, just to make absolutely sure we cannot run into a dequeue loop trying to allocate a block. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/block_processor')
-rw-r--r--lib/sqfs/block_processor/backend.c10
-rw-r--r--lib/sqfs/block_processor/block_processor.c4
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/sqfs/block_processor/backend.c b/lib/sqfs/block_processor/backend.c
index f81304b..35e5b4c 100644
--- a/lib/sqfs/block_processor/backend.c
+++ b/lib/sqfs/block_processor/backend.c
@@ -298,6 +298,16 @@ int dequeue_block(sqfs_block_processor_t *proc)
if (proc->backlog < backlog_old)
break;
+ if ((proc->backlog == 1) &&
+ (proc->frag_block != NULL || proc->blk_current != NULL)) {
+ break;
+ }
+
+ if ((proc->backlog == 2) &&
+ proc->frag_block != NULL && proc->blk_current != NULL) {
+ break;
+ }
+
blk = proc->pool->dequeue(proc->pool);
if (blk == NULL) {
diff --git a/lib/sqfs/block_processor/block_processor.c b/lib/sqfs/block_processor/block_processor.c
index 8303dce..de177cd 100644
--- a/lib/sqfs/block_processor/block_processor.c
+++ b/lib/sqfs/block_processor/block_processor.c
@@ -278,8 +278,8 @@ int sqfs_block_processor_create_ex(const sqfs_block_processor_desc_t *desc,
((sqfs_object_t *)proc)->destroy = block_processor_destroy;
/* we need at least one current data block + one fragment block */
- if (proc->max_backlog < 2)
- proc->max_backlog = 2;
+ if (proc->max_backlog < 3)
+ proc->max_backlog = 3;
/* create the thread pool */
proc->pool = thread_pool_create(desc->num_workers, process_block);