mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-25 18:40:19 -04:00
Make state_thermal() return 0 on success and -1 on failure
This commit is contained in:
parent
a0c7d69067
commit
2fd94baa05
2 changed files with 21 additions and 7 deletions
|
|
@ -402,9 +402,11 @@ void state_usage_print(struct snapraid_state* state);
|
|||
void state_fscheck(struct snapraid_state* state, const char* ope);
|
||||
|
||||
/**
|
||||
* Measure the temperature of all disks
|
||||
* Measure the temperature of all disks.
|
||||
* Return 0 if thermal information was successfully gathered, -1 if thermal gathering failed, is not supported, or no valid temperature is available.
|
||||
* Individual disks without a valid temperature are ignored as long as at least one disk provides a valid temperature.
|
||||
*/
|
||||
void state_thermal(struct snapraid_state* state, time_t now);
|
||||
int state_thermal(struct snapraid_state* state, time_t now);
|
||||
|
||||
/**
|
||||
* Check if the temperature is outside the operating range
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ struct snapraid_thermal_params fit_thermal_model(const struct snapraid_thermal_p
|
|||
return model;
|
||||
}
|
||||
|
||||
void state_thermal(struct snapraid_state* state, time_t now)
|
||||
int state_thermal(struct snapraid_state* state, time_t now)
|
||||
{
|
||||
tommy_node* i;
|
||||
unsigned j;
|
||||
|
|
@ -126,7 +126,7 @@ void state_thermal(struct snapraid_state* state, time_t now)
|
|||
int ret;
|
||||
|
||||
if (state->thermal_temperature_limit == 0)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
state_devmap(state);
|
||||
|
||||
|
|
@ -186,11 +186,11 @@ void state_thermal(struct snapraid_state* state, time_t now)
|
|||
|
||||
/* on error, just disable thermal gathering */
|
||||
if (ret != 0)
|
||||
goto bail;
|
||||
goto bail_error;
|
||||
|
||||
/* if the list is empty, it's not supported in this platform */
|
||||
if (tommy_list_empty(&low))
|
||||
goto bail;
|
||||
goto bail_error;
|
||||
|
||||
/* report new attribute */
|
||||
state_attr(state, &low);
|
||||
|
|
@ -215,6 +215,7 @@ void state_thermal(struct snapraid_state* state, time_t now)
|
|||
log_tag("thermal:system:final:%d\n", state->thermal_ambient_temperature);
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
int highest_temperature = 0;
|
||||
for (i = tommy_list_head(&low); i != 0; i = i->next) {
|
||||
tommy_node* t;
|
||||
|
|
@ -226,6 +227,8 @@ void state_thermal(struct snapraid_state* state, time_t now)
|
|||
if (temperature < 0)
|
||||
continue;
|
||||
|
||||
++count;
|
||||
|
||||
/* search of the entry */
|
||||
found = 0;
|
||||
for (t = tommy_list_head(&state->thermallist); t != 0; t = t->next) {
|
||||
|
|
@ -293,15 +296,24 @@ void state_thermal(struct snapraid_state* state, time_t now)
|
|||
found->params.rmse, found->params.r_squared, found->params.max_error);
|
||||
}
|
||||
|
||||
/* if no valid temperature was collected, report failure */
|
||||
if (count == 0)
|
||||
goto bail_error;
|
||||
|
||||
/* always update the highest temperature */
|
||||
state->thermal_highest_temperature = highest_temperature;
|
||||
|
||||
log_tag("thermal:highest:%d\n", highest_temperature);
|
||||
log_flush();
|
||||
|
||||
bail:
|
||||
tommy_list_foreach(&high, free);
|
||||
tommy_list_foreach(&low, free);
|
||||
return 0;
|
||||
|
||||
bail_error:
|
||||
tommy_list_foreach(&high, free);
|
||||
tommy_list_foreach(&low, free);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int state_thermal_alarm(struct snapraid_state* state)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue