Add thermal protection options: temp_limit and temp_sleep
Some checks failed
Build / build-mac (push) Has been cancelled
Build / build-linux (push) Has been cancelled
Build / build-win (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled

Introduce two new configuration directives to protect disks from overheating:

- temp_limit <TEMPERATURE_CELSIUS>
  Sets the maximum allowed disk temperature. When any disk exceeds this limit,
  SnapRAID stops all operations and spins down the disks.

- temp_sleep <TIME_IN_MINUTES>
  Specifies how long disks remain in standby after a temperature event.
  Defaults to 15 minutes.

These options allow SnapRAID to automatically pause activity and cool down
disks when a temperature threshold is reached, improving data safety and
hardware longevity.
This commit is contained in:
Andrea Mazzoleni 2025-09-21 19:54:10 +02:00
parent b5bbece95e
commit 906d215bf5
23 changed files with 1144 additions and 81 deletions

View file

@ -1298,6 +1298,31 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
/* LCOV_EXCL_STOP */
}
/* thermal control */
if (state_thermal_alarm(state)) {
/* until now is misc */
state_usage_misc(state);
state_progress_stop(state);
/* before spinning down flush all the caches */
ret = state_flush(state, &io, parity_handle, blockcur);
if (ret == -1) {
/* LCOV_EXCL_START */
log_fatal("Stopping at block %u\n", blockcur);
++error;
goto bail;
/* LCOV_EXCL_STOP */
}
state_thermal_cooldown(state);
state_progress_restart(state);
/* drop until now */
state_usage_waste(state);
}
/* autosave */
if ((state->autosave != 0
&& autosavedone >= autosavelimit /* if we have reached the limit */