Enforce that full cooling arrives no later than the disk alarm

DISK_RAMP_HIGH_OFFSET below DISK_ALARM_OFFSET means the alarm fires
while there is still cooling left unused. iz-pve0 was tuned that way by
hand (full at limit-2, alarm at limit-5), which would have mailed 3c
before the fans were actually flat out, for every drive class.

check_ramp_ordering() now clamps at startup and logs it, rather than
exiting - a fan controller that refuses to start leaves the fans
wherever they were.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Zeb Hering
2026-08-28 21:49:50 -07:00
parent 02cd1a4004
commit 86f3b0c323
3 changed files with 45 additions and 0 deletions

View File

@@ -29,8 +29,29 @@ DISK_RAMP_HIGH_OFFSET=${DISK_RAMP_HIGH_OFFSET:-8}
# A drive this close to its own limit raises an alarm - the fans are already
# flat out for it and it is still climbing.
#
# That sentence is only true if full fan speed is reached at or before the alarm
# point, i.e. DISK_RAMP_HIGH_OFFSET >= DISK_ALARM_OFFSET. Set the other way round
# the alarm mails you while there is still cooling left unused, which is exactly
# backwards. check_ramp_ordering() enforces it at startup.
DISK_ALARM_OFFSET=${DISK_ALARM_OFFSET:-5}
# True when full cooling is reached no later than the alarm point.
ramp_ordering_ok() {
[ "${1:-$DISK_RAMP_HIGH_OFFSET}" -ge "${2:-$DISK_ALARM_OFFSET}" ]
}
# Clamp rather than refuse to start - a fan controller that exits leaves the
# fans wherever they were, which is worse than a slightly wrong curve.
check_ramp_ordering() {
if ! ramp_ordering_ok; then
echo "/!\\ DISK_RAMP_HIGH_OFFSET ($DISK_RAMP_HIGH_OFFSET) is below DISK_ALARM_OFFSET ($DISK_ALARM_OFFSET):" >&2
echo " the alarm would fire before the fans reach full speed. Raising it to $DISK_ALARM_OFFSET." >&2
log_line "config: raised DISK_RAMP_HIGH_OFFSET $DISK_RAMP_HIGH_OFFSET -> $DISK_ALARM_OFFSET"
DISK_RAMP_HIGH_OFFSET=$DISK_ALARM_OFFSET
fi
}
# Drives report their limit but do not agree on what it means: Samsung and
# Kioxia report a true operating maximum (70), Toshiba and Seagate report 60,
# WD Reds report 85 - the SCT critical limit, not an operating maximum.