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
parent 59112ca27d
commit 69142125d7
16 changed files with 875 additions and 65 deletions
+11
View File
@@ -36,6 +36,7 @@
.Sh SYNOPSIS
.Nm zpool
.Cm clear
.Op Fl -power
.Ar pool
.Oo Ar device Oc Ns …
.
@@ -52,6 +53,16 @@ Pools with
enabled which have been suspended cannot be resumed.
While the pool was suspended, it may have been imported on
another host, and resuming I/O could result in pool damage.
.Bl -tag -width Ds
.It Fl -power
Power on the devices's slot in the storage enclosure and wait for the device
to show up before attempting to clear errors.
This is done on all the devices specified.
Alternatively, you can set the
.Sy ZPOOL_AUTO_POWER_ON_SLOT
environment variable to always enable this behavior.
Note: This flag currently works on Linux only.
.El
.
.Sh SEE ALSO
.Xr zdb 8 ,
+15 -3
View File
@@ -36,12 +36,13 @@
.Sh SYNOPSIS
.Nm zpool
.Cm offline
.Op Fl ft
.Op Fl Sy -power Ns | Ns Op Fl Sy ft
.Ar pool
.Ar device Ns …
.Nm zpool
.Cm online
.Op Fl e
.Op Fl Sy -power
.Op Fl Sy e
.Ar pool
.Ar device Ns …
.
@@ -50,7 +51,7 @@
.It Xo
.Nm zpool
.Cm offline
.Op Fl ft
.Op Fl Sy -power Ns | Ns Op Fl Sy ft
.Ar pool
.Ar device Ns …
.Xc
@@ -60,6 +61,9 @@ While the
is offline, no attempt is made to read or write to the device.
This command is not applicable to spares.
.Bl -tag -width Ds
.It Fl -power
Power off the device's slot in the storage enclosure.
This flag currently works on Linux only
.It Fl f
Force fault.
Instead of offlining the disk, put it into a faulted state.
@@ -73,6 +77,7 @@ Upon reboot, the specified physical device reverts to its previous state.
.It Xo
.Nm zpool
.Cm online
.Op Fl -power
.Op Fl e
.Ar pool
.Ar device Ns …
@@ -80,6 +85,13 @@ Upon reboot, the specified physical device reverts to its previous state.
Brings the specified physical device online.
This command is not applicable to spares.
.Bl -tag -width Ds
.It Fl -power
Power on the device's slot in the storage enclosure and wait for the device
to show up before attempting to online it.
Alternatively, you can set the
.Sy ZPOOL_AUTO_POWER_ON_SLOT
environment variable to always enable this behavior.
This flag currently works on Linux only
.It Fl e
Expand the device to use all available space.
If the device is part of a mirror or raidz then all devices must be expanded
+2
View File
@@ -57,6 +57,8 @@ and the estimated time to completion.
Both of these are only approximate, because the amount of data in the pool and
the other workloads on the system can change.
.Bl -tag -width Ds
.It Fl -power
Display vdev enclosure slot power status (on or off).
.It Fl c Op Ar SCRIPT1 Ns Oo , Ns Ar SCRIPT2 Oc Ns …
Run a script (or scripts) on each vdev and include the output as a new column
in the
+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