|
|
96a22b |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
96a22b |
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
96a22b |
Date: Sat, 21 Mar 2020 23:49:59 -0500
|
|
|
96a22b |
Subject: [PATCH] libmutipath: don't close fd on dm_lib_release
|
|
|
96a22b |
|
|
|
96a22b |
If dm_hold_control_open() isn't set, when dm_lib_release() is called, it
|
|
|
96a22b |
will close the control fd. The control fd will get re-opened on the next
|
|
|
96a22b |
dm_task_run() call, but if there is a dm_task_run() call already
|
|
|
96a22b |
in progress in another thread, it can fail. Since many of the
|
|
|
96a22b |
device-mapper callouts happen with the vecs lock held, this wasn't too
|
|
|
96a22b |
noticeable, but there is code that calls dm_task_run() without the
|
|
|
96a22b |
vecs lock held, notably the dmevent waiter code.
|
|
|
96a22b |
|
|
|
96a22b |
Since, as Martin pointed out, dm_hold_control_open() hasn't always
|
|
|
96a22b |
existed in libdevmapper, check if it's supported on compilation,
|
|
|
96a22b |
and update the version requirements if so.
|
|
|
96a22b |
|
|
|
96a22b |
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
|
96a22b |
---
|
|
|
96a22b |
libmultipath/Makefile | 4 ++++
|
|
|
96a22b |
libmultipath/devmapper.c | 7 ++++++-
|
|
|
96a22b |
2 files changed, 10 insertions(+), 1 deletion(-)
|
|
|
96a22b |
|
|
|
96a22b |
diff --git a/libmultipath/Makefile b/libmultipath/Makefile
|
|
|
96a22b |
index e5651e49..ad690a49 100644
|
|
|
96a22b |
--- a/libmultipath/Makefile
|
|
|
96a22b |
+++ b/libmultipath/Makefile
|
|
|
96a22b |
@@ -36,6 +36,10 @@ ifneq ($(call check_func,dm_task_deferred_remove,/usr/include/libdevmapper.h),0)
|
|
|
96a22b |
CFLAGS += -DLIBDM_API_DEFERRED
|
|
|
96a22b |
endif
|
|
|
96a22b |
|
|
|
96a22b |
+ifneq ($(call check_func,dm_hold_control_dev,/usr/include/libdevmapper.h),0)
|
|
|
96a22b |
+ CFLAGS += -DLIBDM_API_HOLD_CONTROL
|
|
|
96a22b |
+endif
|
|
|
96a22b |
+
|
|
|
96a22b |
OBJS = memory.o parser.o vector.o devmapper.o callout.o \
|
|
|
96a22b |
hwtable.o blacklist.o util.o dmparser.o config.o \
|
|
|
96a22b |
structs.o discovery.o propsel.o dict.o \
|
|
|
96a22b |
diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
|
|
|
96a22b |
index bed8ddc6..13a1cf53 100644
|
|
|
96a22b |
--- a/libmultipath/devmapper.c
|
|
|
96a22b |
+++ b/libmultipath/devmapper.c
|
|
|
96a22b |
@@ -108,7 +108,9 @@ dm_lib_prereq (void)
|
|
|
96a22b |
{
|
|
|
96a22b |
char version[64];
|
|
|
96a22b |
int v[3];
|
|
|
96a22b |
-#if defined(LIBDM_API_DEFERRED)
|
|
|
96a22b |
+#if defined(LIBDM_API_HOLD_CONTROL)
|
|
|
96a22b |
+ int minv[3] = {1, 2, 111};
|
|
|
96a22b |
+#elif defined(LIBDM_API_DEFERRED)
|
|
|
96a22b |
int minv[3] = {1, 2, 89};
|
|
|
96a22b |
#elif defined(DM_SUBSYSTEM_UDEV_FLAG0)
|
|
|
96a22b |
int minv[3] = {1, 2, 82};
|
|
|
96a22b |
@@ -254,6 +256,9 @@ void libmp_dm_init(void)
|
|
|
96a22b |
memcpy(conf->version, version, sizeof(version));
|
|
|
96a22b |
put_multipath_config(conf);
|
|
|
96a22b |
dm_init(verbosity);
|
|
|
96a22b |
+#ifdef LIBDM_API_HOLD_CONTROL
|
|
|
96a22b |
+ dm_hold_control_dev(1);
|
|
|
96a22b |
+#endif
|
|
|
96a22b |
dm_udev_set_sync_support(libmp_dm_udev_sync);
|
|
|
96a22b |
}
|
|
|
96a22b |
|
|
|
96a22b |
--
|
|
|
96a22b |
2.17.2
|
|
|
96a22b |
|