summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2017-02-04 14:47:27 +0100
committerZdenek Kabelac <zkabelac@redhat.com>2017-02-05 17:55:37 +0100
commitdae4f53acb269219e876c229c8f034fcdaf3ff5a (patch)
treeb4e0fc369e8a690ad951276f75067ab8f51ba1ad
parenta4bbaa3b894f03e4ac21c979ec4e5201120703ad (diff)
downloadlvm2-dae4f53acb269219e876c229c8f034fcdaf3ff5a.tar.gz
clvmd: add mutex protection for cpg_ call
The library for corosync multicasting is not supporting multithread usage - add local mutex to avoid parallel call of cpg_mcast_joined().
-rw-r--r--WHATS_NEW1
-rw-r--r--daemons/clvmd/clvmd-corosync.c4
2 files changed, 5 insertions, 0 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index 1c0ef6d90..cbe6c059d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.169 -
=====================================
+ Avoid parallel usage of cpg_mcast_joined() in clvmd with corosync.
Support raid6_{ls,rs,la,ra}_6 segment types and conversions from/to it.
Support raid6_n_6 segment type and conversions from/to it.
Support raid5_n segment type and conversions from/to it.
diff --git a/daemons/clvmd/clvmd-corosync.c b/daemons/clvmd/clvmd-corosync.c
index 05c9882f6..2227cbf0a 100644
--- a/daemons/clvmd/clvmd-corosync.c
+++ b/daemons/clvmd/clvmd-corosync.c
@@ -532,6 +532,7 @@ static int _cluster_fd_callback(struct local_client *fd, char *buf, int len,
static int _cluster_send_message(const void *buf, int msglen, const char *csid,
const char *errtext)
{
+ static pthread_mutex_t _mutex = PTHREAD_MUTEX_INITIALIZER;
struct iovec iov[2];
cs_error_t err;
int target_node;
@@ -546,7 +547,10 @@ static int _cluster_send_message(const void *buf, int msglen, const char *csid,
iov[1].iov_base = (char *)buf;
iov[1].iov_len = msglen;
+ pthread_mutex_lock(&_mutex);
err = cpg_mcast_joined(cpg_handle, CPG_TYPE_AGREED, iov, 2);
+ pthread_mutex_unlock(&_mutex);
+
return cs_to_errno(err);
}