Skip to content

Return an error if udev is not running/available #858

Description

@bmr-cymru

Currently if the systemd-udevd daemon is not running or is unable to respond to uevents the udev synchronization code in devicemapper will hang indefinitely:

[2023-05-25T12:04:11Z DEBUG devicemapper::core::dm] Resuming device stratis-1-private-e00449c6a59b43e48a1187473064225d-physical-originsub
[2023-05-25T12:04:11Z DEBUG devicemapper::core::dm_udev_sync::sync_semaphore] Created UdevSync { cookie: 5114325, semid: 0 }
[2023-05-25T12:04:11Z TRACE devicemapper::core::dm_udev_sync::sync_semaphore] Waiting on UdevSync { cookie: 5114325, semid: Some(0) }
<< blocks here >>

It would be better to test the state of udev and to report an error like "The udev daemon is not running".

The libdevmapper library detects this state by calling the udev API:

static int _check_udev_is_running(void)
{
        struct udev *udev;
        struct udev_queue *udev_queue;
        int r;

        if (!(udev = udev_new()))
                goto_bad;

        if (!(udev_queue = udev_queue_new(udev))) {
                udev_unref(udev);
                goto_bad;
        }

        if (!(r = udev_queue_get_udev_is_active(udev_queue)))
                log_debug_activation("Udev is not running. "
                                     "Not using udev synchronisation code.");

        udev_queue_unref(udev_queue);
        udev_unref(udev);

        return r;

bad:
        log_error("Could not get udev state. Assuming udev is not running.");
        return 0;
}

There are Rust bindings for libudev available so we can potentially implement the same check in devicemapper.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions