]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
radosgw-admin: skip GC init on read-only admin ops
authorMark Kogan <mkogan@redhat.com>
Mon, 26 Apr 2021 09:15:11 +0000 (12:15 +0300)
committerMark Kogan <mkogan@redhat.com>
Wed, 28 Apr 2021 12:16:24 +0000 (15:16 +0300)
Fixes: https://tracker.ceph.com/issues/50520
Signed-off-by: Mark Kogan <mkogan@redhat.com>
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 cafe1ea7ebaaac758391487019fb68a3265dec4a..aac30711273f030971dfab3198f51b178bbecfcb 100644 (file)
@@ -3814,17 +3814,28 @@ int main(int argc, const char **argv)
                         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
+    };
 
     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 = StoreManager::get_raw_storage(dpp(), g_ceph_context, "rados");
     } else {
       store = StoreManager::get_storage(dpp(), g_ceph_context, "rados", 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 3d11536cdbfc1ef65cf153d8b882e469bf9fbe9a..6816b3873bd4b4e3f9ce90e792d966fcc1da0a20 100644 (file)
@@ -1199,12 +1199,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 a1d0c719800e9576b50443a103ad633727a91bd0..23fd3a2d460f8b01a6603d938033d73ff7b08f86 100644 (file)
@@ -401,7 +401,7 @@ class RGWRados
   SafeTimer *timer;
 
   rgw::sal::RadosStore* store;
-  RGWGC *gc;
+  RGWGC *gc = nullptr;
   RGWLC *lc;
   RGWObjectExpirer *obj_expirer;
   bool use_gc_thread;
@@ -480,6 +480,7 @@ protected:
   RGWIndexCompletionManager *index_completion_manager{nullptr};
 
   bool use_cache{false};
+  bool use_gc{true};
 
   int get_obj_head_ioctx(const RGWBucketInfo& bucket_info, const rgw_obj& obj, librados::IoCtx *ioctx);
 public:
@@ -501,6 +502,11 @@ public:
     return *this;
   }
 
+  RGWRados& set_use_gc(bool status) {
+    use_gc = status;
+    return *this;
+  }
+
   RGWLC *get_lc() {
     return lc;
   }
index 2105e547feddfe79153bc7badb7c9a82c8e4dccb..167f1f91ece112679e3017fa81dea8f6b5796f08 100644 (file)
@@ -30,7 +30,7 @@ extern "C" {
 extern rgw::sal::Store* newStore(void);
 }
 
-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)
+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* store = nullptr;
   if (svc.compare("rados") == 0) {
@@ -38,6 +38,7 @@ rgw::sal::Store* StoreManager::init_storage_provider(const DoutPrefixProvider* d
     RGWRados* rados = static_cast<rgw::sal::RadosStore* >(store)->getRados();
 
     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 e4f351d2f2f57fbdc40d65c466f29542da23dd82..082f6ddfbeeff4a381c937121fee697daa0817ae 100644 (file)
@@ -918,16 +918,16 @@ class StoreManager {
 public:
   StoreManager() {}
   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,
-                               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::Store* store = init_storage_provider(dpp, cct, svc, 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::Store* get_raw_storage(const DoutPrefixProvider* dpp, CephContext* cct, const std::string svc) {
     rgw::sal::Store* store = init_raw_storage_provider(dpp, cct, svc);
     return 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);
+  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_raw_storage_provider(const DoutPrefixProvider* dpp, CephContext* cct, const std::string svc);
   static void close_storage(rgw::sal::Store* store);