mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-12-02 21:00:13 -05:00
fix: validate and cap thread and queue counts
- std::stoi threw std::out_of_range for a func.readdir concurrency or queue depth above INT_MAX, e.g. cor:99999999999. Given at mount, mergerfs aborted. Set at runtime through .mergerfs, the daemon shut down and the mount went away, or with process-thread-count>0 the request never got a reply. Parse with str::from, which reports the overflow, and reject the value like any other malformed one. - Reject a readdir queue depth whose product with the concurrency overflows an int, e.g. cor:2147483647:2147483647, instead of wrapping it. - Limit read-thread-count, process-thread-count and the cor/cosr pool size to 64 threads per pool, after resolving automatic and CPU-divided counts, and log a warning when clamping. Resolve negative FUSE counts without overflowing on INT_MIN, and drop the unreachable negative readdir concurrency branch. - process-thread-queue-depth is multiplied by the process thread count. Saturate the product at INT_MAX instead of overflowing. - Correct the docs: cor/cosr counts accept digits only and 0 means the core count, at most 8; a queue depth of 0 means 2 per thread; read-thread-count=0 with process-thread-count=0 is 2 read threads and max(2, cores - 2) process threads, at most 8; the queue limit is depth times process threads, each read thread holding one in-flight buffer of its own. Point at threads.md for how the settings combine. - Document the per-read-thread /dev/fuse clones and their fallback. - tests.cpp covers the overflow cases. Performance: default thread counts are unchanged (8 on hosts with 8 or more cores). Only explicit or CPU-divided counts above 64, which 2.42.0 honored, are reduced.
This commit is contained in:
parent
61597c8dfd
commit
d679fdd265
7 changed files with 143 additions and 44 deletions
|
|
@ -136,25 +136,28 @@ config file.
|
|||
use. When used alone (`process-thread-count=-1`) it sets the number
|
||||
of threads reading and processing FUSE messages. When used together
|
||||
it sets the number of threads reading from FUSE. When set to zero it
|
||||
will attempt to discover and use the number of logical cores. If the
|
||||
thread count is set negative it will look up the number of cores
|
||||
then divide by the absolute value. ie. threads=-2 on an 8 core
|
||||
machine will result in 8 / 2 = 4 threads. There will always be at
|
||||
least 1 thread. If set to -1 in combination with
|
||||
`process-thread-count` then it will try to pick reasonable values
|
||||
based on CPU thread count. NOTE: higher number of threads increases
|
||||
uses the number of logical cores, up to 8, or 2 read threads when
|
||||
`process-thread-count` is enabled as well. If the thread count is set
|
||||
negative it will look up the number of cores then divide by the
|
||||
absolute value. ie. threads=-2 on an 8 core machine will result in
|
||||
8 / 2 = 4 threads. There will always be at least 1 thread and at
|
||||
most 64, including counts resolved from automatic or negative
|
||||
settings. Counts above 64 are clamped with a syslog warning
|
||||
(`LOG_WARNING`). See [threads](threads.md) for how it combines with
|
||||
`process-thread-count`. NOTE: higher number of threads increases
|
||||
parallelism but usually decreases throughput. (default: 0)
|
||||
* **[process-thread-count](threads.md)=INT**: Enables separate thread
|
||||
pool to asynchronously process FUSE requests. In this mode
|
||||
`read-thread-count` refers to the number of threads reading FUSE
|
||||
messages which are dispatched to process threads. -1 means disabled
|
||||
otherwise acts like `read-thread-count`. (default: -1)
|
||||
otherwise acts like `read-thread-count`, including the 64-thread cap
|
||||
and warning when clamped. (default: -1)
|
||||
* **[process-thread-queue-depth](threads.md)=UINT**: Sets the number
|
||||
of requests any single process thread can have queued up at one
|
||||
time. Meaning the total memory usage of the queues is queue depth
|
||||
multiplied by the number of process threads plus read thread
|
||||
count. 0 sets the depth to the same as the process thread
|
||||
count. (default: 2)
|
||||
time. Meaning the queue capacity is the queue depth multiplied by
|
||||
the number of process threads, and each read thread additionally
|
||||
holds one in-flight message buffer. 0 sets the depth to 2. Queue
|
||||
depths are not capped to 64. (default: 2)
|
||||
* **[pin-threads](pin-threads.md)=STR**: Selects a strategy to pin
|
||||
threads to CPUs (default: unset)
|
||||
* **[flush-on-close](flush-on-close.md)=never|always|opened-for-write**:
|
||||
|
|
@ -171,9 +174,13 @@ config file.
|
|||
* **[func.FUNC](functions_categories_policies.md)=POLICY**: Sets the
|
||||
specific FUSE function's policy. See below for the list of value
|
||||
types. Example: **func.getattr=newest**
|
||||
* **[func.readdir](func_readdir.md)=seq|cosr|cor|cosr:INT|cor:INT**:
|
||||
Sets `readdir` policy. INT value sets the number of threads to use
|
||||
for concurrency. (default: seq)
|
||||
* **[func.readdir](func_readdir.md)**: `seq` (default), `cosr[:N[:M]]`,
|
||||
or `cor[:N[:M]]`. `N` (threads) and `M` (queue slots per thread) accept
|
||||
decimal digits only. Values above `INT_MAX` (2147483647) are rejected.
|
||||
Omitted or zero values use the core count (at most 8) for `N` and 2 for `M`. Valid
|
||||
thread counts above 64 are clamped to 64 with a syslog warning; `M` is
|
||||
not capped at 64. If the effective `N * M` exceeds `INT_MAX`, the entire
|
||||
setting is rejected.
|
||||
* **[category.action](functions_categories_policies.md)=POLICY**: Sets
|
||||
policy of all FUSE functions in the action category. (default:
|
||||
epall)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue