diff options
author | Sanju Rakonde <srakonde@redhat.com> | 2018-11-28 16:13:58 +0530 |
---|---|---|
committer | Atin Mukherjee <amukherj@redhat.com> | 2018-12-03 17:03:57 +0000 |
commit | 2bb0e89e4bb113a93c6e786446a140cd99261af8 (patch) | |
tree | 4e3ad012d934fb471b60bbd3b18fd61f4fc4c8cf /xlators/mgmt/glusterd/src/glusterd.h | |
parent | 220722b426f4014abdca0c719b2ca4e3aefeecc4 (diff) |
glusterd: perform rcu_read_lock/unlock() under cleanup_lock mutex
Problem: glusterd should not try to acquire locks on any resources,
when it already received a SIGTERM and cleanup is started. Otherwise
we might hit segfault, since the thread which is going through
cleanup path will be freeing up the resouces and some other thread
might be trying to acquire locks on freed resources.
Solution: perform rcu_read_lock/unlock() under cleanup_lock mutex.
fixes: bz#1654270
Change-Id: I87a97cfe4f272f74f246d688660934638911ce54
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd.h')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h index b0a7d9a448d..be1eed04a68 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -925,6 +925,20 @@ typedef ssize_t (*gd_serialize_t)(struct iovec outmsg, void *args); *snap_volname_ptr = '\0'; \ } while (0) +#define RCU_READ_LOCK \ + pthread_mutex_lock(&(THIS->ctx)->cleanup_lock); \ + { \ + rcu_read_lock(); \ + } \ + pthread_mutex_unlock(&(THIS->ctx)->cleanup_lock); + +#define RCU_READ_UNLOCK \ + pthread_mutex_lock(&(THIS->ctx)->cleanup_lock); \ + { \ + rcu_read_unlock(); \ + } \ + pthread_mutex_unlock(&(THIS->ctx)->cleanup_lock); + #define GLUSTERD_DUMP_PEERS(head, member, xpeers) \ do { \ glusterd_peerinfo_t *_peerinfo = NULL; \ @@ -933,7 +947,7 @@ typedef ssize_t (*gd_serialize_t)(struct iovec outmsg, void *args); \ key = xpeers ? "glusterd.xaction_peer" : "glusterd.peer"; \ \ - rcu_read_lock(); \ + RCU_READ_LOCK; \ cds_list_for_each_entry_rcu(_peerinfo, head, member) \ { \ glusterd_dump_peer(_peerinfo, key, index, xpeers); \ @@ -941,7 +955,7 @@ typedef ssize_t (*gd_serialize_t)(struct iovec outmsg, void *args); glusterd_dump_peer_rpcstat(_peerinfo, key, index); \ index++; \ } \ - rcu_read_unlock(); \ + RCU_READ_UNLOCK; \ \ } while (0) |