afr: remove unreachable halo threshold override branch#4682
Open
ThalesBarretto wants to merge 1 commit into
Open
afr: remove unreachable halo threshold override branch#4682ThalesBarretto wants to merge 1 commit into
ThalesBarretto wants to merge 1 commit into
Conversation
In __afr_handle_ping_event(), the inner check "(up_children - 1) < halo_min_replicas" is always false when the outer guard "up_children > halo_min_replicas" holds, since up_children > min implies up_children - 1 >= min. The "Overriding halo threshold" log message is never emitted. Remove the dead branch and collapse the if/else. Fixes: gluster#4683 Signed-off-by: Thales Antunes de Oliveira Barretto <thales.barretto.git@gmail.com>
8766abe to
b1d90a3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #4683
In
__afr_handle_ping_event(), the inner check(up_children - 1) < priv->halo_min_replicasis algebraically unreachable when the outer guardup_children > priv->halo_min_replicasholds. The "Overriding halo threshold" log message is never emitted.Algebraic proof
The outer guard requires
up_children > halo_min_replicas. For non-negative integers, this impliesup_children >= halo_min_replicas + 1, thereforeup_children - 1 >= halo_min_replicas. The inner check(up_children - 1) < halo_min_replicasis the negation of this — always FALSE.Signed/unsigned:
up_childrenisint(computed by countingchild_up[i] == 1, always non-negative).halo_min_replicasisuint32_t. The implicitint→unsignedpromotion is safe becauseup_childrenis non-negative and both values are bounded bychild_count. No overflow or sign-conversion hazard.Provenance
Dead from birth. The outer guard has been
>(strict greater-than) since the first halo prototype in 2014. See #4683 for the full git archaeology.>with inner check< min. Dead from birth.find_worst_up_child(this) == idx— a reachable check.cluster/afr: Fixes for halo(bz#1800583). Addedhalo_child_up[]guards to the live branch but did not touch the dead branch.Fix
Remove the dead branch, collapse the if/else. No behavior change — the dead branch only logged and never executed.
Build verified:
make -C xlators/cluster/afr/src— zero errors, zero warnings.