From adc3425e39f5ace4e6aa9b4e9ec211f2aade49f7 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 fbfae4f7e6..b68ef09c38 100644 --- a/lib/libzutil/os/linux/zutil_import_os.c +++ b/lib/libzutil/os/linux/zutil_import_os.c @@ -597,6 +597,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); @@ -650,7 +651,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\n"); udev_unref(udev);