mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 02:49:02 -04:00
Reset all SMART attribute fields (raw, norm, worst, thresh) to SMART_UNASSIGNED when ignored
This commit is contained in:
parent
3a3152a36f
commit
97b13557fe
2 changed files with 16 additions and 8 deletions
|
|
@ -533,6 +533,14 @@ static void state_info_log(devinfo_t* devinfo)
|
|||
log_tag("attr:%s:%s:rotationrate:%" PRIu64 "\n", devinfo->file, devinfo->name, devinfo->info[INFO_ROTATION_RATE]);
|
||||
}
|
||||
|
||||
static void smart_attr_clear(struct smart_attr* attr)
|
||||
{
|
||||
attr->raw = SMART_UNASSIGNED;
|
||||
attr->norm = SMART_UNASSIGNED;
|
||||
attr->worst = SMART_UNASSIGNED;
|
||||
attr->thresh = SMART_UNASSIGNED;
|
||||
}
|
||||
|
||||
void state_smart_ignore(struct snapraid_state* state, devinfo_t* devinfo)
|
||||
{
|
||||
int i, j;
|
||||
|
|
@ -541,26 +549,26 @@ void state_smart_ignore(struct snapraid_state* state, devinfo_t* devinfo)
|
|||
for (i = 0; i < SMART_IGNORE_MAX; ++i) {
|
||||
/* global ignore */
|
||||
if (state->smartignore[i].attr_index > 0 && state->smartignore[i].attr_index < 256) {
|
||||
devinfo->smart[state->smartignore[i].attr_index].raw = SMART_UNASSIGNED;
|
||||
smart_attr_clear(&devinfo->smart[state->smartignore[i].attr_index]);
|
||||
}
|
||||
if (state->smartignore[i].attr_name[0] != 0) {
|
||||
for (j = 0; j < SMART_COUNT; ++j) {
|
||||
if (devinfo->smart[j].name[0] != 0
|
||||
&& strcasecmp(devinfo->smart[j].name, state->smartignore[i].attr_name) == 0) {
|
||||
devinfo->smart[j].raw = SMART_UNASSIGNED;
|
||||
smart_attr_clear(&devinfo->smart[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* devinfo ignore */
|
||||
if (devinfo->smartignore[i].attr_index > 0 && devinfo->smartignore[i].attr_index < 256) {
|
||||
devinfo->smart[devinfo->smartignore[i].attr_index].raw = SMART_UNASSIGNED;
|
||||
smart_attr_clear(&devinfo->smart[devinfo->smartignore[i].attr_index]);
|
||||
}
|
||||
if (devinfo->smartignore[i].attr_name[0] != 0) {
|
||||
for (j = 0; j < SMART_COUNT; ++j) {
|
||||
if (devinfo->smart[j].name[0] != 0
|
||||
&& strcasecmp(devinfo->smart[j].name, devinfo->smartignore[i].attr_name) == 0) {
|
||||
devinfo->smart[j].raw = SMART_UNASSIGNED;
|
||||
smart_attr_clear(&devinfo->smart[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -971,19 +971,19 @@ static void test_smart_ignore(void)
|
|||
state_smart_ignore(&state, &devinfo);
|
||||
|
||||
/* Check that ignored attributes are set to SMART_UNASSIGNED */
|
||||
if (devinfo.smart[5].raw != SMART_UNASSIGNED) {
|
||||
if (devinfo.smart[5].raw != SMART_UNASSIGNED || devinfo.smart[5].norm != SMART_UNASSIGNED) {
|
||||
log_fatal(EINTERNAL, "test_smart_ignore: numerical global ignore failed\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (devinfo.smart[197].raw != SMART_UNASSIGNED) {
|
||||
if (devinfo.smart[197].raw != SMART_UNASSIGNED || devinfo.smart[197].norm != SMART_UNASSIGNED) {
|
||||
log_fatal(EINTERNAL, "test_smart_ignore: name global ignore failed\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (devinfo.smart[10].raw != SMART_UNASSIGNED) {
|
||||
if (devinfo.smart[10].raw != SMART_UNASSIGNED || devinfo.smart[10].norm != SMART_UNASSIGNED) {
|
||||
log_fatal(EINTERNAL, "test_smart_ignore: numerical devinfo ignore failed\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (devinfo.smart[20].raw != SMART_UNASSIGNED) {
|
||||
if (devinfo.smart[20].raw != SMART_UNASSIGNED || devinfo.smart[20].norm != SMART_UNASSIGNED) {
|
||||
log_fatal(EINTERNAL, "test_smart_ignore: name devinfo ignore failed\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue