[PATCH] fsck: add --workers option to configure worker threads
Nithurshen
nithurshen.dev at gmail.com
Sun Mar 22 19:36:20 AEDT 2026
Hi Utkal,
I've run some tests on your patch.
I compiled fsck.erofs locally, generated a test EROFS image, and passed
various valid and invalid inputs to the new --workers flag (positive
integers, hex, trailing garbage, overflow, and negative numbers).
The happy path works perfectly. The *endptr check correctly catches
trailing garbage, and standard overflows are handled well.
I would suggest changes:
There's a hidden edge case with negative numbers (like --workers=-1)
on 32-bit systems. Because strtoul() is used, a negative number wraps
around to ULONG_MAX. On 64-bit machines, this is safely caught by your
v > UINT_MAX check. However, on 32-bit machines, ULONG_MAX equals
UINT_MAX, meaning -1 will bypass the check and attempt to spawn
4.2 billion threads.
Also, when -EINVAL is returned, fsck silently prints the generic help
menu without explaining what went wrong.
Therefore, in case you decide to send a v2 patch,
1. Switch to strtol() instead of strtoul() so you can explicitly catch
negative numbers or zero (e.g., `if (*endptr || v <= 0 || ...)`).
2. Add an explicit error message (e.g., using erofs_err) before
returning -EINVAL so the user knows their input was invalid.
These are just my opinion, but follow what the lead maintainers say.
Best,
Nithurshen
More information about the Linux-erofs
mailing list