From 3b8fb3d498d39ddb375ea406858ddd6997b8c118 Mon Sep 17 00:00:00 2001 From: Daniel Gryniewicz Date: Tue, 19 Jul 2022 13:06:29 -0400 Subject: [PATCH] RGW - Zipper - Add temporary Filter testing In order to test filters, we need to be able to instantiate one and stack it over a store. Add a temporary config option to specify a filter that can be used for testing. This will be replaced with a better system once the loadable module work is done. Signed-off-by: Daniel Gryniewicz --- src/common/options/rgw.yaml.in | 12 +++++++ src/rgw/librgw.cc | 8 +++++ src/rgw/rgw_admin.cc | 11 +++++- src/rgw/rgw_main.cc | 8 +++++ src/rgw/rgw_object_expirer.cc | 2 +- src/rgw/rgw_realm_reloader.cc | 1 + src/rgw/rgw_sal.cc | 62 +++++++++++++++++++++------------- src/rgw/rgw_sal.h | 12 +++---- src/rgw/rgw_sal_filter.cc | 11 ++++++ 9 files changed, 95 insertions(+), 32 deletions(-) diff --git a/src/common/options/rgw.yaml.in b/src/common/options/rgw.yaml.in index 798e390f2df7e..74d149911034c 100644 --- a/src/common/options/rgw.yaml.in +++ b/src/common/options/rgw.yaml.in @@ -3456,6 +3456,18 @@ options: - rados - dbstore - motr +- name: rgw_filter + type: str + level: advanced + desc: experimental Option to set a filter + long_desc: defaults to none. Other valid values are base and trace (both experimental). + default: none + services: + - rgw + enum_values: + - none + - base + - trace - name: dbstore_db_dir type: str level: advanced diff --git a/src/rgw/librgw.cc b/src/rgw/librgw.cc index 87fbb97ad6dd1..48d5b30478813 100644 --- a/src/rgw/librgw.cc +++ b/src/rgw/librgw.cc @@ -573,8 +573,16 @@ namespace rgw { } #endif + // Get the filter + std::string rgw_filter = "none"; + const auto& config_filter = g_conf().get_val("rgw_filter"); + if (config_filter == "base") { + rgw_filter = "base"; + } + store = StoreManager::get_storage(this, g_ceph_context, rgw_store, + rgw_filter, run_gc, run_lc, run_quota, diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index c726fa1b41e94..ee7c926ed7aab 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -4367,14 +4367,23 @@ int main(int argc, const char **argv) } #endif + // Get the filter + std::string rgw_filter = "none"; + const auto& config_filter = g_conf().get_val("rgw_filter"); + if (config_filter == "base") { + rgw_filter = "base"; + } + if (raw_storage_op) { store = StoreManager::get_raw_storage(dpp(), g_ceph_context, - rgw_store); + rgw_store, + rgw_filter); } else { store = StoreManager::get_storage(dpp(), g_ceph_context, rgw_store, + rgw_filter, false, false, false, diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc index 0d7bb3ed1803c..6e7509a29df21 100644 --- a/src/rgw/rgw_main.cc +++ b/src/rgw/rgw_main.cc @@ -395,9 +395,17 @@ int radosgw_Main(int argc, const char **argv) } #endif + // Get the filter + std::string rgw_filter = "none"; + const auto& config_filter = g_conf().get_val("rgw_filter"); + if (config_filter == "base") { + rgw_filter = "base"; + } + rgw::sal::Store* store = StoreManager::get_storage(&dp, g_ceph_context, rgw_store, + rgw_filter, g_conf()->rgw_enable_gc_threads, g_conf()->rgw_enable_lc_threads, g_conf()->rgw_enable_quota_threads, diff --git a/src/rgw/rgw_object_expirer.cc b/src/rgw/rgw_object_expirer.cc index 1fd940533c510..79ecf7452764e 100644 --- a/src/rgw/rgw_object_expirer.cc +++ b/src/rgw/rgw_object_expirer.cc @@ -80,7 +80,7 @@ int main(const int argc, const char **argv) common_init_finish(g_ceph_context); const DoutPrefix dp(cct.get(), dout_subsys, "rgw object expirer: "); - store = StoreManager::get_storage(&dp, g_ceph_context, "rados", false, false, false, false, false); + store = StoreManager::get_storage(&dp, g_ceph_context, "rados", "none", false, false, false, false, false); if (!store) { std::cerr << "couldn't init storage provider" << std::endl; return EIO; diff --git a/src/rgw/rgw_realm_reloader.cc b/src/rgw/rgw_realm_reloader.cc index f3b0d306ef6dd..d27567cf9328b 100644 --- a/src/rgw/rgw_realm_reloader.cc +++ b/src/rgw/rgw_realm_reloader.cc @@ -108,6 +108,7 @@ void RGWRealmReloader::reload() store = StoreManager::get_storage(&dp, cct, "rados", + "none", cct->_conf->rgw_enable_gc_threads, cct->_conf->rgw_enable_lc_threads, cct->_conf->rgw_enable_quota_threads, diff --git a/src/rgw/rgw_sal.cc b/src/rgw/rgw_sal.cc index f42254e67d13e..1c55c2dbe0adc 100644 --- a/src/rgw/rgw_sal.cc +++ b/src/rgw/rgw_sal.cc @@ -44,6 +44,7 @@ extern rgw::sal::Store* newDBStore(CephContext *cct); #ifdef WITH_RADOSGW_MOTR extern rgw::sal::Store* newMotrStore(CephContext *cct); #endif +extern rgw::sal::Store* newBaseFilter(rgw::sal::Store* next); } RGWObjState::RGWObjState() { @@ -81,10 +82,12 @@ RGWObjState::RGWObjState(const RGWObjState& rhs) : obj (rhs.obj) { compressed = rhs.compressed; } -rgw::sal::Store* StoreManager::init_storage_provider(const DoutPrefixProvider* dpp, CephContext* cct, const std::string svc, bool use_gc_thread, bool use_lc_thread, bool quota_threads, bool run_sync_thread, bool run_reshard_thread, bool use_cache, bool use_gc) +rgw::sal::Store* StoreManager::init_storage_provider(const DoutPrefixProvider* dpp, CephContext* cct, const std::string svc, const std::string filter, bool use_gc_thread, bool use_lc_thread, bool quota_threads, bool run_sync_thread, bool run_reshard_thread, bool use_cache, bool use_gc) { + rgw::sal::Store* store{nullptr}; + if (svc.compare("rados") == 0) { - rgw::sal::Store* store = newStore(); + store = newStore(); RGWRados* rados = static_cast(store)->getRados(); if ((*rados).set_use_cache(use_cache) @@ -107,12 +110,11 @@ rgw::sal::Store* StoreManager::init_storage_provider(const DoutPrefixProvider* d delete store; return nullptr; } - return store; } else if (svc.compare("d3n") == 0) { - rgw::sal::RadosStore *store = new rgw::sal::RadosStore(); + store = new rgw::sal::RadosStore(); RGWRados* rados = new D3nRGWDataCache; - store->setRados(rados); + dynamic_cast(store)->setRados(rados); rados->set_store(static_cast(store)); if ((*rados).set_use_cache(use_cache) @@ -134,26 +136,22 @@ rgw::sal::Store* StoreManager::init_storage_provider(const DoutPrefixProvider* d delete store; return nullptr; } - return store; } - #ifdef WITH_RADOSGW_DBSTORE - if (svc.compare("dbstore") == 0) { - rgw::sal::Store* store = newDBStore(cct); + else if (svc.compare("dbstore") == 0) { + store = newDBStore(cct); if ((*(rgw::sal::DBStore*)store).set_run_lc_thread(use_lc_thread) .initialize(cct, dpp) < 0) { delete store; return nullptr; } - - return store; } #endif #ifdef WITH_RADOSGW_MOTR - if (svc.compare("motr") == 0) { - rgw::sal::Store* store = newMotrStore(cct); + else if (svc.compare("motr") == 0) { + store = newMotrStore(cct); if (store == nullptr) { ldpp_dout(dpp, 0) << "newMotrStore() failed!" << dendl; return store; @@ -188,15 +186,24 @@ rgw::sal::Store* StoreManager::init_storage_provider(const DoutPrefixProvider* d ldpp_dout(dpp, 20) << "User display name = " << suser->get_info().display_name << dendl; ldpp_dout(dpp, 20) << "User email = " << suser->get_info().user_email << dendl; } - - return store; } #endif - return nullptr; + if (filter.compare("base") == 0) { + rgw::sal::Store* next = store; + store = newBaseFilter(next); + + if (store->initialize(cct, dpp) < 0) { + delete store; + delete next; + return nullptr; + } + } + + return store; } -rgw::sal::Store* StoreManager::init_raw_storage_provider(const DoutPrefixProvider* dpp, CephContext* cct, const std::string svc) +rgw::sal::Store* StoreManager::init_raw_storage_provider(const DoutPrefixProvider* dpp, CephContext* cct, const std::string svc, const std::string filter) { rgw::sal::Store* store = nullptr; if (svc.compare("rados") == 0) { @@ -220,9 +227,7 @@ rgw::sal::Store* StoreManager::init_raw_storage_provider(const DoutPrefixProvide delete store; return nullptr; } - } - - if (svc.compare("dbstore") == 0) { + } else if (svc.compare("dbstore") == 0) { #ifdef WITH_RADOSGW_DBSTORE store = newDBStore(cct); @@ -230,19 +235,28 @@ rgw::sal::Store* StoreManager::init_raw_storage_provider(const DoutPrefixProvide delete store; return nullptr; } - #else store = nullptr; #endif - } - - if (svc.compare("motr") == 0) { + } else if (svc.compare("motr") == 0) { #ifdef WITH_RADOSGW_MOTR store = newMotrStore(cct); #else store = nullptr; #endif } + + if (filter.compare("base") == 0) { + rgw::sal::Store* next = store; + store = newBaseFilter(next); + + if (store->initialize(cct, dpp) < 0) { + delete store; + delete next; + return nullptr; + } + } + return store; } diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index 1b9869e296613..6b234aa168480 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -1538,21 +1538,21 @@ class StoreManager { public: StoreManager() {} /** Get a full store by service name */ - static rgw::sal::Store* get_storage(const DoutPrefixProvider* dpp, CephContext* cct, const std::string svc, bool use_gc_thread, bool use_lc_thread, bool quota_threads, + static rgw::sal::Store* get_storage(const DoutPrefixProvider* dpp, CephContext* cct, const std::string svc, const std::string filter, bool use_gc_thread, bool use_lc_thread, bool quota_threads, bool run_sync_thread, bool run_reshard_thread, bool use_cache = true, bool use_gc = true) { - rgw::sal::Store* store = init_storage_provider(dpp, cct, svc, use_gc_thread, use_lc_thread, + rgw::sal::Store* store = init_storage_provider(dpp, cct, svc, filter, use_gc_thread, use_lc_thread, quota_threads, run_sync_thread, run_reshard_thread, use_cache, use_gc); return store; } /** Get a stripped down store by service name */ - static rgw::sal::Store* get_raw_storage(const DoutPrefixProvider* dpp, CephContext* cct, const std::string svc) { - rgw::sal::Store* store = init_raw_storage_provider(dpp, cct, svc); + static rgw::sal::Store* get_raw_storage(const DoutPrefixProvider* dpp, CephContext* cct, const std::string svc, const std::string filter) { + rgw::sal::Store* store = init_raw_storage_provider(dpp, cct, svc, filter); return store; } /** Initialize a new full Store */ - static rgw::sal::Store* init_storage_provider(const DoutPrefixProvider* dpp, CephContext* cct, const std::string svc, bool use_gc_thread, bool use_lc_thread, bool quota_threads, bool run_sync_thread, bool run_reshard_thread, bool use_metadata_cache, bool use_gc); + static rgw::sal::Store* init_storage_provider(const DoutPrefixProvider* dpp, CephContext* cct, const std::string svc, const std::string filter, bool use_gc_thread, bool use_lc_thread, bool quota_threads, bool run_sync_thread, bool run_reshard_thread, bool use_metadata_cache, bool use_gc); /** Initialize a new raw Store */ - static rgw::sal::Store* init_raw_storage_provider(const DoutPrefixProvider* dpp, CephContext* cct, const std::string svc); + static rgw::sal::Store* init_raw_storage_provider(const DoutPrefixProvider* dpp, CephContext* cct, const std::string svc, const std::string filter); /** Close a Store when it's no longer needed */ static void close_storage(rgw::sal::Store* store); diff --git a/src/rgw/rgw_sal_filter.cc b/src/rgw/rgw_sal_filter.cc index 711a0f6544d78..64cadd9b68dc9 100644 --- a/src/rgw/rgw_sal_filter.cc +++ b/src/rgw/rgw_sal_filter.cc @@ -1322,3 +1322,14 @@ int FilterLuaScriptManager::del(const DoutPrefixProvider* dpp, optional_yield y, } } } // namespace rgw::sal + +extern "C" { + +rgw::sal::Store* newBaseFilter(rgw::sal::Store* next) +{ + rgw::sal::FilterStore* store = new rgw::sal::FilterStore(next); + + return store; +} + +} -- 2.39.5