From 67e4896671a8f39fdb904bfae69671167458c223 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sun, 21 Dec 2025 17:31:35 +0100 Subject: [PATCH] Output the power mode with the attr: tag like other attributes --- cmdline/mingw.c | 15 ++++++----- cmdline/unix.c | 11 ++++---- doc/snapraid_log.1 | 62 +++++++++++++++++++++--------------------- doc/snapraid_log.d | 64 +++++++++++++++++++++++--------------------- doc/snapraid_log.txt | 64 +++++++++++++++++++++++--------------------- 5 files changed, 113 insertions(+), 103 deletions(-) diff --git a/cmdline/mingw.c b/cmdline/mingw.c index f4b69295..4731fb79 100644 --- a/cmdline/mingw.c +++ b/cmdline/mingw.c @@ -2661,14 +2661,17 @@ retry: } if (ret == 0) { - log_tag("device:%s:%s:active\n", file, name); + log_tag("attr:%s:%s:power:active\n", file, name); *power = POWER_ACTIVE; } else if (ret == 3) { - log_tag("device:%s:%s:standby\n", file, name); + log_tag("attr:%s:%s:power:standby\n", file, name); *power = POWER_STANDBY; } else { - log_tag("device:%s:%s:unknown\n", file, name); - *power = POWER_UNKNOWN; + /* LCOV_EXCL_START */ + log_tag("device:%s:%s:exit:%d\n", file, name, ret); + log_fatal("Failed to run '%s' with return code %xh.\n", u16tou8(conv_buf, cmd), ret); + return -1; + /* LCOV_EXCL_STOP */ } return 0; @@ -2758,7 +2761,7 @@ retry: /* LCOV_EXCL_STOP */ } - log_tag("device:%s:%s:down\n", file, name); + log_tag("attr:%s:%s:power:down\n", file, name); return 0; } @@ -2841,7 +2844,7 @@ static int devup(uint64_t device, const char* name, const char* wfile) VirtualFree(buffer, 0, MEM_RELEASE); - log_tag("device:%s:%s:up\n", file, name); + log_tag("attr:%s:%s:power:up\n", file, name); return 0; } diff --git a/cmdline/unix.c b/cmdline/unix.c index 83115407..ee7b1417 100644 --- a/cmdline/unix.c +++ b/cmdline/unix.c @@ -1221,7 +1221,7 @@ static int devsmart(dev_t device, const char* name, const char* smartctl, uint64 if (!WIFEXITED(ret)) { /* LCOV_EXCL_START */ - log_tag("device:%s:%s:error:abort\n", file, name); + log_tag("device:%s:%s:abort\n", file, name); log_fatal("Failed to run '%s' (not exited).\n", cmd); return -1; /* LCOV_EXCL_STOP */ @@ -1314,11 +1314,12 @@ static int devprobe(dev_t device, const char* name, const char* smartctl, int* p return -1; /* LCOV_EXCL_STOP */ } + if (WEXITSTATUS(ret) == 0) { - log_tag("device:%s:%s:active\n", file, name); + log_tag("attr:%s:%s:power:active\n", file, name); *power = POWER_ACTIVE; } else if (WEXITSTATUS(ret) == 3) { - log_tag("device:%s:%s:standby\n", file, name); + log_tag("attr:%s:%s:power:standby\n", file, name); *power = POWER_STANDBY; } else { /* LCOV_EXCL_START */ @@ -1413,7 +1414,7 @@ static int devdown(dev_t device, const char* name, const char* smartctl) /* LCOV_EXCL_STOP */ } - log_tag("device:%s:%s:down\n", file, name); + log_tag("attr:%s:%s:power:down\n", file, name); return 0; } @@ -1494,7 +1495,7 @@ static int devup(dev_t device, const char* name) /* LCOV_EXCL_STOP */ } - log_tag("device:%s:%s:up\n", file, name); + log_tag("attr:%s:%s:power:up\n", file, name); free(buf); return 0; diff --git a/doc/snapraid_log.1 b/doc/snapraid_log.1 index 5733f929..aa15ceab 100644 --- a/doc/snapraid_log.1 +++ b/doc/snapraid_log.1 @@ -512,8 +512,9 @@ device. .HP 4 .I [/] The configured name of the disk. -In case of multiple splits, the splits after the first -one have an extension \`/N\`, where N starts from 1. +In case of split parity, the parity name is followed +by \`/N\` to indicate the split number, where N starts +from 0. The \`/0\` is always omitted. .HP 4 .I The unique device ID (uint64). @@ -1440,9 +1441,10 @@ Note that a \`\` may be associated with more \`\`, in case the logical disk uses more physical disks. In such a case, you\'ll see multiple tags for the same \`\` but with different \`\`. -.SS SMART Attributes -Tags logging specific disk identification and raw SMART attribute -values. +In case of split parity, the parity name is followed by \`/N\` to indicate +the split number, where N starts from 0. The \`/0\` is always omitted. +.SS Attributes +Tags logging specific disk identification and attribute values. .TP .B smart::[/] Logs the start of the SMART report for a device. @@ -1454,8 +1456,9 @@ The file path of the device (e.g., /dev/sdb). .HP 4 .I [/] The configured name of the disk. -In case of multiple splits, the splits after the first -one have an extension \`/N\`, where N starts from 1. +In case of split parity, the parity name is followed +by \`/N\` to indicate the split number, where N starts +from 0. The \`/0\` is always omitted. .PD .RE .TP @@ -1568,6 +1571,22 @@ The raw attribute value (uint64, decimal). The raw attribute value (uint64, hexadecimal). .PD .RE +.TP +.B attr::[/]:power:active +Logs that the device was confirmed to be in an active power +state after a status probe. +.TP +.B attr::[/]:power:standby +Logs that the device was confirmed to be in a standby/spun\-down +state. +.TP +.B attr::[/]:power:up +Logs a successful spin\-up operation via direct O_DIRECT +read. +.TP +.B attr::[/]:power:down +Logs a successful spin\-down operation initiated via the +smartctl command. .SS Summary Tags logging the overall failure probabilities for the array. .TP @@ -1590,13 +1609,10 @@ the next year (double). .RE .SH DEVICE STATUS TAGS These tags log the lifecycle of hardware interactions and external -command execution. They are primarily output during the \`up\` -(spin\-up), \`down\` (spin\-down), and \`probe\` (power state check) -commands. +command execution with the \`smartctl\` command. .TP -.B device::[/]:active -Logs that the device was confirmed to be in an active power -state after a status probe. +.B device::[/]:shell +Logs a failure in the command shell execution environment. .RS 4 .PD 0 .HP 4 @@ -1605,26 +1621,12 @@ The system path to the device node. .HP 4 .I [/] The configured name of the disk. -In case of multiple splits, the splits after the first -one have an extension \`/N\`, where N starts from 1. +In case of split parity, the parity name is followed +by \`/N\` to indicate the split number, where N starts +from 0. The \`/0\` is always omitted. .PD .RE .TP -.B device::[/]:standby -Logs that the device was confirmed to be in a standby/spun\-down -state. -.TP -.B device::[/]:up -Logs a successful spin\-up operation via direct O_DIRECT -read. -.TP -.B device::[/]:down -Logs a successful spin\-down operation initiated via the -smartctl command. -.TP -.B device::[/]:shell -Logs a failure in the command shell execution environment. -.TP .B device::[/]:error: Logs a low\-level system error during direct file operations. This is triggered when open(), read(), or close() diff --git a/doc/snapraid_log.d b/doc/snapraid_log.d index 585dba16..65541e08 100644 --- a/doc/snapraid_log.d +++ b/doc/snapraid_log.d @@ -345,8 +345,9 @@ Thermal Tags device. [/] - The configured name of the disk. - In case of multiple splits, the splits after the first - one have an extension `/N`, where N starts from 1. + In case of split parity, the parity name is followed + by `/N` to indicate the split number, where N starts + from 0. The `/0` is always omitted. - The unique device ID (uint64). - The current temperature read from the disk in degrees Celsius. @@ -921,18 +922,20 @@ Command Smart Tags in case the logical disk uses more physical disks. In such a case, you'll see multiple tags for the same `` but with different ``. + In case of split parity, the parity name is followed by `/N` to indicate + the split number, where N starts from 0. The `/0` is always omitted. - SMART Attributes - Tags logging specific disk identification and raw SMART attribute - values. + Attributes + Tags logging specific disk identification and attribute values. =smart::[/] Logs the start of the SMART report for a device. - The file path of the device (e.g., /dev/sdb). [/] - The configured name of the disk. - In case of multiple splits, the splits after the first - one have an extension `/N`, where N starts from 1. + In case of split parity, the parity name is followed + by `/N` to indicate the split number, where N starts + from 0. The `/0` is always omitted. =attr::[/]:serial: Logs the disk's serial number. @@ -991,6 +994,22 @@ Command Smart Tags - The raw attribute value (uint64, decimal). - The raw attribute value (uint64, hexadecimal). + =attr::[/]:power:active + Logs that the device was confirmed to be in an active power + state after a status probe. + + =attr::[/]:power:standby + Logs that the device was confirmed to be in a standby/spun-down + state. + + =attr::[/]:power:up + Logs a successful spin-up operation via direct O_DIRECT + read. + + =attr::[/]:power:down + Logs a successful spin-down operation initiated via the + smartctl command. + Summary Tags logging the overall failure probabilities for the array. @@ -1005,34 +1024,17 @@ Command Smart Tags Device Status Tags These tags log the lifecycle of hardware interactions and external - command execution. They are primarily output during the `up` - (spin-up), `down` (spin-down), and `probe` (power state check) - commands. - - =device::[/]:active - Logs that the device was confirmed to be in an active power - state after a status probe. - - - The system path to the device node. - [/] - The configured name of the disk. - In case of multiple splits, the splits after the first - one have an extension `/N`, where N starts from 1. - - =device::[/]:standby - Logs that the device was confirmed to be in a standby/spun-down - state. - - =device::[/]:up - Logs a successful spin-up operation via direct O_DIRECT - read. - - =device::[/]:down - Logs a successful spin-down operation initiated via the - smartctl command. + command execution with the `smartctl` command. =device::[/]:shell Logs a failure in the command shell execution environment. + - The system path to the device node. + [/] - The configured name of the disk. + In case of split parity, the parity name is followed + by `/N` to indicate the split number, where N starts + from 0. The `/0` is always omitted. + =device::[/]:error: Logs a low-level system error during direct file operations. This is triggered when open(), read(), or close() diff --git a/doc/snapraid_log.txt b/doc/snapraid_log.txt index 9ac09fcd..316d7490 100644 --- a/doc/snapraid_log.txt +++ b/doc/snapraid_log.txt @@ -363,8 +363,9 @@ disk access. device. [/] - The configured name of the disk. - In case of multiple splits, the splits after the first - one have an extension `/N`, where N starts from 1. + In case of split parity, the parity name is followed + by `/N` to indicate the split number, where N starts + from 0. The `/0` is always omitted. - The unique device ID (uint64). - The current temperature read from the disk in degrees Celsius. @@ -963,18 +964,20 @@ Note that a `` may be associated with more ``, in case the logical disk uses more physical disks. In such a case, you'll see multiple tags for the same `` but with different ``. +In case of split parity, the parity name is followed by `/N` to indicate +the split number, where N starts from 0. The `/0` is always omitted. ----- 14.0.1 SMART Attributes ---- -Tags logging specific disk identification and raw SMART attribute -values. +---- 14.0.1 Attributes ---- +Tags logging specific disk identification and attribute values. smart::[/] Logs the start of the SMART report for a device. - The file path of the device (e.g., /dev/sdb). [/] - The configured name of the disk. - In case of multiple splits, the splits after the first - one have an extension `/N`, where N starts from 1. + In case of split parity, the parity name is followed + by `/N` to indicate the split number, where N starts + from 0. The `/0` is always omitted. attr::[/]:serial: Logs the disk's serial number. @@ -1033,6 +1036,22 @@ values. - The raw attribute value (uint64, decimal). - The raw attribute value (uint64, hexadecimal). + attr::[/]:power:active + Logs that the device was confirmed to be in an active power + state after a status probe. + + attr::[/]:power:standby + Logs that the device was confirmed to be in a standby/spun-down + state. + + attr::[/]:power:up + Logs a successful spin-up operation via direct O_DIRECT + read. + + attr::[/]:power:down + Logs a successful spin-down operation initiated via the + smartctl command. + ---- 14.0.2 Summary ---- Tags logging the overall failure probabilities for the array. @@ -1050,34 +1069,17 @@ Tags logging the overall failure probabilities for the array. ===================== These tags log the lifecycle of hardware interactions and external -command execution. They are primarily output during the `up` -(spin-up), `down` (spin-down), and `probe` (power state check) -commands. - - device::[/]:active - Logs that the device was confirmed to be in an active power - state after a status probe. - - - The system path to the device node. - [/] - The configured name of the disk. - In case of multiple splits, the splits after the first - one have an extension `/N`, where N starts from 1. - - device::[/]:standby - Logs that the device was confirmed to be in a standby/spun-down - state. - - device::[/]:up - Logs a successful spin-up operation via direct O_DIRECT - read. - - device::[/]:down - Logs a successful spin-down operation initiated via the - smartctl command. +command execution with the `smartctl` command. device::[/]:shell Logs a failure in the command shell execution environment. + - The system path to the device node. + [/] - The configured name of the disk. + In case of split parity, the parity name is followed + by `/N` to indicate the split number, where N starts + from 0. The `/0` is always omitted. + device::[/]:error: Logs a low-level system error during direct file operations. This is triggered when open(), read(), or close()