]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
radosgw-admin: skip GC init on read-only admin ops 42655/head
authorMark Kogan <mkogan@redhat.com>
Mon, 26 Apr 2021 09:15:11 +0000 (12:15 +0300)
committerCory Snyder <csnyder@iland.com>
Wed, 4 Aug 2021 16:26:52 +0000 (12:26 -0400)
Fixes: https://tracker.ceph.com/issues/50520
Signed-off-by: Mark Kogan <mkogan@redhat.com>
(cherry picked from commit 9ac1991fc798af7e0ba0fac18209b71b5ae3f02b)

Conflicts:
src/rgw/rgw_admin.cc
src/rgw/rgw_rados.h
src/rgw/rgw_sal.cc
src/rgw/rgw_sal.h

Cherry-pick notes:
- Conflicts due to move from of RGWStoreManager in rgw_sal_rados.h to StoreManager in rgw_sal.h

src/rgw/rgw_admin.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_sal_rados.cc
src/rgw/rgw_sal_rados.h

index a57e2cacd7bed8ea932f2bf70413e3e89c5d7a6c..780843cd91d1512694211b6c60a919749bfab346 100644 (file)
@@ -3896,23 +3896,34 @@ int main(int argc, const char **argv)
                         OPT::ROLE_POLICY_GET,
                         OPT::RESHARD_LIST,
                         OPT::RESHARD_STATUS,
-       OPT::PUBSUB_TOPICS_LIST,
-       OPT::PUBSUB_TOPIC_GET,
-       OPT::PUBSUB_SUB_GET,
-       OPT::PUBSUB_SUB_PULL,
-       OPT::SCRIPT_GET,
-  };
-
+                        OPT::PUBSUB_TOPICS_LIST,
+                        OPT::PUBSUB_TOPIC_GET,
+                        OPT::PUBSUB_SUB_GET,
+                        OPT::PUBSUB_SUB_PULL,
+                        OPT::SCRIPT_GET,
+    };
+
+    std::set<OPT> gc_ops_list = {
+                        OPT::GC_LIST,
+                        OPT::GC_PROCESS,
+                        OPT::OBJECT_RM,
+                        OPT::BUCKET_RM,  // --purge-objects
+                        OPT::USER_RM,    // --purge-data
+                        OPT::OBJECTS_EXPIRE,
+                        OPT::OBJECTS_EXPIRE_STALE_RM,
+                        OPT::LC_PROCESS
+    };
 
   bool raw_storage_op = (raw_storage_ops_list.find(opt_cmd) != raw_storage_ops_list.end() ||
                          raw_period_update || raw_period_pull);
   bool need_cache = readonly_ops_list.find(opt_cmd) == readonly_ops_list.end();
+  bool need_gc = (gc_ops_list.find(opt_cmd) != gc_ops_list.end()) && !bypass_gc;
 
