From: Casey Bodley Date: Sun, 4 Feb 2024 18:43:10 +0000 (-0500) Subject: rgw/rados: store SiteConfig with RGWServices X-Git-Tag: testing/wip-root-testing-20240411.174241^2~31 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=3288d05142d71226506ec2c8836ee21b65477540;p=ceph-ci.git rgw/rados: store SiteConfig with RGWServices make the SiteConfig available to all of RGWRados via svc.site instead of storing it in sal::RadosStore Signed-off-by: Casey Bodley (cherry picked from commit 0057bb7d0f02974f3a8cb1d34e73ead8d92c3062) --- diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index 480600d91fe..03e7874eb72 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -1367,29 +1367,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; @@ -1400,13 +1396,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; diff --git a/src/rgw/driver/rados/rgw_rados.h b/src/rgw/driver/rados/rgw_rados.h index 7e7a58480a6..f43b1b4e531 100644 --- a/src/rgw/driver/rados/rgw_rados.h +++ b/src/rgw/driver/rados/rgw_rados.h @@ -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(); diff --git a/src/rgw/driver/rados/rgw_sal_rados.cc b/src/rgw/driver/rados/rgw_sal_rados.cc index 2bde7d192e5..6e4d346120e 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.cc +++ b/src/rgw/driver/rados/rgw_sal_rados.cc @@ -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(io_context), - *static_cast(site_config)); + *static_cast(io_context)); if (store) { RGWRados* rados = new RGWRados(); diff --git a/src/rgw/driver/rados/rgw_sal_rados.h b/src/rgw/driver/rados/rgw_sal_rados.h index 85612eec1a9..e85b3fde1d4 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.h +++ b/src/rgw/driver/rados/rgw_sal_rados.h @@ -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 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; } diff --git a/src/rgw/driver/rados/rgw_service.cc b/src/rgw/driver/rados/rgw_service.cc index 1f05495fb3d..0c0e2bbea65 100644 --- a/src/rgw/driver/rados/rgw_service.cc +++ b/src/rgw/driver/rados/rgw_service.cc @@ -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) { diff --git a/src/rgw/driver/rados/rgw_service.h b/src/rgw/driver/rados/rgw_service.h index 08873e6058e..03b37f1ad5a 100644 --- a/src/rgw/driver/rados/rgw_service.h +++ b/src/rgw/driver/rados/rgw_service.h @@ -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(); diff --git a/src/rgw/rgw_sal.cc b/src/rgw/rgw_sal.cc index 5e4603b8116..d9dd1bde603 100644 --- a/src/rgw/rgw_sal.cc +++ b/src/rgw/rgw_sal.cc @@ -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(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; dynamic_cast(driver)->setRados(rados); rados->set_store(static_cast(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(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; diff --git a/src/test/rgw/test_rgw_iam_policy.cc b/src/test/rgw/test_rgw_iam_policy.cc index e69910395a8..f36dfe5ab44 100644 --- a/src/test/rgw/test_rgw_iam_policy.cc +++ b/src/test/rgw/test_rgw_iam_policy.cc @@ -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 user = store.get_user(rgw_user()); rgw_env.set("REMOTE_ADDR", "192.168.1.1"); rgw_env.set("HTTP_HOST", "1.2.3.4"); diff --git a/src/test/rgw/test_rgw_lua.cc b/src/test/rgw/test_rgw_lua.cc index 8aed91bb6f5..e6014513ba3 100644 --- a/src/test/rgw/test_rgw_lua.cc +++ b/src/test/rgw/test_rgw_lua.cc @@ -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 make_store() { auto context_pool = std::make_unique( g_cct->_conf->rgw_thread_pool_size); - std::unique_ptr site = rgw::SiteConfig::make_fake(); - struct StoreBundle : public sal::RadosStore { std::unique_ptr context_pool; - std::unique_ptr site; - StoreBundle(std::unique_ptr context_pool_, - std::unique_ptr site_) - : sal::RadosStore(*context_pool_.get(), *site_), - context_pool(std::move(context_pool_)), - site(std::move(site_)) { + StoreBundle(std::unique_ptr context_pool_) + : sal::RadosStore(*context_pool_.get()), + context_pool(std::move(context_pool_)) { setRados(new RGWRados); } virtual ~StoreBundle() = default; }; - return std::make_unique(std::move(context_pool), - std::move(site)); + return std::make_unique(std::move(context_pool)); }; #define DEFINE_REQ_STATE RGWProcessEnv pe; \