|
|
671555 |
---
|
|
|
671555 |
libmultipath/uevent.c | 17 ++++++++++++-----
|
|
|
671555 |
libmultipath/uevent.h | 4 +++-
|
|
|
671555 |
multipathd/main.c | 8 +++++---
|
|
|
671555 |
3 files changed, 20 insertions(+), 9 deletions(-)
|
|
|
671555 |
|
|
|
671555 |
Index: multipath-tools-130222/libmultipath/uevent.c
|
|
|
671555 |
===================================================================
|
|
|
671555 |
--- multipath-tools-130222.orig/libmultipath/uevent.c
|
|
|
671555 |
+++ multipath-tools-130222/libmultipath/uevent.c
|
|
|
671555 |
@@ -47,7 +47,6 @@
|
|
|
671555 |
#include "list.h"
|
|
|
671555 |
#include "uevent.h"
|
|
|
671555 |
#include "vector.h"
|
|
|
671555 |
-#include "config.h"
|
|
|
671555 |
|
|
|
671555 |
typedef int (uev_trigger)(struct uevent *, void * trigger_data);
|
|
|
671555 |
|
|
|
671555 |
@@ -127,11 +126,14 @@ service_uevq(struct list_head *tmpq)
|
|
|
671555 |
|
|
|
671555 |
static void uevq_stop(void *arg)
|
|
|
671555 |
{
|
|
|
671555 |
+ struct udev *udev = arg;
|
|
|
671555 |
+
|
|
|
671555 |
condlog(3, "Stopping uev queue");
|
|
|
671555 |
pthread_mutex_lock(uevq_lockp);
|
|
|
671555 |
my_uev_trigger = NULL;
|
|
|
671555 |
pthread_cond_signal(uev_condp);
|
|
|
671555 |
pthread_mutex_unlock(uevq_lockp);
|
|
|
671555 |
+ udev_unref(udev);
|
|
|
671555 |
}
|
|
|
671555 |
|
|
|
671555 |
void
|
|
|
671555 |
@@ -399,9 +401,9 @@ exit:
|
|
|
671555 |
return 1;
|
|
|
671555 |
}
|
|
|
671555 |
|
|
|
671555 |
-int uevent_listen(void)
|
|
|
671555 |
+int uevent_listen(struct udev *udev)
|
|
|
671555 |
{
|
|
|
671555 |
- int err;
|
|
|
671555 |
+ int err = 2;
|
|
|
671555 |
struct udev_monitor *monitor = NULL;
|
|
|
671555 |
int fd, socket_flags;
|
|
|
671555 |
int need_failback = 1;
|
|
|
671555 |
@@ -411,9 +413,14 @@ int uevent_listen(void)
|
|
|
671555 |
* thereby not getting to empty the socket's receive buffer queue
|
|
|
671555 |
* often enough.
|
|
|
671555 |
*/
|
|
|
671555 |
- pthread_cleanup_push(uevq_stop, NULL);
|
|
|
671555 |
+ if (!udev) {
|
|
|
671555 |
+ condlog(1, "no udev context");
|
|
|
671555 |
+ return 1;
|
|
|
671555 |
+ }
|
|
|
671555 |
+ udev_ref(udev);
|
|
|
671555 |
+ pthread_cleanup_push(uevq_stop, udev);
|
|
|
671555 |
|
|
|
671555 |
- monitor = udev_monitor_new_from_netlink(conf->udev, "udev");
|
|
|
671555 |
+ monitor = udev_monitor_new_from_netlink(udev, "udev");
|
|
|
671555 |
if (!monitor) {
|
|
|
671555 |
condlog(2, "failed to create udev monitor");
|
|
|
671555 |
goto out;
|
|
|
671555 |
Index: multipath-tools-130222/libmultipath/uevent.h
|
|
|
671555 |
===================================================================
|
|
|
671555 |
--- multipath-tools-130222.orig/libmultipath/uevent.h
|
|
|
671555 |
+++ multipath-tools-130222/libmultipath/uevent.h
|
|
|
671555 |
@@ -13,6 +13,8 @@
|
|
|
671555 |
#define NETLINK_KOBJECT_UEVENT 15
|
|
|
671555 |
#endif
|
|
|
671555 |
|
|
|
671555 |
+struct udev;
|
|
|
671555 |
+
|
|
|
671555 |
struct uevent {
|
|
|
671555 |
struct list_head node;
|
|
|
671555 |
struct udev_device *udev;
|
|
|
671555 |
@@ -27,7 +29,7 @@ struct uevent {
|
|
|
671555 |
int is_uevent_busy(void);
|
|
|
671555 |
void setup_thread_attr(pthread_attr_t *attr, size_t stacksize, int detached);
|
|
|
671555 |
|
|
|
671555 |
-int uevent_listen(void);
|
|
|
671555 |
+int uevent_listen(struct udev *udev);
|
|
|
671555 |
int uevent_dispatch(int (*store_uev)(struct uevent *, void * trigger_data),
|
|
|
671555 |
void * trigger_data);
|
|
|
671555 |
int uevent_get_major(struct uevent *uev);
|
|
|
671555 |
Index: multipath-tools-130222/multipathd/main.c
|
|
|
671555 |
===================================================================
|
|
|
671555 |
--- multipath-tools-130222.orig/multipathd/main.c
|
|
|
671555 |
+++ multipath-tools-130222/multipathd/main.c
|
|
|
671555 |
@@ -840,7 +840,7 @@ out:
|
|
|
671555 |
static void *
|
|
|
671555 |
ueventloop (void * ap)
|
|
|
671555 |
{
|
|
|
671555 |
- if (uevent_listen())
|
|
|
671555 |
+ if (uevent_listen(udev))
|
|
|
671555 |
condlog(0, "error starting uevent listener");
|
|
|
671555 |
|
|
|
671555 |
return NULL;
|
|
|
671555 |
@@ -1593,7 +1593,7 @@ static int
|
|
|
671555 |
child (void * param)
|
|
|
671555 |
{
|
|
|
671555 |
pthread_t check_thr, uevent_thr, uxlsnr_thr, uevq_thr;
|
|
|
671555 |
- pthread_attr_t log_attr, misc_attr;
|
|
|
671555 |
+ pthread_attr_t log_attr, misc_attr, uevent_attr;
|
|
|
671555 |
struct vectors * vecs;
|
|
|
671555 |
struct multipath * mpp;
|
|
|
671555 |
int i;
|
|
|
671555 |
@@ -1606,6 +1606,7 @@ child (void * param)
|
|
|
671555 |
udev = udev_new();
|
|
|
671555 |
|
|
|
671555 |
setup_thread_attr(&misc_attr, 64 * 1024, 1);
|
|
|
671555 |
+ setup_thread_attr(&uevent_attr, 128 * 1024, 1);
|
|
|
671555 |
setup_thread_attr(&waiter_attr, 32 * 1024, 1);
|
|
|
671555 |
|
|
|
671555 |
if (logsink) {
|
|
|
671555 |
@@ -1671,10 +1672,11 @@ child (void * param)
|
|
|
671555 |
/*
|
|
|
671555 |
* Start uevent listener early to catch events
|
|
|
671555 |
*/
|
|
|
671555 |
- if ((rc = pthread_create(&uevent_thr, &misc_attr, ueventloop, vecs))) {
|
|
|
671555 |
+ if ((rc = pthread_create(&uevent_thr, &uevent_attr, ueventloop, udev))) {
|
|
|
671555 |
condlog(0, "failed to create uevent thread: %d", rc);
|
|
|
671555 |
exit(1);
|
|
|
671555 |
}
|
|
|
671555 |
+ pthread_attr_destroy(&uevent_attr);
|
|
|
671555 |
if ((rc = pthread_create(&uxlsnr_thr, &misc_attr, uxlsnrloop, vecs))) {
|
|
|
671555 |
condlog(0, "failed to create cli listener: %d", rc);
|
|
|
671555 |
exit(1);
|