Skip to content

afr: remove unreachable halo threshold override branch#4682

Open
ThalesBarretto wants to merge 1 commit into
gluster:develfrom
ThalesBarretto:fix-afr-halo-dead-code
Open

afr: remove unreachable halo threshold override branch#4682
ThalesBarretto wants to merge 1 commit into
gluster:develfrom
ThalesBarretto:fix-afr-halo-dead-code

Conversation

@ThalesBarretto

@ThalesBarretto ThalesBarretto commented May 26, 2026

Copy link
Copy Markdown
Contributor

Fixes: #4683

In __afr_handle_ping_event(), the inner check (up_children - 1) < priv->halo_min_replicas is algebraically unreachable when the outer guard up_children > priv->halo_min_replicas holds. 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 implies up_children >= halo_min_replicas + 1, therefore up_children - 1 >= halo_min_replicas. The inner check (up_children - 1) < halo_min_replicas is the negation of this — always FALSE.

Signed/unsigned: up_children is int (computed by counting child_up[i] == 1, always non-negative). halo_min_replicas is uint32_t. The implicit int→unsigned promotion is safe because up_children is non-negative and both values are bounded by child_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.

Date Commit Author What happened
2014-04-29 bbceb48 Richard Wareing (FB) First halo prototype. Outer guard > with inner check < min. Dead from birth.
2014-09-08 7a6ead5 Richard Wareing (FB) Replaced the dead branch with find_worst_up_child(this) == idx — a reachable check.
2017-03-21 ca10139 Kevin Vigor (FB) Squash-merged halo to upstream (Gerrit 16099 / 16177). Based on a version that predated Wareing's 7a6ead5 fix — the dead branch was re-introduced.
2020-02-04 4bb65d6 Pranith Kumar K (RH) cluster/afr: Fixes for halo (bz#1800583). Added halo_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.

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>
@ThalesBarretto ThalesBarretto force-pushed the fix-afr-halo-dead-code branch from 8766abe to b1d90a3 Compare May 26, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

afr: dead code in halo threshold override branch (__afr_handle_ping_event)

1 participant