mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-03 13:20:28 -05:00
During cooldown keep spinning down any disk that is spun up
This commit is contained in:
parent
b549bffd4c
commit
ac986579d7
5 changed files with 97 additions and 2 deletions
|
|
@ -1350,6 +1350,24 @@ static int devdown(dev_t device, const char* name, const char* smartctl)
|
|||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Spin down a specific device if it's up.
|
||||
*/
|
||||
#if HAVE_LINUX_DEVICE
|
||||
static int devdownifup(dev_t device, const char* name, const char* smartctl, int* power)
|
||||
{
|
||||
*power = POWER_UNKNOWN;
|
||||
|
||||
if (devprobe(device, name, smartctl, power) != 0)
|
||||
return -1;
|
||||
|
||||
if (*power == POWER_ACTIVE)
|
||||
return devdown(device, name, smartctl);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Spin up a specific device.
|
||||
*/
|
||||
|
|
@ -1465,6 +1483,34 @@ static void* thread_spindown(void* arg)
|
|||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Thread for spinning down.
|
||||
*/
|
||||
static void* thread_spindownifup(void* arg)
|
||||
{
|
||||
#if HAVE_LINUX_DEVICE
|
||||
devinfo_t* devinfo = arg;
|
||||
uint64_t start;
|
||||
int power;
|
||||
|
||||
start = tick_ms();
|
||||
|
||||
if (devdownifup(devinfo->device, devinfo->name, devinfo->smartctl, &power) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
return (void*)-1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (power == POWER_ACTIVE)
|
||||
msg_status("Spundown device '%s' for disk '%s' in %" PRIu64 " ms.\n", devinfo->file, devinfo->name, tick_ms() - start);
|
||||
|
||||
return 0;
|
||||
#else
|
||||
(void)arg;
|
||||
return (void*)-1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Thread for getting smart info.
|
||||
*/
|
||||
|
|
@ -1620,6 +1666,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation, int others)
|
|||
case DEVICE_DOWN : func = thread_spindown; break;
|
||||
case DEVICE_SMART : func = thread_smart; break;
|
||||
case DEVICE_PROBE : func = thread_probe; break;
|
||||
case DEVICE_DOWNIFUP : func = thread_spindownifup; break;
|
||||
}
|
||||
|
||||
if (!func)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue