]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Remove `RGWSI_RADOS` from `RGWSI_Zone_Tools`
authorAdam C. Emerson <aemerson@redhat.com>
Fri, 2 Dec 2022 07:49:09 +0000 (02:49 -0500)
committerCasey Bodley <cbodley@redhat.com>
Wed, 29 Nov 2023 18:15:27 +0000 (13:15 -0500)
Simply use the RADOS handle directly.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/rgw/driver/rados/rgw_service.cc
src/rgw/services/svc_zone_utils.cc
src/rgw/services/svc_zone_utils.h

index b9b2d2a8415a5d8b6a234b048aa9d46e802a29f5..cf03d7b220deb5733b7868ec61ef1f6248f844e8 100644 (file)
@@ -110,7 +110,7 @@ int RGWServices_Def::init(CephContext *cct,
   otp->init(zone.get(), meta.get(), meta_be_otp.get());
   rados->init();
   zone->init(sysobj.get(), radoshandle, sync_modules.get(), bucket_sync_sobj.get());
-  zone_utils->init(rados.get(), zone.get());
+  zone_utils->init(radoshandle, zone.get());
   quota->init(zone.get());
   sync_modules->init(zone.get());
   sysobj_core->core_init(rados.get(), zone.get());
index 712bb97c9ba3ff0680055dd58efe5a3b743b8f2d..be9f861f02cc77d7bfbf01ff6a26f0b4bba7aae7 100644 (file)
@@ -5,6 +5,10 @@
 #include "svc_rados.h"
 #include "svc_zone.h"
 
+#undef FMT_HEADER_ONLY
+#define FMT_HEADER_ONLY 1
+#include <fmt/format.h>
+
 #include "rgw_zone.h"
 
 using namespace std;
@@ -18,26 +22,24 @@ int RGWSI_ZoneUtils::do_start(optional_yield, const DoutPrefixProvider *dpp)
 
 string RGWSI_ZoneUtils::gen_host_id() {
   /* uint64_t needs 16, two '-' separators and a trailing null */
-  const string& zone_name = zone_svc->get_zone().name;
-  const string& zonegroup_name = zone_svc->get_zonegroup().get_name();
-  char charbuf[16 + zone_name.size() + zonegroup_name.size() + 2 + 1];
-  snprintf(charbuf, sizeof(charbuf), "%llx-%s-%s", (unsigned long long)rados_svc->instance_id(), zone_name.c_str(), zonegroup_name.c_str());
-  return string(charbuf);
+  return fmt::format("{}-{}-{}", rados->get_instance_id(),
+                    zone_svc->get_zone().name,
+                    zone_svc->get_zonegroup().get_name());
 }
 
 string RGWSI_ZoneUtils::unique_id(uint64_t unique_num)
 {
-  char buf[32];
-  snprintf(buf, sizeof(buf), ".%llu.%llu", (unsigned long long)rados_svc->instance_id(), (unsigned long long)unique_num);
-  string s = zone_svc->get_zone_params().get_id() + buf;
-  return s;
+  return fmt::format("{}.{}.{}",
+                    zone_svc->get_zone_params().get_id(),
+                    rados->get_instance_id(),
+                    unique_num);
 }
 
 void RGWSI_ZoneUtils::init_unique_trans_id_deps() {
-  char buf[16 + 2 + 1]; /* uint64_t needs 16, 2 hyphens add further 2 */
-
-  snprintf(buf, sizeof(buf), "-%llx-", (unsigned long long)rados_svc->instance_id());
-  url_encode(string(buf) + zone_svc->get_zone().name, trans_id_suffix);
+  url_encode(fmt::format("-{}-{}",
+                        rados->get_instance_id(),
+                        zone_svc->get_zone().name),
+            trans_id_suffix);
 }
 
 /* In order to preserve compatibility with Swift API, transaction ID
index 43e3fee8d93d5859e9510b8756f7feee81c15208..41b9400335b057ffa859d21449b60a4ddfa7f3ef 100644 (file)
@@ -6,21 +6,20 @@
 #include "rgw_service.h"
 
 
-class RGWSI_RADOS;
 class RGWSI_Zone;
 
 class RGWSI_ZoneUtils : public RGWServiceInstance
 {
   friend struct RGWServices_Def;
 
-  RGWSI_RADOS *rados_svc{nullptr};
+  librados::Rados* rados{nullptr};
   RGWSI_Zone *zone_svc{nullptr};
 
   std::string trans_id_suffix;
 
-  void init(RGWSI_RADOS *_rados_svc,
+  void init(librados::Rados* rados_,
             RGWSI_Zone *_zone_svc) {
-    rados_svc = _rados_svc;
+    rados = rados_;
     zone_svc = _zone_svc;
   }