Skip to content

erofs-utils: lib: add error propagation and wait support to erofs_workqueue #41

@mugiwaraluffy56

Description

@mugiwaraluffy56

erofs_workqueue in lib/workqueue.c provides a pthreads-based worker pool currently used by mkfs for parallel compression. the infrastructure is solid but has two gaps that prevent it from being used in fsck for parallel decompression.

the first gap is error propagation. struct erofs_work carries a void (*fn)(struct erofs_work *, void *) callback with no return value, so if a worker fails during decompression there is no way to surface that error back to the caller. an int retval field needs to be added to struct erofs_workqueue and workers need a way to signal failure so the caller can check after draining.

the second gap is a missing wait primitive. erofs_destroy_workqueue() drains all pending jobs and tears down the threads, but there is no erofs_wait_workqueue() that simply blocks until the queue is empty while keeping the workers alive. fsck needs to submit a batch of decompression jobs, wait for them all to finish, check for errors, and then move on, without destroying and recreating the pool each time.

once these two additions land, fsck can be wired up with a -j N / --jobs=N option that allocates the workqueue on startup and feeds decompression jobs into it, which is the first concrete step toward the parallel decompression goal in #33.

expected diff size is around 150-200 lines across lib/workqueue.c, include/erofs/workqueue.h, and fsck/main.c.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions