mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-27 16:48:58 +00:00
73a30178f5
The capacity scan's timeout fallback required the exact prefix (threshold + sample_rate files, default ~200k) to be fully enumerated before any sample existed. Cold-cache HDDs cannot stat that many files inside the 15s budget, so large slow disks — exactly the disks sampling was designed for — always timed out with sampled_count == 0, discarded the accumulated exact-prefix work with a hard error, and re-ran 15s of useless full-disk I/O every 120s (S03). When a sample did exist, the estimate only extrapolated over files the walker had seen, silently under-reporting disks whose tail was never reached (S10). - Enter sampling early: once half the (possibly dynamic) time budget is consumed and the exact prefix hasn't filled, freeze the threshold at the current position so the remaining budget collects samples and the timeout fallback is always reachable. - Compensate the unseen tail: when the scan root is a dedicated mount point (stat st_dev differs from the parent), take the max of the seen-files extrapolation and the filesystem-level used bytes. On shared filesystems (multi-disk dev layouts) statvfs would overcount, so it is not trusted and behavior is unchanged. - sampled_count == 0 at timeout no longer hard-fails when a dedicated mount provides filesystem usage; the exact prefix is kept as a floor. Without any estimator the original error still surfaces. - Extract ScanLimits from env reading so the blocking scanner is parameterizable in tests. Ref: rustfs/backlog#1013 (S03+S10 from audit rustfs/backlog#1010)