]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: rename round-robin counters for brevity
authorOguzhan Ozmen <oozmen@bloomberg.net>
Tue, 3 Mar 2026 20:46:38 +0000 (20:46 +0000)
committerOguzhan Ozmen <oozmen@bloomberg.net>
Wed, 3 Jun 2026 11:04:29 +0000 (11:04 +0000)
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 <oozmen@bloomberg.net>
src/rgw/rgw_rest_conn.cc
src/rgw/rgw_rest_conn.h

index 6d27faa27c5dfd650e7ca89f068d6a7468746c55..c0060c8fbdb89f32ef0a36ef57e4b1ff8da60de8 100644 (file)
@@ -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<double>(ceph::real_clock::now() - last_fail);
+    auto diff = ceph::to_seconds<double>(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];
index 325a9ab7a1d9f084f27f6765c9d40b191b269da0..82794867e565092a965a57678ecffd00642fad9a 100644 (file)
@@ -111,7 +111,7 @@ struct ResolvedEndpoint {
   std::string host;               // e.g., "s3.abc.com"
   int port = -1;                  // e.g., 8443
   std::vector<ResolvedIP> 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<size_t> ip_rr_index{0};    // round-robin index for IPs
   mutable std::atomic<ceph::real_time> 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<int64_t> endpoint_round_robin_counter = { 0 }; // Round-robin counter for resolved_endpoints
+  std::atomic<int64_t> endpoint_rr_index = { 0 }; // Round-robin counter for resolved_endpoints
   std::vector<ResolvedEndpoint> resolved_endpoints;
   RGWAccessKey key;
   std::string self_zone_group;