]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
radosgw-admin: skip GC init on read-only admin ops 45423/head
authorMark Kogan <mkogan@redhat.com>
Mon, 26 Apr 2021 09:15:11 +0000 (12:15 +0300)
committerCory Snyder <csnyder@iland.com>
Mon, 16 May 2022 08:39:29 +0000 (04:39 -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:
- src/rgw/rgw_admin.cc: conflicts due to differences in op lists
- src/rgw/rgw_rados.h: conflicts due to changes to unrelated  method signatures
- src/rgw/rgw_sal.cc: conflicts due to octopus missing a couple of methods from later releases
- src/rgw/rgw_sal.h: conflicts due to changes to unrelated method seignatures
- src/rgw/rgw_rados.cc: use of ldpp_dout vs. ldout

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

index 9d3d8351e68d750a40e8d538afdd49a9563b2e16..f6bda422ff292bc44f459b791028876e64c6a027 100644 (file)
@@ -3887,16 +3887,27 @@ int main(int argc, const char **argv)
                         OPT::RESHARD_STATUS,
   };
 
+    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) {
     store = RGWStoreManager::get_raw_storage(g_ceph_context);
   } else {
     store = RGWStoreManager::get_storage(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 a677613793fb4ea3484c6743367605e9dfe3d065..7b16372ce4489e28d4057f01b5f1b37c652eadd6 100644 (file)
@@ -1184,12 +1184,16 @@ int RGWRados::init_complete()
 
   pools_initialized = true;
 
-  gc = new RGWGC();
-  gc->initialize(cct, this);
+  if (use_gc) {
+    gc = new RGWGC();
+    gc->initialize(cct, this);
+  } else {
+    ldout(cct, 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 8a5ee7cfeefe5c1f0c664cfcec73b9ab4022df98..0ffe12785cc0bc76d44addd03af35ba2872a5775 100644 (file)
@@ -428,7 +428,7 @@ class RGWRados
   SafeTimer *timer;
 
   rgw::sal::RGWRadosStore *store;
-  RGWGC *gc;
+  RGWGC *gc = nullptr;
   RGWLC *lc;
   RGWObjectExpirer *obj_expirer;
   bool use_gc_thread;
@@ -507,6 +507,7 @@ protected:
   RGWIndexCompletionManager *index_completion_manager{nullptr};
 
   bool use_cache{false};
+  bool use_gc{true};
 public:
   RGWRados(): timer(NULL),
                gc(NULL), lc(NULL), obj_expirer(NULL), use_gc_thread(false), use_lc_thread(false), quota_threads(false),
@@ -526,6 +527,11 @@ public:
     return *this;
   }
 
+  RGWRados& set_use_gc(bool status) {
+    use_gc = status;
+    return *this;
+  }
+
   RGWLC *get_lc() {
     return lc;
   }
index 53079f66a783590795f7aaa6fd38ca30a813564a..12df94fe2b72bfbde80009b0a7d370046b04a103 100644 (file)
@@ -301,7 +301,7 @@ int RGWRadosStore::get_bucket(RGWUser& u, const rgw_bucket& b, RGWBucket** bucke
 
 } // namespace rgw::sal
 
-rgw::sal::RGWRadosStore *RGWStoreManager::init_storage_provider(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(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();
@@ -310,6 +310,7 @@ rgw::sal::RGWRadosStore *RGWStoreManager::init_storage_provider(CephContext *cct
   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 542844d03924868770b2629e11559fafe7c25378..a46739b3b7ea09c92e5728bc9e968b2186c4d963 100644 (file)
@@ -319,16 +319,16 @@ class RGWStoreManager {
 public:
   RGWStoreManager() {}
   static rgw::sal::RGWRadosStore *get_storage(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(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(CephContext *cct) {
     rgw::sal::RGWRadosStore *rados = init_raw_storage_provider(cct);
     return rados;
   }
-  static rgw::sal::RGWRadosStore *init_storage_provider(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(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(CephContext *cct);
   static void close_storage(rgw::sal::RGWRadosStore *store);