From 5cfd4553d163b96c9c409db68264d1b6af2fe49e Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Sun, 29 Dec 2019 17:35:13 +0200 Subject: afr: simplify afr_has_quorum() 1. Perform AFR_COUNT() once, in afr_has_quorum() and pass the result to afr_lookup_has_quorum() 2. Simplify afr_lookup_has_quorum() - pass less parameters to it. (Via the change in item 1 above). 3. Make afr_is_add_replica_mount_lookup_on_root() static function. 4. Remove dead code - afr_decide_heal_info() which was not used. Change-Id: If9168cd01e22788a0e60b91e315787d2aa60e97b updates: bz#1193929 Signed-off-by: Yaniv Kaul --- xlators/cluster/afr/src/afr-common.c | 33 +++++++------------------------ xlators/cluster/afr/src/afr-transaction.c | 2 +- xlators/cluster/afr/src/afr.h | 4 ++-- 3 files changed, 10 insertions(+), 29 deletions(-) (limited to 'xlators/cluster/afr/src') diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c index 15c926b52c8..a2f0b2ad1c2 100644 --- a/xlators/cluster/afr/src/afr-common.c +++ b/xlators/cluster/afr/src/afr-common.c @@ -6707,21 +6707,6 @@ out: return changelog; } -gf_boolean_t -afr_decide_heal_info(afr_private_t *priv, unsigned char *sources, int source) -{ - int sources_count = 0; - - if (source < 0) - goto out; - - sources_count = AFR_COUNT(sources, priv->child_count); - if (sources_count == priv->child_count) - return _gf_false; -out: - return _gf_true; -} - static dict_t * afr_set_heal_info(char *status) { @@ -7791,16 +7776,16 @@ afr_ta_has_quorum(afr_private_t *priv, afr_local_t *local) return _gf_false; } -gf_boolean_t +static gf_boolean_t afr_is_add_replica_mount_lookup_on_root(call_frame_t *frame) { afr_local_t *local = NULL; - local = frame->local; - if (frame->root->pid != GF_CLIENT_PID_ADD_REPLICA_MOUNT) return _gf_false; + local = frame->local; + if (local->op != GF_FOP_LOOKUP) /* TODO:If the replica count is being increased on a plain distribute * volume that was never mounted, we need to allow setxattr on '/' with @@ -7817,15 +7802,11 @@ afr_is_add_replica_mount_lookup_on_root(call_frame_t *frame) } gf_boolean_t -afr_lookup_has_quorum(call_frame_t *frame, xlator_t *this, - unsigned char *subvols) +afr_lookup_has_quorum(call_frame_t *frame, const unsigned int up_children_count) { - afr_private_t *priv = this->private; - - if (frame && afr_is_add_replica_mount_lookup_on_root(frame)) { - if (AFR_COUNT(subvols, priv->child_count) > 0) - return _gf_true; - } + if (frame && (up_children_count > 0) && + afr_is_add_replica_mount_lookup_on_root(frame)) + return _gf_true; return _gf_false; } diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c index 88cb186dedb..78438f91331 100644 --- a/xlators/cluster/afr/src/afr-transaction.c +++ b/xlators/cluster/afr/src/afr-transaction.c @@ -873,7 +873,7 @@ afr_has_quorum(unsigned char *subvols, xlator_t *this, call_frame_t *frame) priv = this->private; up_children_count = AFR_COUNT(subvols, priv->child_count); - if (afr_lookup_has_quorum(frame, this, subvols)) + if (afr_lookup_has_quorum(frame, up_children_count)) return _gf_true; if (priv->quorum_count == AFR_QUORUM_AUTO) { diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h index e0aad4e38ff..88456562610 100644 --- a/xlators/cluster/afr/src/afr.h +++ b/xlators/cluster/afr/src/afr.h @@ -1380,8 +1380,8 @@ void afr_ta_locked_priv_invalidate(afr_private_t *priv); gf_boolean_t -afr_lookup_has_quorum(call_frame_t *frame, xlator_t *this, - unsigned char *subvols); +afr_lookup_has_quorum(call_frame_t *frame, + const unsigned int up_children_count); void afr_mark_new_entry_changelog(call_frame_t *frame, xlator_t *this); -- cgit