Linux Device Mapper development
 help / color / mirror / Atom feed
From: "Benjamin Marzinski" <bmarzins@redhat.com>
To: device-mapper development <dm-devel@redhat.com>
Cc: Martin Wilck <mwilck@suse.com>
Subject: [PATCH 3/3] multipathd: stop waiter in __setup_multipath
Date: Fri, 16 Mar 2018 16:31:07 -0500	[thread overview]
Message-ID: <1521235867-29476-4-git-send-email-bmarzins@redhat.com> (raw)
In-Reply-To: <1521235867-29476-1-git-send-email-bmarzins@redhat.com>

__setup_multipath can remove a multipath device from multipathd, and it
can be called by either by the waiter thread or another thread.
Previously, it dealt with this by never stopping the waiter thread.  It
simply relied on the waiter thread to notice and stop itself.  Now, when
called by another thread, it explicitly stops the waiter thread.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 multipathd/main.c   | 2 +-
 multipathd/waiter.c | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/multipathd/main.c b/multipathd/main.c
index 70aff5d..3ae0442 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -398,7 +398,7 @@ int __setup_multipath(struct vectors *vecs, struct multipath *mpp,
 
 	return 0;
 out:
-	remove_map(mpp, vecs, PURGE_VEC);
+	remove_map_and_stop_waiter(mpp, vecs, PURGE_VEC);
 	return 1;
 }
 
diff --git a/multipathd/waiter.c b/multipathd/waiter.c
index c70ad21..595c69a 100644
--- a/multipathd/waiter.c
+++ b/multipathd/waiter.c
@@ -57,6 +57,11 @@ void stop_waiter_thread (struct multipath *mpp, struct vectors *vecs)
 			mpp->alias);
 		return;
 	}
+	/* Don't cancel yourself. __setup_multipath is called by
+	   by the waiter thread, and may remove a multipath device */
+	if (pthread_equal(mpp->waiter, pthread_self()))
+		return;
+
 	condlog(2, "%s: stop event checker thread (%lu)", mpp->alias,
 		mpp->waiter);
 	thread = mpp->waiter;
-- 
2.7.4

  parent reply	other threads:[~2018-03-16 21:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-16 21:31 [PATCH 0/3] multipathd per-device waiter fixes Benjamin Marzinski
2018-03-16 21:31 ` [PATCH 1/3] multipathd: fix waiter thread cancelling Benjamin Marzinski
2018-03-19 12:59   ` Martin Wilck
2018-03-19 16:25     ` Benjamin Marzinski
2018-03-19 20:02       ` Martin Wilck
2018-03-16 21:31 ` [PATCH 2/3] multipathd: move __setup_multipath to multipathd Benjamin Marzinski
2018-03-19 13:07   ` Martin Wilck
2018-03-16 21:31 ` Benjamin Marzinski [this message]
2018-03-19 13:08   ` [PATCH 3/3] multipathd: stop waiter in __setup_multipath Martin Wilck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1521235867-29476-4-git-send-email-bmarzins@redhat.com \
    --to=bmarzins@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=mwilck@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox