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 <mason@blisses.org>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
This commit is contained in:
Richard Yao 2023-11-30 17:12:33 -05:00
parent 86e115e21e
commit adc3425e39
1 changed files with 6 additions and 1 deletions

View File

@ -597,6 +597,7 @@ zpool_label_disk_wait(const char *path, int timeout_ms)
int settle_ms = 50; int settle_ms = 50;
long sleep_ms = 10; long sleep_ms = 10;
hrtime_t start, settle; hrtime_t start, settle;
boolean_t c = B_TRUE;
if ((udev = udev_new()) == NULL) if ((udev = udev_new()) == NULL)
return (ENXIO); return (ENXIO);
@ -650,7 +651,11 @@ zpool_label_disk_wait(const char *path, int timeout_ms)
udev_device_unref(dev); udev_device_unref(dev);
(void) usleep(sleep_ms * MILLISEC); (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); udev_unref(udev);