zed: misc vdev_enc_sysfs_path fixes
There have been rare cases where the VDEV_ENC_SYSFS_PATH value that zed gets passed is stale. To mitigate this, dynamically check the sysfs path at the time of zed event processing, and use the dynamic value if possible. Note that there will be other times when we can not dynamically detect the sysfs path (like if a disk disappears) and have to rely on the old value for things like turning on the fault LED. That is to say, we can't just blindly use the dynamic path in every case. Also: - Add enclosure sysfs entry when running 'zpool add' - Fix 'slot' and 'enc' zpool.d scripts for nvme Reviewed-by: Don Brady <dev.fs.zfs@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Tony Hutter <hutter2@llnl.gov> Closes #15462
This commit is contained in:
parent
11574a7934
commit
dffe59c415
|
@ -222,8 +222,12 @@ zfs_process_add(zpool_handle_t *zhp, nvlist_t *vdev, boolean_t labeled)
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) nvlist_lookup_string(vdev, ZPOOL_CONFIG_PHYS_PATH, &physpath);
|
(void) nvlist_lookup_string(vdev, ZPOOL_CONFIG_PHYS_PATH, &physpath);
|
||||||
|
|
||||||
|
update_vdev_config_dev_sysfs_path(vdev, path,
|
||||||
|
ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH);
|
||||||
(void) nvlist_lookup_string(vdev, ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH,
|
(void) nvlist_lookup_string(vdev, ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH,
|
||||||
&enc_sysfs_path);
|
&enc_sysfs_path);
|
||||||
|
|
||||||
(void) nvlist_lookup_uint64(vdev, ZPOOL_CONFIG_WHOLE_DISK, &wholedisk);
|
(void) nvlist_lookup_uint64(vdev, ZPOOL_CONFIG_WHOLE_DISK, &wholedisk);
|
||||||
(void) nvlist_lookup_uint64(vdev, ZPOOL_CONFIG_OFFLINE, &offline);
|
(void) nvlist_lookup_uint64(vdev, ZPOOL_CONFIG_OFFLINE, &offline);
|
||||||
(void) nvlist_lookup_uint64(vdev, ZPOOL_CONFIG_FAULTED, &faulted);
|
(void) nvlist_lookup_uint64(vdev, ZPOOL_CONFIG_FAULTED, &faulted);
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "zed_strings.h"
|
#include "zed_strings.h"
|
||||||
|
|
||||||
#include "agents/zfs_agents.h"
|
#include "agents/zfs_agents.h"
|
||||||
|
#include <libzutil.h>
|
||||||
|
|
||||||
#define MAXBUF 4096
|
#define MAXBUF 4096
|
||||||
|
|
||||||
|
@ -907,6 +908,25 @@ _zed_event_add_time_strings(uint64_t eid, zed_strings_t *zsp, int64_t etime[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
_zed_event_update_enc_sysfs_path(nvlist_t *nvl)
|
||||||
|
{
|
||||||
|
char *vdev_path;
|
||||||
|
|
||||||
|
if (nvlist_lookup_string(nvl, FM_EREPORT_PAYLOAD_ZFS_VDEV_PATH,
|
||||||
|
&vdev_path) != 0) {
|
||||||
|
return; /* some other kind of event, ignore it */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vdev_path == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
update_vdev_config_dev_sysfs_path(nvl, vdev_path,
|
||||||
|
FM_EREPORT_PAYLOAD_ZFS_VDEV_ENC_SYSFS_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Service the next zevent, blocking until one is available.
|
* Service the next zevent, blocking until one is available.
|
||||||
*/
|
*/
|
||||||
|
@ -954,6 +974,17 @@ zed_event_service(struct zed_conf *zcp)
|
||||||
zed_log_msg(LOG_WARNING,
|
zed_log_msg(LOG_WARNING,
|
||||||
"Failed to lookup zevent class (eid=%llu)", eid);
|
"Failed to lookup zevent class (eid=%llu)", eid);
|
||||||
} else {
|
} else {
|
||||||
|
/*
|
||||||
|
* Special case: If we can dynamically detect an enclosure sysfs
|
||||||
|
* path, then use that value rather than the one stored in the
|
||||||
|
* vd->vdev_enc_sysfs_path. There have been rare cases where
|
||||||
|
* vd->vdev_enc_sysfs_path becomes outdated. However, there
|
||||||
|
* will be other times when we can not dynamically detect the
|
||||||
|
* sysfs path (like if a disk disappears) and have to rely on
|
||||||
|
* the old value for things like turning on the fault LED.
|
||||||
|
*/
|
||||||
|
_zed_event_update_enc_sysfs_path(nvl);
|
||||||
|
|
||||||
/* let internal modules see this event first */
|
/* let internal modules see this event first */
|
||||||
zfs_agent_post_event(class, NULL, nvl);
|
zfs_agent_post_event(class, NULL, nvl);
|
||||||
|
|
||||||
|
|
|
@ -32,10 +32,18 @@ for i in $scripts ; do
|
||||||
val=""
|
val=""
|
||||||
case $i in
|
case $i in
|
||||||
enc)
|
enc)
|
||||||
val=$(ls "$VDEV_ENC_SYSFS_PATH/../../" 2>/dev/null)
|
if echo "$VDEV_ENC_SYSFS_PATH" | grep -q '/sys/bus/pci/slots' ; then
|
||||||
|
val="$VDEV_ENC_SYSFS_PATH"
|
||||||
|
else
|
||||||
|
val="$(ls """$VDEV_ENC_SYSFS_PATH/../../""" 2>/dev/null)"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
slot)
|
slot)
|
||||||
val=$(cat "$VDEV_ENC_SYSFS_PATH/slot" 2>/dev/null)
|
if echo "$VDEV_ENC_SYSFS_PATH" | grep -q '/sys/bus/pci/slots' ; then
|
||||||
|
val="$(basename """$VDEV_ENC_SYSFS_PATH""")"
|
||||||
|
else
|
||||||
|
val="$(cat """$VDEV_ENC_SYSFS_PATH/slot""" 2>/dev/null)"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
encdev)
|
encdev)
|
||||||
val=$(ls "$VDEV_ENC_SYSFS_PATH/../device/scsi_generic" 2>/dev/null)
|
val=$(ls "$VDEV_ENC_SYSFS_PATH/../device/scsi_generic" 2>/dev/null)
|
||||||
|
|
|
@ -373,6 +373,10 @@ make_leaf_vdev(nvlist_t *props, const char *arg, boolean_t is_primary)
|
||||||
verify(nvlist_add_string(vdev, ZPOOL_CONFIG_PATH, path) == 0);
|
verify(nvlist_add_string(vdev, ZPOOL_CONFIG_PATH, path) == 0);
|
||||||
verify(nvlist_add_string(vdev, ZPOOL_CONFIG_TYPE, type) == 0);
|
verify(nvlist_add_string(vdev, ZPOOL_CONFIG_TYPE, type) == 0);
|
||||||
|
|
||||||
|
/* Lookup and add the enclosure sysfs path (if exists) */
|
||||||
|
update_vdev_config_dev_sysfs_path(vdev, path,
|
||||||
|
ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH);
|
||||||
|
|
||||||
if (strcmp(type, VDEV_TYPE_DISK) == 0)
|
if (strcmp(type, VDEV_TYPE_DISK) == 0)
|
||||||
verify(nvlist_add_uint64(vdev, ZPOOL_CONFIG_WHOLE_DISK,
|
verify(nvlist_add_uint64(vdev, ZPOOL_CONFIG_WHOLE_DISK,
|
||||||
(uint64_t)wholedisk) == 0);
|
(uint64_t)wholedisk) == 0);
|
||||||
|
|
|
@ -187,6 +187,8 @@ int for_each_vdev_cb(void *zhp, nvlist_t *nv, pool_vdev_iter_f func,
|
||||||
int for_each_vdev_in_nvlist(nvlist_t *nvroot, pool_vdev_iter_f func,
|
int for_each_vdev_in_nvlist(nvlist_t *nvroot, pool_vdev_iter_f func,
|
||||||
void *data);
|
void *data);
|
||||||
void update_vdevs_config_dev_sysfs_path(nvlist_t *config);
|
void update_vdevs_config_dev_sysfs_path(nvlist_t *config);
|
||||||
|
_LIBZUTIL_H void update_vdev_config_dev_sysfs_path(nvlist_t *nv,
|
||||||
|
const char *path, const char *key);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -99,6 +99,7 @@
|
||||||
<elf-symbol name='sa_validate_shareopts' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
<elf-symbol name='sa_validate_shareopts' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||||
<elf-symbol name='snapshot_namecheck' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
<elf-symbol name='snapshot_namecheck' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||||
<elf-symbol name='unshare_one' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
<elf-symbol name='unshare_one' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||||
|
<elf-symbol name='update_vdev_config_dev_sysfs_path' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||||
<elf-symbol name='use_color' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
<elf-symbol name='use_color' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||||
<elf-symbol name='zcmd_alloc_dst_nvlist' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
<elf-symbol name='zcmd_alloc_dst_nvlist' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||||
<elf-symbol name='zcmd_expand_dst_nvlist' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
<elf-symbol name='zcmd_expand_dst_nvlist' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
|
||||||
|
@ -5124,6 +5125,12 @@
|
||||||
<parameter type-id='95e97e5e' name='flags'/>
|
<parameter type-id='95e97e5e' name='flags'/>
|
||||||
<return type-id='c19b74c3'/>
|
<return type-id='c19b74c3'/>
|
||||||
</function-decl>
|
</function-decl>
|
||||||
|
<function-decl name='update_vdev_config_dev_sysfs_path' mangled-name='update_vdev_config_dev_sysfs_path' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='update_vdev_config_dev_sysfs_path'>
|
||||||
|
<parameter type-id='5ce45b60' name='nv'/>
|
||||||
|
<parameter type-id='80f4b756' name='path'/>
|
||||||
|
<parameter type-id='80f4b756' name='key'/>
|
||||||
|
<return type-id='48b5725f'/>
|
||||||
|
</function-decl>
|
||||||
<function-decl name='zfs_mount_at' mangled-name='zfs_mount_at' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_mount_at'>
|
<function-decl name='zfs_mount_at' mangled-name='zfs_mount_at' visibility='default' binding='global' size-in-bits='64' elf-symbol-id='zfs_mount_at'>
|
||||||
<parameter type-id='9200a744' name='zhp'/>
|
<parameter type-id='9200a744' name='zhp'/>
|
||||||
<parameter type-id='80f4b756' name='options'/>
|
<parameter type-id='80f4b756' name='options'/>
|
||||||
|
|
|
@ -248,6 +248,15 @@ zfs_dev_flush(int fd __unused)
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
update_vdev_config_dev_sysfs_path(nvlist_t *nv, const char *path,
|
||||||
|
const char *key)
|
||||||
|
{
|
||||||
|
(void) nv;
|
||||||
|
(void) path;
|
||||||
|
(void) key;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
update_vdevs_config_dev_sysfs_path(nvlist_t *config)
|
update_vdevs_config_dev_sysfs_path(nvlist_t *config)
|
||||||
{
|
{
|
||||||
|
|
|
@ -781,9 +781,12 @@ no_dev:
|
||||||
* Rescan the enclosure sysfs path for turning on enclosure LEDs and store it
|
* Rescan the enclosure sysfs path for turning on enclosure LEDs and store it
|
||||||
* in the nvlist * (if applicable). Like:
|
* in the nvlist * (if applicable). Like:
|
||||||
* vdev_enc_sysfs_path: '/sys/class/enclosure/11:0:1:0/SLOT 4'
|
* vdev_enc_sysfs_path: '/sys/class/enclosure/11:0:1:0/SLOT 4'
|
||||||
|
*
|
||||||
|
* key: The nvlist_t name (like ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH)
|
||||||
*/
|
*/
|
||||||
static void
|
void
|
||||||
update_vdev_config_dev_sysfs_path(nvlist_t *nv, char *path)
|
update_vdev_config_dev_sysfs_path(nvlist_t *nv, const char *path,
|
||||||
|
const char *key)
|
||||||
{
|
{
|
||||||
char *upath, *spath;
|
char *upath, *spath;
|
||||||
|
|
||||||
|
@ -792,9 +795,9 @@ update_vdev_config_dev_sysfs_path(nvlist_t *nv, char *path)
|
||||||
spath = zfs_get_enclosure_sysfs_path(upath);
|
spath = zfs_get_enclosure_sysfs_path(upath);
|
||||||
|
|
||||||
if (spath) {
|
if (spath) {
|
||||||
nvlist_add_string(nv, ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH, spath);
|
(void) nvlist_add_string(nv, key, spath);
|
||||||
} else {
|
} else {
|
||||||
nvlist_remove_all(nv, ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH);
|
(void) nvlist_remove_all(nv, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(upath);
|
free(upath);
|
||||||
|
@ -812,7 +815,8 @@ sysfs_path_pool_vdev_iter_f(void *hdl_data, nvlist_t *nv, void *data)
|
||||||
return (1);
|
return (1);
|
||||||
|
|
||||||
/* Rescan our enclosure sysfs path for this vdev */
|
/* Rescan our enclosure sysfs path for this vdev */
|
||||||
update_vdev_config_dev_sysfs_path(nv, path);
|
update_vdev_config_dev_sysfs_path(nv, path,
|
||||||
|
ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -901,7 +905,8 @@ update_vdev_config_dev_strs(nvlist_t *nv)
|
||||||
(void) nvlist_add_string(nv, ZPOOL_CONFIG_PHYS_PATH,
|
(void) nvlist_add_string(nv, ZPOOL_CONFIG_PHYS_PATH,
|
||||||
vds.vds_devphys);
|
vds.vds_devphys);
|
||||||
}
|
}
|
||||||
update_vdev_config_dev_sysfs_path(nv, path);
|
update_vdev_config_dev_sysfs_path(nv, path,
|
||||||
|
ZPOOL_CONFIG_VDEV_ENC_SYSFS_PATH);
|
||||||
} else {
|
} else {
|
||||||
/* Clear out any stale entries. */
|
/* Clear out any stale entries. */
|
||||||
(void) nvlist_remove_all(nv, ZPOOL_CONFIG_DEVID);
|
(void) nvlist_remove_all(nv, ZPOOL_CONFIG_DEVID);
|
||||||
|
|
Loading…
Reference in New Issue