diff options
author | Kaushal M <kaushal@redhat.com> | 2015-03-24 12:15:19 +0530 |
---|---|---|
committer | Krishnan Parthasarathi <kparthas@redhat.com> | 2015-03-25 04:36:06 -0700 |
commit | 891c7d0fad16e7f0f51af217a8aad0a653a353d7 (patch) | |
tree | a22b1cccb8361819fac6ec91d2e17e6cd50fb77b /xlators/mgmt | |
parent | fb81ee019655f8ce56f1610568526e51c49e8a11 (diff) |
glusterd: Prevent possible deadlock due to glusterd_quorum_count
Also rename the macro glusterd_quorum_count to GLUSTERD_QUORUM_COUNT so
that it stands out as a macro.
This change was developed on the git branch at [1]. This commit is a
combination of the following commits on the development branch.
0fbd7ba Prevent possible deadlock due to glusterd_quorum_count
5da3062 Rename glusterd_quorum_count to GLUSTERD_QUORUM_COUNT
b3aa3c4 Enclose GLUSTERD_QUORUM_COUNT definition in a do-while block
[1]: https://github.com/kshlm/glusterfs/tree/urcu
Change-Id: Ic4b3949f303d72ce53e0139f62b83b8d13fb4e47
BUG: 1205186
Signed-off-by: Kaushal M <kaushal@redhat.com>
Reviewed-on: http://review.gluster.org/9978
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-by: Gaurav Kumar Garg <ggarg@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 11 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.h | 3 |
2 files changed, 8 insertions, 6 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 02d2cfb0932..03cebdc518a 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -2920,25 +2920,24 @@ glusterd_get_quorum_cluster_counts (xlator_t *this, int *active_count, if (active_count) *active_count = 1; + rcu_read_lock (); if (!peer_list) { - rcu_read_lock (); cds_list_for_each_entry_rcu (peerinfo, &conf->peers, uuid_list) { - glusterd_quorum_count(peerinfo, inquorum_count, + GLUSTERD_QUORUM_COUNT(peerinfo, inquorum_count, active_count, out); } - rcu_read_unlock (); } else { if (_local_xaction_peers) { list_for_each_local_xaction_peers (peerinfo, peer_list) { - glusterd_quorum_count(peerinfo, inquorum_count, + GLUSTERD_QUORUM_COUNT(peerinfo, inquorum_count, active_count, out); } } else { cds_list_for_each_entry (peerinfo, peer_list, op_peers_list) { - glusterd_quorum_count(peerinfo, inquorum_count, + GLUSTERD_QUORUM_COUNT(peerinfo, inquorum_count, active_count, out); } } @@ -2959,6 +2958,8 @@ glusterd_get_quorum_cluster_counts (xlator_t *this, int *active_count, *quorum_count = count; ret = 0; out: + rcu_read_unlock (); + return ret; } diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h index 1956029192a..f923bfad757 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.h +++ b/xlators/mgmt/glusterd/src/glusterd-utils.h @@ -37,13 +37,14 @@ volinfo->volname, brickid);\ } while (0) -#define glusterd_quorum_count(peerinfo, inquorum_count, active_count, _exit)\ +#define GLUSTERD_QUORUM_COUNT(peerinfo, inquorum_count, active_count, _exit) do {\ if (peerinfo->quorum_contrib == QUORUM_WAITING)\ goto _exit;\ if (_is_contributing_to_quorum (peerinfo->quorum_contrib))\ inquorum_count = inquorum_count + 1;\ if (active_count && (peerinfo->quorum_contrib == QUORUM_UP))\ *active_count = *active_count + 1;\ +} while (0) struct glusterd_lock_ { uuid_t owner; |