zpool: Add slot power control, print power status

Add `zpool` flags to control the slot power to drives.  This assumes
your SAS or NVMe enclosure supports slot power control via sysfs.

The new `--power` flag is added to `zpool offline|online|clear`:

    zpool offline --power <pool> <device>    Turn off device slot power
    zpool online --power <pool> <device>     Turn on device slot power
    zpool clear --power <pool> [device]      Turn on device slot power

If the ZPOOL_AUTO_POWER_ON_SLOT env var is set, then the '--power'
option is automatically implied for `zpool online` and `zpool clear`
and does not need to be passed.

zpool status also gets a --power option to print the slot power status.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Mart Frauenlob <AllKind@fastest.cc>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #15662
This commit is contained in:
Tony Hutter
2023-12-21 10:53:16 -08:00
committed by GitHub
parent 6930ecbb75
commit a9520e6e59
16 changed files with 875 additions and 65 deletions
+18 -1
View File
@@ -444,7 +444,7 @@ rpool 14.6G 54.9G 4 55 250K 2.69M
.Ed
.
.Sh ENVIRONMENT VARIABLES
.Bl -tag -compact -width "ZPOOL_IMPORT_UDEV_TIMEOUT_MS"
.Bl -tag -compact -width "ZPOOL_STATUS_NON_NATIVE_ASHIFT_IGNORE"
.It Sy ZFS_ABORT
Cause
.Nm
@@ -456,6 +456,23 @@ Use ANSI color in
and
.Nm zpool Cm iostat
output.
.It Sy ZPOOL_AUTO_POWER_ON_SLOT
Automatically attempt to turn on the drives enclosure slot power to a drive when
running the
.Nm zpool Cm online
or
.Nm zpool Cm clear
commands.
This has the same effect as passing the
.Fl -power
option to those commands.
.It Sy ZPOOL_POWER_ON_SLOT_TIMEOUT_MS
The maximum time in milliseconds to wait for a slot power sysfs value
to return the correct value after writing it.
For example, after writing "on" to the sysfs enclosure slot power_control file,
it can take some time for the enclosure to power down the slot and return
"on" if you read back the 'power_control' value.
Defaults to 30 seconds (30000ms) if not set.
.It Sy ZPOOL_IMPORT_PATH
The search path for devices or files to use with the pool.
This is a colon-separated list of directories in which