From 3023c4bd7651d4503830c36676cd08864e315cdf Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 13 Jun 2017 14:44:39 +0200 Subject: glusterd: streamline logic flow in glusterd_validate_quorum() Make an earlier exit when the volume is not of server quorum. Thereby it spares the actual quorum calculation in this case. This also increases the overall readability of the function. The patch is best seen with the --patience diff option to understand what it does (e.g. "git show --patience"). Change-Id: Ifce50bc3f73d79d3d6226473661a83696d65149a BUG: 1476719 Signed-off-by: Michael Adam Reviewed-on: https://review.gluster.org/17924 Smoke: Gluster Build System Tested-by: Atin Mukherjee CentOS-regression: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Atin Mukherjee --- xlators/mgmt/glusterd/src/glusterd-server-quorum.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-server-quorum.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-server-quorum.c b/xlators/mgmt/glusterd/src/glusterd-server-quorum.c index 37dec3d2d6b..468191cd27f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-server-quorum.c +++ b/xlators/mgmt/glusterd/src/glusterd-server-quorum.c @@ -99,17 +99,19 @@ glusterd_validate_quorum (xlator_t *this, glusterd_op_t op, goto out; } - if (does_gd_meet_server_quorum (this)) { + if (!glusterd_is_volume_in_server_quorum (volinfo)) { ret = 0; goto out; } - if (glusterd_is_volume_in_server_quorum (volinfo)) { - ret = -1; - *op_errstr = gf_strdup (errstr); + if (does_gd_meet_server_quorum (this)) { + ret = 0; goto out; } - ret = 0; + + ret = -1; + *op_errstr = gf_strdup (errstr); + out: return ret; } -- cgit