mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 11:18:52 +03:00
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:
committed by
Brian Behlendorf
parent
6b33ae072c
commit
0bc841fb59
@@ -2808,6 +2808,9 @@ zpool_vdev_is_interior(const char *name)
|
||||
return (B_FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Lookup the nvlist for a given vdev.
|
||||
*/
|
||||
nvlist_t *
|
||||
zpool_find_vdev(zpool_handle_t *zhp, const char *path, boolean_t *avail_spare,
|
||||
boolean_t *l2cache, boolean_t *log)
|
||||
@@ -2815,6 +2818,7 @@ zpool_find_vdev(zpool_handle_t *zhp, const char *path, boolean_t *avail_spare,
|
||||
char *end;
|
||||
nvlist_t *nvroot, *search, *ret;
|
||||
uint64_t guid;
|
||||
boolean_t __avail_spare, __l2cache, __log;
|
||||
|
||||
verify(nvlist_alloc(&search, NV_UNIQUE_NAME, KM_SLEEP) == 0);
|
||||
|
||||
@@ -2830,6 +2834,18 @@ zpool_find_vdev(zpool_handle_t *zhp, const char *path, boolean_t *avail_spare,
|
||||
verify(nvlist_lookup_nvlist(zhp->zpool_config, ZPOOL_CONFIG_VDEV_TREE,
|
||||
&nvroot) == 0);
|
||||
|
||||
/*
|
||||
* User can pass NULL for avail_spare, l2cache, and log, but
|
||||
* we still need to provide variables to vdev_to_nvlist_iter(), so
|
||||
* just point them to junk variables here.
|
||||
*/
|
||||
if (!avail_spare)
|
||||
avail_spare = &__avail_spare;
|
||||
if (!l2cache)
|
||||
l2cache = &__l2cache;
|
||||
if (!log)
|
||||
log = &__log;
|
||||
|
||||
*avail_spare = B_FALSE;
|
||||
*l2cache = B_FALSE;
|
||||
if (log != NULL)
|
||||
@@ -3233,21 +3249,23 @@ zpool_vdev_fault(zpool_handle_t *zhp, uint64_t guid, vdev_aux_t aux)
|
||||
}
|
||||
|
||||
/*
|
||||
* Mark the given vdev degraded.
|
||||
* Generic set vdev state function
|
||||
*/
|
||||
int
|
||||
zpool_vdev_degrade(zpool_handle_t *zhp, uint64_t guid, vdev_aux_t aux)
|
||||
static int
|
||||
zpool_vdev_set_state(zpool_handle_t *zhp, uint64_t guid, vdev_aux_t aux,
|
||||
vdev_state_t state)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
char msg[1024];
|
||||
libzfs_handle_t *hdl = zhp->zpool_hdl;
|
||||
|
||||
(void) snprintf(msg, sizeof (msg),
|
||||
dgettext(TEXT_DOMAIN, "cannot degrade %llu"), (u_longlong_t)guid);
|
||||
dgettext(TEXT_DOMAIN, "cannot set %s %llu"),
|
||||
zpool_state_to_name(state, aux), (u_longlong_t)guid);
|
||||
|
||||
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
|
||||
zc.zc_guid = guid;
|
||||
zc.zc_cookie = VDEV_STATE_DEGRADED;
|
||||
zc.zc_cookie = state;
|
||||
zc.zc_obj = aux;
|
||||
|
||||
if (zfs_ioctl(hdl, ZFS_IOC_VDEV_SET_STATE, &zc) == 0)
|
||||
@@ -3256,6 +3274,27 @@ zpool_vdev_degrade(zpool_handle_t *zhp, uint64_t guid, vdev_aux_t aux)
|
||||
return (zpool_standard_error(hdl, errno, msg));
|
||||
}
|
||||
|
||||
/*
|
||||
* Mark the given vdev degraded.
|
||||
*/
|
||||
int
|
||||
zpool_vdev_degrade(zpool_handle_t *zhp, uint64_t guid, vdev_aux_t aux)
|
||||
{
|
||||
return (zpool_vdev_set_state(zhp, guid, aux, VDEV_STATE_DEGRADED));
|
||||
}
|
||||
|
||||
/*
|
||||
* Mark the given vdev as in a removed state (as if the device does not exist).
|
||||
*
|
||||
* This is different than zpool_vdev_remove() which does a removal of a device
|
||||
* from the pool (but the device does exist).
|
||||
*/
|
||||
int
|
||||
zpool_vdev_set_removed_state(zpool_handle_t *zhp, uint64_t guid, vdev_aux_t aux)
|
||||
{
|
||||
return (zpool_vdev_set_state(zhp, guid, aux, VDEV_STATE_REMOVED));
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns TRUE if the given nvlist is a vdev that was originally swapped in as
|
||||
* a hot spare.
|
||||
|
||||
Reference in New Issue
Block a user