From 0a0a66653247a9f5666cbb225e06596197c1429d Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Thu, 30 Nov 2023 17:12:33 -0500 Subject: [PATCH] Linux: Print to stderr when ZPOOL_IMPORT_UDEV_TIMEOUT_MS exceeded libudev support was added in 0.7.y and ever since, whenever udev is unavailable or something is wrong with it, pools take 30 seconds to import, which is extremely annoying to system administrators. There is no obvious sign of the problem, making it even more annoying. Let's report this condition to system administrators going forward. Reported-by: Mason Loring Bliss Signed-off-by: Richard Yao --- lib/libzutil/os/linux/zutil_import_os.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/libzutil/os/linux/zutil_import_os.c b/lib/libzutil/os/linux/zutil_import_os.c index 8b64369dc29f..6574a4b74efe 100644 --- a/lib/libzutil/os/linux/zutil_import_os.c +++ b/lib/libzutil/os/linux/zutil_import_os.c @@ -598,6 +598,7 @@ zpool_label_disk_wait(const char *path, int timeout_ms) int settle_ms = 50; long sleep_ms = 10; hrtime_t start, settle; + boolean_t c = B_TRUE; if ((udev = udev_new()) == NULL) return (ENXIO); @@ -651,7 +652,11 @@ zpool_label_disk_wait(const char *path, int timeout_ms) udev_device_unref(dev); (void) usleep(sleep_ms * MILLISEC); - } while (NSEC2MSEC(gethrtime() - start) < timeout_ms); + } while (c = ((NSEC2MSEC(gethrtime() - start) < timeout_ms))); + + if (c == B_FALSE) + fprintf(stderr, "error: %s", + "ZPOOL_IMPORT_UDEV_TIMEOUT_MS exceeded"); udev_unref(udev);