]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/rados: store SiteConfig with RGWServices
authorCasey Bodley <cbodley@redhat.com>
Sun, 4 Feb 2024 18:43:10 +0000 (13:43 -0500)
committerCasey Bodley <cbodley@redhat.com>
Tue, 5 Mar 2024 17:55:24 +0000 (12:55 -0500)
make the SiteConfig available to all of RGWRados via svc.site instead
of storing it in sal::RadosStore

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/driver/rados/rgw_rados.cc
src/rgw/driver/rados/rgw_rados.h
src/rgw/driver/rados/rgw_sal_rados.cc
src/rgw/driver/rados/rgw_sal_rados.h
src/rgw/driver/rados/rgw_service.cc
src/rgw/driver/rados/rgw_service.h
src/rgw/rgw_sal.cc
src/test/rgw/test_rgw_iam_policy.cc
src/test/rgw/test_rgw_lua.cc

index b8fcfa2f368fb04b4475695125e2f02ffaf4d4c3..18ff24f21813b977cd219494b73ae60ba80f9162 100644 (file)
@@ -1366,29 +1366,25 @@ int RGWRados::init_complete(const DoutPrefixProvider *dpp, optional_yield y)
   return ret;
 }
 
-int RGWRados::init_svc(bool raw, const DoutPrefixProvider *dpp)
+int RGWRados::init_svc(bool raw, const DoutPrefixProvider *dpp,
+                       const rgw::SiteConfig& site)
 {
   if (raw) {
-    return svc.init_raw(cct, driver, use_cache, null_yield, dpp);
+    return svc.init_raw(cct, driver, use_cache, null_yield, dpp, site);
   }
 
-  return svc.init(cct, driver, use_cache, run_sync_thread, null_yield, dpp);
-}
-
-int RGWRados::init_ctl(const DoutPrefixProvider *dpp)
-{
-  return ctl.init(&svc, driver, dpp);
+  return svc.init(cct, driver, use_cache, run_sync_thread, null_yield, dpp, site);
 }
 
 /** 
  * Initialize the RADOS instance and prepare to do other ops
  * Returns 0 on success, -ERR# on failure.
  */
