summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmeer Hamza <[email protected]>2022-10-21 22:46:38 +0500
committerGitHub <[email protected]>2022-10-21 10:46:38 -0700
commit0b2428da20c69bf32bbb9cbf561aa615fee64395 (patch)
tree5563d927bd564ce239906efef30e77cd2e7a6a4a
parentc5a388a1ef071b308ab0985fe831f94639fd4d7c (diff)
zed: Avoid core dump if wholedisk property does not exist
zed aborts and dumps core in vdev_whole_disk_from_config() if wholedisk property does not exist. make_leaf_vdev() adds the property but there may be already pools that don't have the wholedisk in the label. Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Alexander Motin <[email protected]> Reviewed-by: Richard Yao <[email protected]> Signed-off-by: Ameer Hamza <[email protected]> Closes #14062
-rw-r--r--cmd/zed/agents/zfs_mod.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/cmd/zed/agents/zfs_mod.c b/cmd/zed/agents/zfs_mod.c
index 44abb4eb9..0271fffe4 100644
--- a/cmd/zed/agents/zfs_mod.c
+++ b/cmd/zed/agents/zfs_mod.c
@@ -948,14 +948,13 @@ vdev_whole_disk_from_config(zpool_handle_t *zhp, const char *vdev_path)
{
nvlist_t *nvl = NULL;
boolean_t avail_spare, l2cache, log;
- uint64_t wholedisk;
+ uint64_t wholedisk = 0;
nvl = zpool_find_vdev(zhp, vdev_path, &avail_spare, &l2cache, &log);
if (!nvl)
return (0);
- verify(nvlist_lookup_uint64(nvl, ZPOOL_CONFIG_WHOLE_DISK,
- &wholedisk) == 0);
+ (void) nvlist_lookup_uint64(nvl, ZPOOL_CONFIG_WHOLE_DISK, &wholedisk);
return (wholedisk);
}
@@ -994,7 +993,7 @@ zfsdle_vdev_online(zpool_handle_t *zhp, void *data)
if ((tgt = zpool_find_vdev_by_physpath(zhp, devname,
&avail_spare, &l2cache, NULL)) != NULL) {
char *path, fullpath[MAXPATHLEN];
- uint64_t wholedisk;
+ uint64_t wholedisk = 0;
error = nvlist_lookup_string(tgt, ZPOOL_CONFIG_PATH, &path);
if (error) {
@@ -1002,10 +1001,8 @@ zfsdle_vdev_online(zpool_handle_t *zhp, void *data)
return (0);
}
- error = nvlist_lookup_uint64(tgt, ZPOOL_CONFIG_WHOLE_DISK,
+ (void) nvlist_lookup_uint64(tgt, ZPOOL_CONFIG_WHOLE_DISK,
&wholedisk);
- if (error)
- wholedisk = 0;
if (wholedisk) {
path = strrchr(path, '/');