Skip to content

Commit

Permalink
Linux: Print to stderr when ZPOOL_IMPORT_UDEV_TIMEOUT_MS exceeded
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Richard Yao <[email protected]>
  • Loading branch information
ryao committed Nov 30, 2023
1 parent 6c96269 commit cada11b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/libzutil/os/linux/zutil_import_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit cada11b

Please sign in to comment.