]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
RGW - Zipper - Add temporary Filter testing 47190/head
authorDaniel Gryniewicz <dang@redhat.com>
Tue, 19 Jul 2022 17:06:29 +0000 (13:06 -0400)
committerDaniel Gryniewicz <dang@redhat.com>
Wed, 27 Jul 2022 17:32:53 +0000 (13:32 -0400)
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 <dang@redhat.com>
src/common/options/rgw.yaml.in
src/rgw/librgw.cc
src/rgw/rgw_admin.cc
src/rgw/rgw_main.cc
src/rgw/rgw_object_expirer.cc
src/rgw/rgw_realm_reloader.cc
src/rgw/rgw_sal.cc
src/rgw/rgw_sal.h
src/rgw/rgw_sal_filter.cc

index 798e390f2df7eccd7a5bac12268febad69018717..74d149911034c0654d07f5d30139c9ffd7f412ef 100644 (file)
@@ -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
index 87fbb97ad6dd1f81a2928b39762619e6c38c668b..48d5b3047881319fa1a89b64fe7d0a86791e0568 100644 (file)
@@ -573,8 +573,16 @@ namespace rgw {
     }
 #endif
 
+    // Get the filter
+    std::string rgw_filter = "none";
+    const auto& config_filter = g_conf().get_val<std::string>("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,
index c726fa1b41e94b7463399e308149d0c279598305..ee7c926ed7aab297e2d45df949b54d9ba1a96d0c 100644 (file)
@@ -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<std::string>("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,
index 0d7bb3ed1803c6da3e339aa9599ff839d670f9a2..6e7509a29df21dea5c844c5d0ad15509005fe5e6 100644 (file)
@@ -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<std::string>("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,
index 1fd940533c510062d89e4144517f500f828012fc..79ecf7452764ea48d6dd16de8fb9a468bef7a410 100644 (file)
@@ -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;
index f3b0d306ef6ddab41ec118b9e98684de9a68c251..d27567cf9328b6605689a601f09cde16310d3f6c 100644 (file)
@@ -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,
index f42254e67d13ed7241a003e885954c6fc3ac4b20..1c55c2dbe0adc6418aa3550c45597eb6c751023c 100644 (file)
@@ -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<rgw::sal::RadosStore* >(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<RGWRados>;
-    store->setRados(rados);
+    dynamic_cast<rgw::sal::RadosStore*>(store)->setRados(rados);
     rados->set_store(static_cast<rgw::sal::RadosStore* >(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;
 }
 
index 1b9869e2966130a5917259cd1a0d06cc2244c641..6b234aa168480fbc8e14c4e9071f92f0e7323728 100644 (file)
@@ -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);
 
index 711a0f6544d782ad6cace9c6120b7701046fdc22..64cadd9b68dc96f5d197106e9f8d073a45e72d17 100644 (file)
@@ -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;
+}
+
+}