fn reclaim(
dir: &Path,
min_free: f64,
min_free_bytes: u64,
) -> Result<Vec<PathBuf>>Expand description
Drop the oldest blocks, across every signal, until the volume is back above
min_free — the ratio and the byte floor both. Returns what was unlinked,
oldest first.
Deleting data the operator did not ask to lose needs both terms to agree: a
small volume trips the ratio first and a large one trips the bytes first, and
either alone is wrong somewhere. See MIN_FREE_BYTES.
They are parameters only so a test can say “pretend the volume is full” without one; the sweep passes the two constants and nothing else ever will.
ponytail: one statfs per unlink and one full scan per sweep that trips.
Both are O(blocks) on a path that only runs when the volume is nearly full,
where the unlink dominates anyway. If a volume ever spends long enough down
here for that to matter, the fix is to stop after freeing a target fraction
in one pass rather than re-measuring per block.