From: Oguzhan Ozmen Date: Tue, 3 Mar 2026 20:46:38 +0000 (+0000) Subject: rgw: rename round-robin counters for brevity X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9f0c1093a002f4de94201cb54c1c733f5828e965;p=ceph.git rgw: rename round-robin counters for brevity Rename endpoint_round_robin_counter to endpoint_rr_index and endpoint_ips_round_robin_counter to ip_rr_index for shorter, cleaner variable names while maintaining clarity. Signed-off-by: Oguzhan Ozmen --- diff --git a/src/rgw/rgw_rest_conn.cc b/src/rgw/rgw_rest_conn.cc index 6d27faa27c5..c0060c8fbdb 100644 --- a/src/rgw/rgw_rest_conn.cc +++ b/src/rgw/rgw_rest_conn.cc @@ -124,7 +124,7 @@ RGWRESTConn::RGWRESTConn(CephContext *_cct, RGWRESTConn::RGWRESTConn(RGWRESTConn&& other) : cct(other.cct), - endpoint_round_robin_counter(other.endpoint_round_robin_counter.load()), + endpoint_rr_index(other.endpoint_rr_index.load()), resolved_endpoints(std::move(other.resolved_endpoints)), key(std::move(other.key)), self_zone_group(std::move(other.self_zone_group)), @@ -137,7 +137,7 @@ RGWRESTConn::RGWRESTConn(RGWRESTConn&& other) RGWRESTConn& RGWRESTConn::operator=(RGWRESTConn&& other) { cct = other.cct; - endpoint_round_robin_counter = other.endpoint_round_robin_counter.load(); + endpoint_rr_index = other.endpoint_rr_index.load(); resolved_endpoints = std::move(other.resolved_endpoints); key = std::move(other.key); self_zone_group = std::move(other.self_zone_group); @@ -169,10 +169,11 @@ void RGWRESTConn::populate_connect_to(RGWEndpoint& endpoint, ResolvedEndpoint& r const auto ip_fail_timeout = cct->_conf->rgw_rest_conn_ip_fail_timeout_secs; const size_t num_ips = resolved_endpoint.resolved_ips.size(); + auto now = ceph::real_clock::now(); // Round-robin through IPs, skipping any that are marked down for (size_t i = 0; i < num_ips; ++i) { - size_t idx = resolved_endpoint.endpoint_ips_round_robin_counter++ % num_ips; + size_t idx = resolved_endpoint.ip_rr_index++ % num_ips; ResolvedIP& ip_status = resolved_endpoint.resolved_ips[idx]; const auto& last_fail = ip_status.last_failure.load(); @@ -181,7 +182,7 @@ void RGWRESTConn::populate_connect_to(RGWEndpoint& endpoint, ResolvedEndpoint& r return; } - auto diff = ceph::to_seconds(ceph::real_clock::now() - last_fail); + auto diff = ceph::to_seconds(now - last_fail); if (diff >= ip_fail_timeout) { // Failure expired, mark IP as up and use it ip_status.mark_up(); @@ -238,7 +239,7 @@ int RGWRESTConn::get_endpoint(RGWEndpoint& endpoint) size_t num = 0; size_t selected_idx = 0; while (num < resolved_endpoints.size()) { - int i = ++endpoint_round_robin_counter; + int i = ++endpoint_rr_index; selected_idx = i % resolved_endpoints.size(); ResolvedEndpoint& res_ep = resolved_endpoints[selected_idx]; diff --git a/src/rgw/rgw_rest_conn.h b/src/rgw/rgw_rest_conn.h index 325a9ab7a1d..82794867e56 100644 --- a/src/rgw/rgw_rest_conn.h +++ b/src/rgw/rgw_rest_conn.h @@ -111,7 +111,7 @@ struct ResolvedEndpoint { std::string host; // e.g., "s3.abc.com" int port = -1; // e.g., 8443 std::vector resolved_ips; // Per-IP connect_to strings with health status - mutable size_t endpoint_ips_round_robin_counter = 0; // round-robin index for IPs + mutable std::atomic ip_rr_index{0}; // round-robin index for IPs mutable std::atomic last_failure_time; // most recent IP failure seen on this endpoint ResolvedEndpoint() : last_failure_time(ceph::real_clock::zero()) {} @@ -123,7 +123,7 @@ struct ResolvedEndpoint { host(std::move(other.host)), port(other.port), resolved_ips(std::move(other.resolved_ips)), - endpoint_ips_round_robin_counter(other.endpoint_ips_round_robin_counter), + ip_rr_index(other.ip_rr_index.load()), last_failure_time(other.last_failure_time.load()) {} @@ -134,7 +134,7 @@ struct ResolvedEndpoint { host = std::move(other.host); port = other.port; resolved_ips = std::move(other.resolved_ips); - endpoint_ips_round_robin_counter = other.endpoint_ips_round_robin_counter; + ip_rr_index.store(other.ip_rr_index.load()); last_failure_time.store(other.last_failure_time.load()); return *this; } @@ -155,7 +155,7 @@ struct ResolvedEndpoint { class RGWRESTConn { CephContext *cct; - std::atomic endpoint_round_robin_counter = { 0 }; // Round-robin counter for resolved_endpoints + std::atomic endpoint_rr_index = { 0 }; // Round-robin counter for resolved_endpoints std::vector resolved_endpoints; RGWAccessKey key; std::string self_zone_group;