From 50b32cb925f20ececeff1b500811fa349fb419ba Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Tue, 27 Aug 2024 10:39:13 +1000 Subject: [PATCH] fm: pass io_flags through events & zed as uint64_t In 4938d01db (#14086) zio_flag_t was converted from an enum (generally signed 32-bit) to a uint64_t. The corresponding change wasn't made to the error reporting subsystem, limiting the error flags being delivered to zed to 32 bits. This bumps the whole pipeline to use uint64s. A tiny bit of compatibility is added for newer zed working agsinst an older kernel module, because its easy to do and misdetecting scrub/resilver errors and taking action is potentially dangerous. Making it work for new kernel modules against older zed seems to be far more invasive for far less benefit, so I have not. Sponsored-by: Klara, Inc. Sponsored-by: Wasabi Technology, Inc. Reviewed-by: Alexander Motin Reviewed-by: Brian Behlendorf Signed-off-by: Rob Norris Closes #16469 --- cmd/zed/agents/zfs_diagnosis.c | 15 ++++++++++++--- module/zfs/zfs_fm.c | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/cmd/zed/agents/zfs_diagnosis.c b/cmd/zed/agents/zfs_diagnosis.c index e0ad00800a..e35cd0756c 100644 --- a/cmd/zed/agents/zfs_diagnosis.c +++ b/cmd/zed/agents/zfs_diagnosis.c @@ -844,7 +844,6 @@ zfs_fm_recv(fmd_hdl_t *hdl, fmd_event_t *ep, nvlist_t *nvl, const char *class) const char *failmode = NULL; boolean_t checkremove = B_FALSE; uint32_t pri = 0; - int32_t flags = 0; /* * If this is a checksum or I/O error, then toss it into the @@ -922,18 +921,28 @@ zfs_fm_recv(fmd_hdl_t *hdl, fmd_event_t *ep, nvlist_t *nvl, const char *class) } } else if (fmd_nvl_class_match(hdl, nvl, ZFS_MAKE_EREPORT(FM_EREPORT_ZFS_CHECKSUM))) { + uint64_t flags = 0; + int32_t flags32 = 0; /* * We ignore ereports for checksum errors generated by * scrub/resilver I/O to avoid potentially further * degrading the pool while it's being repaired. + * + * Note that FM_EREPORT_PAYLOAD_ZFS_ZIO_FLAGS used to + * be int32. To allow newer zed to work on older + * kernels, if we don't find the flags, we look for + * the older ones too. */ if (((nvlist_lookup_uint32(nvl, FM_EREPORT_PAYLOAD_ZFS_ZIO_PRIORITY, &pri) == 0) && (pri == ZIO_PRIORITY_SCRUB || pri == ZIO_PRIORITY_REBUILD)) || - ((nvlist_lookup_int32(nvl, + ((nvlist_lookup_uint64(nvl, FM_EREPORT_PAYLOAD_ZFS_ZIO_FLAGS, &flags) == 0) && - (flags & (ZIO_FLAG_SCRUB | ZIO_FLAG_RESILVER)))) { + (flags & (ZIO_FLAG_SCRUB | ZIO_FLAG_RESILVER))) || + ((nvlist_lookup_int32(nvl, + FM_EREPORT_PAYLOAD_ZFS_ZIO_FLAGS, &flags32) == 0) && + (flags32 & (ZIO_FLAG_SCRUB | ZIO_FLAG_RESILVER)))) { fmd_hdl_debug(hdl, "ignoring '%s' for " "scrub/resilver I/O", class); return; diff --git a/module/zfs/zfs_fm.c b/module/zfs/zfs_fm.c index 2f43c4aa41..f7cecc9af8 100644 --- a/module/zfs/zfs_fm.c +++ b/module/zfs/zfs_fm.c @@ -645,7 +645,7 @@ zfs_ereport_start(nvlist_t **ereport_out, nvlist_t **detector_out, fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_ZIO_ERR, DATA_TYPE_INT32, zio->io_error, NULL); fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_ZIO_FLAGS, - DATA_TYPE_INT32, zio->io_flags, NULL); + DATA_TYPE_UINT64, zio->io_flags, NULL); fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_ZIO_STAGE, DATA_TYPE_UINT32, zio->io_stage, NULL); fm_payload_set(ereport, FM_EREPORT_PAYLOAD_ZFS_ZIO_PIPELINE,