-int RGWRados::init_begin(const DoutPrefixProvider *dpp)
+int RGWRados::init_begin(CephContext* _cct, const DoutPrefixProvider *dpp,
+                         const rgw::SiteConfig& site)
 {
-  int ret;
-
-  ret = driver->init_neorados(dpp);
+  set_context(_cct);
+  int ret = driver->init_neorados(dpp);
   if (ret < 0) {
     ldpp_dout(dpp, 0) << "ERROR: failed to initialize neorados (ret=" << cpp_strerror(-ret) << ")" << dendl;
     return ret;
@@ -1399,13 +1395,13 @@ int RGWRados::init_begin(const DoutPrefixProvider *dpp)
     return ret;
   }
 
-  ret = init_svc(false, dpp);
+  ret = init_svc(false, dpp, site);
   if (ret < 0) {
     ldpp_dout(dpp, 0) << "ERROR: failed to init services (ret=" << cpp_strerror(-ret) << ")" << dendl;
     return ret;
   }
 
-  ret = init_ctl(dpp);
+  ret = ctl.init(&svc, driver, dpp);
   if (ret < 0) {
     ldpp_dout(dpp, 0) << "ERROR: failed to init ctls (ret=" << cpp_strerror(-ret) << ")" << dendl;
     return ret;
index 7e7a58480a6534d560fc3467150434dba79120cd..f43b1b4e5314416d14148e58e7b76b79ba7e100e 100644 (file)
@@ -58,6 +58,7 @@ struct RGWZoneGroup;
 struct RGWZoneParams;
 class RGWReshard;
 class RGWReshardWait;
+namespace rgw { class SiteConfig; }
 
 struct get_obj_data;
 
@@ -593,15 +594,11 @@ public:
 
   CephContext *ctx() { return cct; }
   /** do all necessary setup of the storage device */
-  int init_begin(CephContext *_cct, const DoutPrefixProvider *dpp) {
-    set_context(_cct);
-    return init_begin(dpp);
-  }
+  int init_begin(CephContext *_cct, const DoutPrefixProvider *dpp,
+                         const rgw::SiteConfig& site);
   /** Initialize the RADOS instance and prepare to do other ops */
-  int init_svc(bool raw, const DoutPrefixProvider *dpp);
-  int init_ctl(const DoutPrefixProvider *dpp);
+  int init_svc(bool raw, const DoutPrefixProvider *dpp, const rgw::SiteConfig& site);
   virtual int init_rados();
-  int init_begin(const DoutPrefixProvider *dpp);
   int init_complete(const DoutPrefixProvider *dpp, optional_yield y);
   void finalize();
 
index 2bde7d192e5ac296f408e59d93792a8732db2763..6e4d346120e2bd9a580b1d40611fb8ce8803c7b4 100644 (file)
@@ -3953,11 +3953,10 @@ int RadosRole::delete_obj(const DoutPrefixProvider *dpp, optional_yield y)
 
 extern "C" {
 
-void* newRadosStore(void* io_context, const void* site_config)
+void* newRadosStore(void* io_context)
 {
   rgw::sal::RadosStore* store = new rgw::sal::RadosStore(
-    *static_cast<boost::asio::io_context*>(io_context),
-    *static_cast<const rgw::SiteConfig*>(site_config));
+    *static_cast<boost::asio::io_context*>(io_context));
   if (store) {
     RGWRados* rados = new RGWRados();
 
index 85612eec1a9ba58a078c5ea98eedee3bb5a28d63..e85b3fde1d4fc8b781f1377b65cb01b70a11deb6 100644 (file)
@@ -120,7 +120,6 @@ class RadosZone : public StoreZone {
 class RadosStore : public StoreDriver {
   private:
     boost::asio::io_context& io_context;
-    const rgw::SiteConfig& site_config;
     RGWRados* rados;
     RGWUserCtl* user_ctl;
     std::unique_ptr<RadosZone> zone;
@@ -128,9 +127,8 @@ class RadosStore : public StoreDriver {
     std::string topics_oid(const std::string& tenant) const;
 
   public:
-    RadosStore(boost::asio::io_context& io_context,
-              const rgw::SiteConfig& site_config)
-      : io_context(io_context), site_config(site_config), rados(nullptr) {
+    RadosStore(boost::asio::io_context& io_context)
+      : io_context(io_context), rados(nullptr) {
       }
     ~RadosStore() {
       delete rados;
@@ -285,7 +283,6 @@ class RadosStore : public StoreDriver {
     void setRados(RGWRados * st) { rados = st; }
     RGWRados* getRados(void) { return rados; }
     boost::asio::io_context& get_io_context() { return io_context; }
-    const rgw::SiteConfig& get_siteconfig() { return site_config; }
     neorados::RADOS& get_neorados() { return *neorados; }
 
     RGWServices* svc() { return &rados->svc; }
index 1f05495fb3d4617e06847ee97da5c768db9e392e..0c0e2bbea659d0c23620321ccee597c23a81c929 100644 (file)
@@ -314,9 +314,10 @@ void RGWServices_Def::shutdown()
   has_shutdown = true;
 }
 
-int RGWServices::do_init(CephContext *_cct, rgw::sal::RadosStore* driver, bool have_cache, bool raw, bool run_sync, optional_yield y, const DoutPrefixProvider *dpp)
+int RGWServices::do_init(CephContext *_cct, rgw::sal::RadosStore* driver, bool have_cache, bool raw, bool run_sync, optional_yield y, const DoutPrefixProvider *dpp, const rgw::SiteConfig& _site)
 {
   cct = _cct;
+  site = &_site;
 
   int r = _svc.init(cct, driver, have_cache, raw, run_sync, y, dpp);
   if (r < 0) {
index 08873e6058e5ada2f41a05e01853f847079cbc03..03b37f1ad5a200cfe97039bc7ca41ab5c334ae0d 100644 (file)
@@ -120,12 +120,14 @@ struct RGWServices_Def
   void shutdown();
 };
 
+namespace rgw { class SiteConfig; }
 
 struct RGWServices
 {
   RGWServices_Def _svc;
 
   CephContext *cct;
+  const rgw::SiteConfig* site{nullptr};
 
   RGWSI_Finisher *finisher{nullptr};
   RGWSI_Bucket *bucket{nullptr};
@@ -159,17 +161,19 @@ struct RGWServices
 
   int do_init(CephContext *cct, rgw::sal::RadosStore* store, bool have_cache,
              bool raw_storage, bool run_sync, optional_yield y,
-             const DoutPrefixProvider *dpp);
+             const DoutPrefixProvider *dpp, const rgw::SiteConfig& site);
 
   int init(CephContext *cct, rgw::sal::RadosStore* store, bool have_cache,
-          bool run_sync, optional_yield y, const DoutPrefixProvider *dpp) {
-    return do_init(cct, store, have_cache, false, run_sync, y, dpp);
+          bool run_sync, optional_yield y, const DoutPrefixProvider *dpp,
+          const rgw::SiteConfig& site) {
+    return do_init(cct, store, have_cache, false, run_sync, y, dpp, site);
   }
 
   int init_raw(CephContext *cct, rgw::sal::RadosStore* store,
               bool have_cache, optional_yield y,
-              const DoutPrefixProvider *dpp) {
-    return do_init(cct, store, have_cache, true, false, y, dpp);
+              const DoutPrefixProvider *dpp,
+              const rgw::SiteConfig& site) {
+    return do_init(cct, store, have_cache, true, false, y, dpp, site);
   }
   void shutdown() {
     _svc.shutdown();
index 5e4603b811625cd8dc4d4a7bc1d070a2fc2a4b27..d9dd1bde60339c921c7365dbd5c2dd37dfba9b17 100644 (file)
@@ -46,8 +46,7 @@
 #define dout_subsys ceph_subsys_rgw
 
 extern "C" {
-extern rgw::sal::Driver* newRadosStore(boost::asio::io_context* io_context,
-                                      const rgw::SiteConfig* site_config);
+extern rgw::sal::Driver* newRadosStore(boost::asio::io_context* io_context);
 #ifdef WITH_RADOSGW_DBSTORE
 extern rgw::sal::Driver* newDBStore(CephContext *cct);
 #endif
@@ -118,7 +117,7 @@ rgw::sal::Driver* DriverManager::init_storage_provider(const DoutPrefixProvider*
   rgw::sal::Driver* driver{nullptr};
 
   if (cfg.store_name.compare("rados") == 0) {
-    driver = newRadosStore(&io_context, &site_config);
+    driver = newRadosStore(&io_context);
     RGWRados* rados = static_cast<rgw::sal::RadosStore* >(driver)->getRados();
 
     if ((*rados).set_use_cache(use_cache)
@@ -130,7 +129,7 @@ rgw::sal::Driver* DriverManager::init_storage_provider(const DoutPrefixProvider*
                 .set_run_sync_thread(run_sync_thread)
                 .set_run_reshard_thread(run_reshard_thread)
                 .set_run_notification_thread(run_notification_thread)
-                .init_begin(cct, dpp) < 0) {
+                .init_begin(cct, dpp, site_config) < 0) {
       delete driver;
       return nullptr;
     }
@@ -144,7 +143,7 @@ rgw::sal::Driver* DriverManager::init_storage_provider(const DoutPrefixProvider*
     }
   }
   else if (cfg.store_name.compare("d3n") == 0) {
-    driver = new rgw::sal::RadosStore(io_context, site_config);
+    driver = new rgw::sal::RadosStore(io_context);
     RGWRados* rados = new D3nRGWDataCache<RGWRados>;
     dynamic_cast<rgw::sal::RadosStore*>(driver)->setRados(rados);
     rados->set_store(static_cast<rgw::sal::RadosStore* >(driver));
@@ -157,7 +156,7 @@ rgw::sal::Driver* DriverManager::init_storage_provider(const DoutPrefixProvider*
                 .set_run_sync_thread(run_sync_thread)
                 .set_run_reshard_thread(run_reshard_thread)
                 .set_run_notification_thread(run_notification_thread)
-                .init_begin(cct, dpp) < 0) {
+                .init_begin(cct, dpp, site_config) < 0) {
       delete driver;
       return nullptr;
     }
@@ -270,7 +269,7 @@ rgw::sal::Driver* DriverManager::init_raw_storage_provider(const DoutPrefixProvi
 {
   rgw::sal::Driver* driver = nullptr;
   if (cfg.store_name.compare("rados") == 0) {
-    driver = newRadosStore(&io_context, &site_config);
+    driver = newRadosStore(&io_context);
     RGWRados* rados = static_cast<rgw::sal::RadosStore* >(driver)->getRados();
 
     rados->set_context(cct);
@@ -280,7 +279,7 @@ rgw::sal::Driver* DriverManager::init_raw_storage_provider(const DoutPrefixProvi
       return nullptr;
     }
 
-    int ret = rados->init_svc(true, dpp);
+    int ret = rados->init_svc(true, dpp, site_config);
     if (ret < 0) {
       ldout(cct, 0) << "ERROR: failed to init services (ret=" << cpp_strerror(-ret) << ")" << dendl;
       delete driver;
index e69910395a8ff848ce18791b14ba5813ba9dc564..f36dfe5ab4407b2142998cb9c7b0ab7993b33e31 100644 (file)
@@ -913,8 +913,7 @@ TEST_F(IPPolicyTest, IPEnvironment) {
   // Unfortunately RGWCivetWeb is too tightly tied to civetweb to test RGWCivetWeb::init_env.
   RGWEnv rgw_env;
   ceph::async::io_context_pool context_pool(cct->_conf->rgw_thread_pool_size); \
-  auto site = rgw::SiteConfig::make_fake();
-  rgw::sal::RadosStore store(context_pool, *site);
+  rgw::sal::RadosStore store(context_pool);
   std::unique_ptr<rgw::sal::User> user = store.get_user(rgw_user());
   rgw_env.set("REMOTE_ADDR", "192.168.1.1");
   rgw_env.set("HTTP_HOST", "1.2.3.4");
index 8aed91bb6f5ac8c3f5a6a7955361ec0624d04049..e6014513ba3a7cebda01a530f2560ca2a9b8e807 100644 (file)
@@ -8,7 +8,6 @@
 #include "rgw_lua_request.h"
 #include "rgw_lua_background.h"
 #include "rgw_lua_data_filter.h"
-#include "driver/rados/rgw_zone.h"
 #include "rgw_sal_config.h"
 
 using namespace std;
@@ -165,23 +164,17 @@ tracing::Tracer tracer;
 inline std::unique_ptr<sal::RadosStore> make_store() {
   auto context_pool = std::make_unique<ceph::async::io_context_pool>(
     g_cct->_conf->rgw_thread_pool_size);
-  std::unique_ptr<rgw::SiteConfig> site = rgw::SiteConfig::make_fake();
-
 
   struct StoreBundle : public sal::RadosStore {
     std::unique_ptr<ceph::async::io_context_pool> context_pool;
-    std::unique_ptr<rgw::SiteConfig> site;
-    StoreBundle(std::unique_ptr<ceph::async::io_context_pool> context_pool_,
-                std::unique_ptr<rgw::SiteConfig> site_)
-      : sal::RadosStore(*context_pool_.get(), *site_),
-        context_pool(std::move(context_pool_)),
-        site(std::move(site_)) {
+    StoreBundle(std::unique_ptr<ceph::async::io_context_pool> context_pool_)
+      : sal::RadosStore(*context_pool_.get()),
+        context_pool(std::move(context_pool_)) {
       setRados(new RGWRados);
     }
     virtual ~StoreBundle() = default;
   };
-  return std::make_unique<StoreBundle>(std::move(context_pool),
-                                       std::move(site));
+  return std::make_unique<StoreBundle>(std::move(context_pool));
 };
 
 #define DEFINE_REQ_STATE RGWProcessEnv pe; \