-  if (raw_storage_op) {
+    if (raw_storage_op) {
     store = RGWStoreManager::get_raw_storage(dpp(), g_ceph_context);
   } else {
     store = RGWStoreManager::get_storage(dpp(), g_ceph_context, false, false, false, false, false,
-      need_cache && g_conf()->rgw_cache_enabled);
+      need_cache && g_conf()->rgw_cache_enabled, need_gc);
   }
   if (!store) {
     cerr << "couldn't init storage provider" << std::endl;
index 5c32b797f0f4d5cc982683f5a184f41f5a994e9e..22cd5568282e44786e7e5ea37cdf3529171fd76d 100644 (file)
@@ -1201,12 +1201,16 @@ int RGWRados::init_complete(const DoutPrefixProvider *dpp)
 
   pools_initialized = true;
 
-  gc = new RGWGC();
-  gc->initialize(cct, this);
+  if (use_gc) {
+    gc = new RGWGC();
+    gc->initialize(cct, this);
+  } else {
+    ldpp_dout(dpp, 5) << "note: GC not initialized" << dendl;
+  }
 
   obj_expirer = new RGWObjectExpirer(this->store);
 
-  if (use_gc_thread) {
+  if (use_gc_thread && use_gc) {
     gc->start_processor();
     obj_expirer->start_processor();
   }
index b971edb0386b6de0f4dcfae67c046aa8d447ff58..4542c4a1f9172746b641e698d78fa7f79f49a7ef 100644 (file)
@@ -427,7 +427,7 @@ class RGWRados
   SafeTimer *timer;
 
   rgw::sal::RGWRadosStore *store;
-  RGWGC *gc;
+  RGWGC *gc = nullptr;
   RGWLC *lc;
   RGWObjectExpirer *obj_expirer;
   bool use_gc_thread;
@@ -506,6 +506,7 @@ protected:
   RGWIndexCompletionManager *index_completion_manager{nullptr};
 
   bool use_cache{false};
+  bool use_gc{true};
 
   int get_obj_head_ioctx(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, const rgw_obj& obj, librados::IoCtx *ioctx);
 public:
@@ -527,6 +528,11 @@ public:
     return *this;
   }
 
+  RGWRados& set_use_gc(bool status) {
+    use_gc = status;
+    return *this;
+  }
+
   RGWLC *get_lc() {
     return lc;
   }
index 778bc9ba04917e27bb8de7922c8ae85fefdbaaaa..b00d8dce441bbc163aadd0d7e24d88d2537d966d 100644 (file)
@@ -1292,7 +1292,7 @@ LCSerializer* RadosLifecycle::get_serializer(const std::string& lock_name, const
 
 } // namespace rgw::sal
 
-rgw::sal::RGWRadosStore *RGWStoreManager::init_storage_provider(const DoutPrefixProvider *dpp, CephContext *cct, bool use_gc_thread, bool use_lc_thread, bool quota_threads, bool run_sync_thread, bool run_reshard_thread, bool use_cache)
+rgw::sal::RGWRadosStore *RGWStoreManager::init_storage_provider(const DoutPrefixProvider *dpp, CephContext *cct, 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)
 {
   RGWRados *rados = new RGWRados;
   rgw::sal::RGWRadosStore *store = new rgw::sal::RGWRadosStore();
@@ -1301,6 +1301,7 @@ rgw::sal::RGWRadosStore *RGWStoreManager::init_storage_provider(const DoutPrefix
   rados->set_store(store);
 
   if ((*rados).set_use_cache(use_cache)
+              .set_use_gc(use_gc)
               .set_run_gc_thread(use_gc_thread)
               .set_run_lc_thread(use_lc_thread)
               .set_run_quota_threads(quota_threads)
index 7ea8fb443da1f1333d7f7ead67a10392b448be1b..79596c6f868dcbfe9496140548a8fd14c01a119d 100644 (file)
@@ -391,16 +391,16 @@ class RGWStoreManager {
 public:
   RGWStoreManager() {}
   static rgw::sal::RGWRadosStore *get_storage(const DoutPrefixProvider *dpp, CephContext *cct, bool use_gc_thread, bool use_lc_thread, bool quota_threads,
-                              bool run_sync_thread, bool run_reshard_thread, bool use_cache = true) {
+                              bool run_sync_thread, bool run_reshard_thread, bool use_cache = true, bool use_gc = true) {
     rgw::sal::RGWRadosStore *store = init_storage_provider(dpp, cct, use_gc_thread, use_lc_thread,
-       quota_threads, run_sync_thread, run_reshard_thread, use_cache);
+       quota_threads, run_sync_thread, run_reshard_thread, use_cache, use_gc);
     return store;
   }
   static rgw::sal::RGWRadosStore *get_raw_storage(const DoutPrefixProvider *dpp, CephContext *cct) {
     rgw::sal::RGWRadosStore *rados = init_raw_storage_provider(dpp, cct);
     return rados;
   }
-  static rgw::sal::RGWRadosStore *init_storage_provider(const DoutPrefixProvider *dpp, CephContext *cct, bool use_gc_thread, bool use_lc_thread, bool quota_threads, bool run_sync_thread, bool run_reshard_thread, bool use_metadata_cache);
+  static rgw::sal::RGWRadosStore *init_storage_provider(const DoutPrefixProvider *dpp, CephContext *cct, 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::RGWRadosStore *init_raw_storage_provider(const DoutPrefixProvider *dpp, CephContext *cct);
   static void close_storage(rgw::sal::RGWRadosStore *store);