device-mapper-multipath/0042-multipathd-move-vecs-desctruction-into-cleanup-funct.patch
Benjamin Marzinski b05147c356 device-mapper-multipath-0.8.5-6
Change patch format to remove Git version
  * Patches 0001-0122 only have the patch format modified
Update to the head of the upstream staging branch plus redhat patches
  * Patches 0123-0134 & 1036-0142 are from the upstream staging branch
  * Patches 0143-1046 have been submitted upstream
  * Patch 0156 is a Red Hat only patch. Red Hat udev rules set ID_SERIAL
    from 60-persistent-storage.rules instead of 55-scsi-sg3_id.rules.
    Multipath's parse_vpd_pg83() function needs to match the ID_SERIAL
    value from udev.
Rename files
  * Previous patches 0123-0132 are now patches 1035 & 0147-0155
2021-03-26 13:33:56 -05:00

123 lines
3.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Wed, 23 Sep 2020 18:05:40 +0200
Subject: [PATCH] multipathd: move vecs desctruction into cleanup function
This will make it easer to move the stuff around later.
The only functional change is that map destuction now happens after
joining all threads, which should actually improve robustness.
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
multipathd/main.c | 64 +++++++++++++++++++++++++++++------------------
1 file changed, 40 insertions(+), 24 deletions(-)
diff --git a/multipathd/main.c b/multipathd/main.c
index abc6a9f7..3da0d7cc 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -148,7 +148,7 @@ int should_exit(void)
/*
* global copy of vecs for use in sig handlers
*/
-struct vectors * gvecs;
+static struct vectors * gvecs;
struct config *multipath_conf;
@@ -2889,6 +2889,44 @@ set_oom_adj (void)
condlog(0, "couldn't adjust oom score");
}
+static void cleanup_maps(struct vectors *vecs)
+{
+ int queue_without_daemon, i;
+ struct multipath *mpp;
+ struct config *conf;
+
+ conf = get_multipath_config();
+ queue_without_daemon = conf->queue_without_daemon;
+ put_multipath_config(conf);
+ if (queue_without_daemon == QUE_NO_DAEMON_OFF)
+ vector_foreach_slot(vecs->mpvec, mpp, i)
+ dm_queue_if_no_path(mpp->alias, 0);
+ remove_maps_and_stop_waiters(vecs);
+ vecs->mpvec = NULL;
+}
+
+static void cleanup_paths(struct vectors *vecs)
+{
+ free_pathvec(vecs->pathvec, FREE_PATHS);
+ vecs->pathvec = NULL;
+}
+
+static void cleanup_vecs(void)
+{
+ if (!gvecs)
+ return;
+ /*
+ * We can't take the vecs lock here, because exit() may
+ * have been called from the child() thread, holding the lock already.
+ * Anyway, by the time we get here, all threads that might access
+ * vecs should have been joined already (in cleanup_threads).
+ */
+ cleanup_maps(gvecs);
+ cleanup_paths(gvecs);
+ pthread_mutex_destroy(&gvecs->lock.mutex);
+ FREE(gvecs);
+}
+
/*
* Use a non-default call_rcu_data for child().
*
@@ -2937,13 +2975,10 @@ child (__attribute__((unused)) void *param)
pthread_t check_thr, uevent_thr, uxlsnr_thr, uevq_thr, dmevent_thr;
pthread_attr_t log_attr, misc_attr, uevent_attr;
struct vectors * vecs;
- struct multipath * mpp;
- int i;
int rc;
int pid_fd = -1;
struct config *conf;
char *envp;
- int queue_without_daemon;
enum daemon_status state;
mlockall(MCL_CURRENT | MCL_FUTURE);
@@ -3108,17 +3143,6 @@ child (__attribute__((unused)) void *param)
if (poll_dmevents)
pthread_cancel(dmevent_thr);
- conf = get_multipath_config();
- queue_without_daemon = conf->queue_without_daemon;
- put_multipath_config(conf);
-
- lock(&vecs->lock);
- if (queue_without_daemon == QUE_NO_DAEMON_OFF)
- vector_foreach_slot(vecs->mpvec, mpp, i)
- dm_queue_if_no_path(mpp->alias, 0);
- remove_maps_and_stop_waiters(vecs);
- unlock(&vecs->lock);
-
pthread_join(check_thr, NULL);
pthread_join(uevent_thr, NULL);
pthread_join(uxlsnr_thr, NULL);
@@ -3128,15 +3152,7 @@ child (__attribute__((unused)) void *param)
stop_io_err_stat_thread();
- lock(&vecs->lock);
- free_pathvec(vecs->pathvec, FREE_PATHS);
- vecs->pathvec = NULL;
- unlock(&vecs->lock);
-
- pthread_mutex_destroy(&vecs->lock.mutex);
- FREE(vecs);
- vecs = NULL;
-
+ cleanup_vecs();
cleanup_foreign();
cleanup_checkers();
cleanup_prio();