Skip to main content

Module disk_guard

Module disk_guard 

Source
Expand description

Keep rws from filling a disk (18.15.0): before writing to a file it keeps growing — the access log, the disk cache — rws asks has_room. Below RWS_CONFIG_MIN_FREE_DISK free on that file’s filesystem the write is skipped (and counted) until space comes back: a full disk costs log lines and cache entries, never the server or whatever shares the disk with it.

RWS_CONFIG_MIN_FREE_DISK: a size (2G, 500M) or a share of the filesystem (10%); unset or empty means the larger of 1% and 1 GiB (the space counted is what an unprivileged process may use, so the root reserve most filesystems keep is already set aside); 0 turns the guard off. Free space is read (statvfs) at most every RECHECK per directory. One line is logged when a directory runs low and one when it recovers.

Constants§

RECHECK
How long a free-space reading is reused.
RWS_CONFIG_MIN_FREE_DISK
RWS_CONFIG_MIN_FREE_DISK.

Functions§

has_room
Whether there’s room to keep writing to file (or into the directory file). true when the guard is off or the space can’t be read.
status
Every directory checked so far: (directory, free bytes, total bytes, low), sorted.