All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bart.vanassche@sandisk.com>
To: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Subject: [PATCH 2/2] multipathd: Avoid that a deadlock is triggered sporadically during shutdown
Date: Fri, 14 Oct 2016 08:35:47 -0700	[thread overview]
Message-ID: <5832949e-aa89-ebf2-11e1-67bbb4d050bf@sandisk.com> (raw)
In-Reply-To: <a7920385-9f76-d029-48dd-31ebcb06a212@sandisk.com>

pthread_cond_wait() is a thread cancellation point. If a thread that
is waiting in pthread_cond_wait() is canceled it is possible that the
mutex is re-acquired before the first cancellation cleanup handler
is called. In this case the cleanup handler is uevq_stop() and that
function locks uevq_lock. Avoid that calling uevq_stop() results in
a deadlock due to an attempt to lock a non-recursive mutex recursively.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 libmultipath/uevent.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
index 6247898..85fd2fb 100644
--- a/libmultipath/uevent.c
+++ b/libmultipath/uevent.c
@@ -52,7 +52,7 @@ typedef int (uev_trigger)(struct uevent *, void * trigger_data);
 
 pthread_t uevq_thr;
 LIST_HEAD(uevq);
-pthread_mutex_t uevq_lock = PTHREAD_MUTEX_INITIALIZER;
+pthread_mutex_t uevq_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
 pthread_mutex_t *uevq_lockp = &uevq_lock;
 pthread_cond_t uev_cond = PTHREAD_COND_INITIALIZER;
 pthread_cond_t *uev_condp = &uev_cond;
-- 
2.10.0

  parent reply	other threads:[~2016-10-14 15:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-14 15:33 [PATCH 0/2] Two multipath-tools bug fixes Bart Van Assche
2016-10-14 15:34 ` [PATCH 1/2] multipathd: Avoid "socket operation on non-socket" errors Bart Van Assche
2016-10-14 15:35 ` Bart Van Assche [this message]
2016-10-20 22:28   ` [PATCH 2/2] multipathd: Avoid that a deadlock is triggered sporadically during shutdown Xose Vazquez Perez
2016-10-20 22:47     ` Bart Van Assche
2016-10-16  7:52 ` [PATCH 0/2] Two multipath-tools bug fixes Christophe Varoqui

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=5832949e-aa89-ebf2-11e1-67bbb4d050bf@sandisk.com \
    --to=bart.vanassche@sandisk.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.