From 4da11411f1491857970c11319fe19c08073b86f9 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Mon, 2 Feb 2026 15:47:30 +0100 Subject: [PATCH] Always get the SMART info after a spinup --- cmdline/device.c | 19 +++++++++++++++++++ cmdline/mingw.c | 15 +++++++++++++++ cmdline/unix.c | 15 +++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/cmdline/device.c b/cmdline/device.c index 7dbc98a6..110c1c29 100644 --- a/cmdline/device.c +++ b/cmdline/device.c @@ -781,6 +781,22 @@ bail: } } +static void state_up(struct snapraid_state* state, tommy_list* low) +{ + tommy_node* i; + + (void)state; + + for (i = tommy_list_head(low); i != 0; i = i->next) { + devinfo_t* devinfo = i->data; + + double afr = smart_afr(devinfo->smart, devinfo->model); + + state_info_log(devinfo); + state_smart_log(devinfo, afr); + } +} + static void state_probe(struct snapraid_state* state, tommy_list* low) { tommy_node* i; @@ -1034,6 +1050,9 @@ void state_device(struct snapraid_state* state, int operation, tommy_list* filte if (operation == DEVICE_PROBE) state_probe(state, &low); + + if (operation == DEVICE_UP) + state_up(state, &low); } tommy_list_foreach(&high, free); diff --git a/cmdline/mingw.c b/cmdline/mingw.c index 8f866cc7..6faa1ef6 100644 --- a/cmdline/mingw.c +++ b/cmdline/mingw.c @@ -3015,6 +3015,21 @@ static void* thread_spinup(void* arg) msg_status("Spunup device '%s' for disk '%s' in %" PRIu64 " ms.\n", devinfo->file, devinfo->name, tick_ms() - start); + /* after the spin up, get SMART info */ + if (devsmart(devinfo->device, devinfo->name, devinfo->smartctl, devinfo->smart, devinfo->info, devinfo->serial, devinfo->family, devinfo->model, devinfo->interf) != 0) { + /* LCOV_EXCL_START */ + return (void*)-1; + /* LCOV_EXCL_STOP */ + } + + /* + * Retrieve some attributes directly from the system. + * + * smartctl intentionally skips queries on devices in standby mode + * to prevent accidentally spinning them up. + */ + devattr(devinfo->device, devinfo->name, devinfo->wfile, devinfo->info, devinfo->serial, devinfo->family, devinfo->model, devinfo->interf); + return 0; } diff --git a/cmdline/unix.c b/cmdline/unix.c index 459c6593..51774f79 100644 --- a/cmdline/unix.c +++ b/cmdline/unix.c @@ -2023,6 +2023,21 @@ static void* thread_spinup(void* arg) msg_status("Spunup device '%s' for disk '%s' in %" PRIu64 " ms.\n", devinfo->file, devinfo->name, tick_ms() - start); + /* after the spin up, get SMART info */ + if (devsmart(devinfo->device, devinfo->name, devinfo->smartctl, devinfo->smart, devinfo->info, devinfo->serial, devinfo->family, devinfo->model, devinfo->interf) != 0) { + /* LCOV_EXCL_START */ + return (void*)-1; + /* LCOV_EXCL_STOP */ + } + + /* + * Retrieve some attributes directly from the system. + * + * smartctl intentionally skips queries on devices in standby mode + * to prevent accidentally spinning them up. + */ + devattr(devinfo->device, devinfo->info, devinfo->serial, devinfo->family, devinfo->model, devinfo->interf); + return 0; #else (void)arg;