Monitor: make libudev dependency optional
Make -ludev configurable, enabled by default.
To disable it, -DNO_LIBUDEV has to be set explicitly in CXFALGS.
This patch restores commit cab9c67d46
("mdmonitor: set small delay
once") for configuration without libudev to bring minimal support in
such case.
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
This commit is contained in:
parent
f94df5cf83
commit
af3396dadf
7
Makefile
7
Makefile
|
@ -119,7 +119,12 @@ endif
|
||||||
# If you want a static binary, you might uncomment these
|
# If you want a static binary, you might uncomment these
|
||||||
# LDFLAGS = -static
|
# LDFLAGS = -static
|
||||||
# STRIP = -s
|
# STRIP = -s
|
||||||
LDLIBS=-ldl -ludev
|
LDLIBS = -ldl
|
||||||
|
|
||||||
|
# To explicitly disable libudev, set -DNO_LIBUDEV in CXFLAGS
|
||||||
|
ifeq (, $(findstring -DNO_LIBUDEV, $(CXFLAGS)))
|
||||||
|
LDLIBS += -ludev
|
||||||
|
endif
|
||||||
|
|
||||||
INSTALL = /usr/bin/install
|
INSTALL = /usr/bin/install
|
||||||
DESTDIR =
|
DESTDIR =
|
||||||
|
|
28
Monitor.c
28
Monitor.c
|
@ -29,7 +29,9 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
#ifndef NO_LIBUDEV
|
||||||
#include <libudev.h>
|
#include <libudev.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
struct state {
|
struct state {
|
||||||
char *devname;
|
char *devname;
|
||||||
|
@ -73,7 +75,9 @@ static int add_new_arrays(struct mdstat_ent *mdstat, struct state **statelist,
|
||||||
int test, struct alert_info *info);
|
int test, struct alert_info *info);
|
||||||
static void try_spare_migration(struct state *statelist, struct alert_info *info);
|
static void try_spare_migration(struct state *statelist, struct alert_info *info);
|
||||||
static void link_containers_with_subarrays(struct state *list);
|
static void link_containers_with_subarrays(struct state *list);
|
||||||
|
#ifndef NO_LIBUDEV
|
||||||
static int check_udev_activity(void);
|
static int check_udev_activity(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
int Monitor(struct mddev_dev *devlist,
|
int Monitor(struct mddev_dev *devlist,
|
||||||
char *mailaddr, char *alert_cmd,
|
char *mailaddr, char *alert_cmd,
|
||||||
|
@ -131,6 +135,7 @@ int Monitor(struct mddev_dev *devlist,
|
||||||
char *mailfrom;
|
char *mailfrom;
|
||||||
struct alert_info info;
|
struct alert_info info;
|
||||||
struct mddev_ident *mdlist;
|
struct mddev_ident *mdlist;
|
||||||
|
int delay_for_event = c->delay;
|
||||||
|
|
||||||
if (!mailaddr) {
|
if (!mailaddr) {
|
||||||
mailaddr = conf_get_mailaddr();
|
mailaddr = conf_get_mailaddr();
|
||||||
|
@ -256,13 +261,25 @@ int Monitor(struct mddev_dev *devlist,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
#ifndef NO_LIBUDEV
|
||||||
/*
|
/*
|
||||||
* If mdmonitor is awaken by event, check for udev activity
|
* Wait for udevd to finish new devices
|
||||||
* to wait for udev to finish new devices processing.
|
* processing.
|
||||||
*/
|
*/
|
||||||
if (mdstat_wait(c->delay) && check_udev_activity())
|
if (mdstat_wait(delay_for_event) &&
|
||||||
|
check_udev_activity())
|
||||||
pr_err("Error while waiting for UDEV to complete new devices processing\n");
|
pr_err("Error while waiting for UDEV to complete new devices processing\n");
|
||||||
|
#else
|
||||||
|
int wait_result = mdstat_wait(delay_for_event);
|
||||||
|
/*
|
||||||
|
* Give chance to process new device
|
||||||
|
*/
|
||||||
|
if (wait_result != 0) {
|
||||||
|
if (c->delay > 5)
|
||||||
|
delay_for_event = 5;
|
||||||
|
} else
|
||||||
|
delay_for_event = c->delay;
|
||||||
|
#endif
|
||||||
mdstat_close();
|
mdstat_close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1033,7 +1050,7 @@ static void link_containers_with_subarrays(struct state *list)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NO_LIBUDEV
|
||||||
/* function: check_udev_activity
|
/* function: check_udev_activity
|
||||||
* Description: Function waits for udev to finish
|
* Description: Function waits for udev to finish
|
||||||
* events processing.
|
* events processing.
|
||||||
|
@ -1089,6 +1106,7 @@ out:
|
||||||
udev_unref(udev);
|
udev_unref(udev);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Not really Monitor but ... */
|
/* Not really Monitor but ... */
|
||||||
int Wait(char *dev)
|
int Wait(char *dev)
|
||||||
|
|
Loading…
Reference in New Issue