From 9935cf0f64f3f1e70e7840385e9838c30487dc64 Mon Sep 17 00:00:00 2001 From: Mateusz Grzonka Date: Tue, 21 Nov 2023 01:58:23 +0100 Subject: Mdmonitor: Improve udev event handling Mdmonitor is waiting for udev queue to become empty. Even if the queue becomes empty, udev might still be processing last event. However we want to wait and wake up mdmonitor when udev finished processing events.. Also, the udev queue interface is considered legacy and should not be used outside of udev. Use udev monitor instead, and wake up mdmonitor on every event triggered by udev for md block device. We need to generate more change events from kernel, because they are missing in some situations, for example, when rebuild started. This will be addressed in a separate patch. Move udev specific code into separate functions, and place them in udev.c file. Also move use_udev() logic from lib.c into newly created file. Signed-off-by: Mateusz Grzonka Signed-off-by: Kinga Tanska Signed-off-by: Jes Sorensen --- mdopen.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'mdopen.c') diff --git a/mdopen.c b/mdopen.c index 3daa71f9..f9b04e1c 100644 --- a/mdopen.c +++ b/mdopen.c @@ -23,6 +23,7 @@ */ #include "mdadm.h" +#include "udev.h" #include "md_p.h" #include @@ -176,7 +177,7 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy, char devnm[32]; char cbuf[400]; - if (!use_udev()) + if (!udev_is_available()) block_udev = 0; if (chosen == NULL) @@ -384,7 +385,7 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy, * If we cannot detect udev, we need to make * devices and links ourselves. */ - if (!use_udev()) { + if (!udev_is_available()) { /* Make sure 'devname' exists and 'chosen' is a symlink to it */ if (lstat(devname, &stb) == 0) { /* Must be the correct device, else error */ @@ -508,7 +509,7 @@ char *find_free_devnm(int use_partitions) continue; if (!conf_name_is_free(devnm)) continue; - if (!use_udev()) { + if (!udev_is_available()) { /* make sure it is new to /dev too, at least as a * non-standard */ dev_t devid = devnm2devid(devnm); -- cgit v1.2.3