]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Refactored methods in rgw gc based on gc log helpers.
authorPritha Srivastava <prsrivas@redhat.com>
Fri, 4 Oct 2019 08:10:36 +0000 (13:40 +0530)
committerPritha Srivastava <prsrivas@redhat.com>
Wed, 16 Oct 2019 04:02:16 +0000 (09:32 +0530)
Signed-off-by: Pritha Srivastava <prsrivas@redhat.com>
src/rgw/rgw_gc.cc
src/rgw/rgw_gc.h
src/rgw/rgw_gc_log.cc

index ab3542643129e5b7ff169a8c2d219b863a4b2047..6d24a0950439247189ef59987613993d60b252aa 100644 (file)
@@ -13,6 +13,7 @@
 #include "rgw_perf_counters.h"
 #include "cls/lock/cls_lock_client.h"
 #include "include/random.h"
+#include "rgw_gc_log.h"
 
 #include <list> // XXX
 #include <sstream>
@@ -46,12 +47,8 @@ void RGWGC::initialize(CephContext *_cct, RGWRados *_store) {
     //version = 1 -> marked ready for transition
     librados::ObjectWriteOperation op;
     op.create(false);
-    obj_version objv;
-    cls_version_check(op, objv, VER_COND_EQ);
     const uint64_t queue_size = cct->_conf->rgw_gc_max_queue_size, num_urgent_data_entries = cct->_conf->rgw_gc_num_urgent_data_entries;
-    cls_rgw_gc_queue_init(op, queue_size, num_urgent_data_entries);
-    objv.ver = 1;
-    cls_version_set(op, objv);
+    gc_log_init2(op, queue_size, num_urgent_data_entries);
     store->gc_operate(obj_names[i], &op);
   }
 }
@@ -66,21 +63,13 @@ int RGWGC::tag_index(const string& tag)
   return rgw_shard_id(tag, max_objs);
 }
 
-void RGWGC::add_chain(ObjectWriteOperation& op, cls_rgw_gc_obj_info& info)
-{
-  obj_version objv;
-  objv.ver = 1;
-  cls_version_check(op, objv, VER_COND_EQ);
-  cls_rgw_gc_queue_enqueue(op, cct->_conf->rgw_gc_obj_min_wait, info);
-}
-
 int RGWGC::send_chain(cls_rgw_obj_chain& chain, const string& tag)
 {
   ObjectWriteOperation op;
   cls_rgw_gc_obj_info info;
   info.chain = chain;
   info.tag = tag;
-  add_chain(op, info);
+  gc_log_enqueue2(op, cct->_conf->rgw_gc_obj_min_wait, info);
 
   int i = tag_index(tag);
 
@@ -137,13 +126,12 @@ void RGWGC::on_defer_canceled(const cls_rgw_gc_obj_info& info)
 int RGWGC::async_defer_chain(const string& tag, const cls_rgw_obj_chain& chain)
 {
   const int i = tag_index(tag);
+  cls_rgw_gc_obj_info info;
+  info.chain = chain;
+  info.tag = tag;
 
   // if we've transitioned this shard object, we can rely on the cls_rgw_gc queue
   if (transitioned_objects_cache[i]) {
-    cls_rgw_gc_obj_info info;
-    info.chain = chain;
-    info.tag = tag;
-
     ObjectWriteOperation op;
     cls_rgw_gc_queue_defer_entry(op, cct->_conf->rgw_gc_obj_min_wait, info);
 
@@ -162,10 +150,7 @@ int RGWGC::async_defer_chain(const string& tag, const cls_rgw_obj_chain& chain)
 
   // assert that we haven't initialized cls_rgw_gc queue. this prevents us
   // from writing new entries to omap after the transition
-  obj_version objv; // objv.ver = 0
-  cls_version_check(op, objv, VER_COND_EQ);
-
-  cls_rgw_gc_defer_entry(op, cct->_conf->rgw_gc_obj_min_wait, tag);
+  gc_log_defer1(op, cct->_conf->rgw_gc_obj_min_wait, info);
 
   // prepare a callback to detect the transition via ECANCELED from cls_version_check()
   auto state = std::make_unique<defer_chain_state>();
index 4cc19226982c8f66c9824db62e470eefee79b6c5..6917394a4648fbd45675a4e63c87a55d920e8022 100644 (file)
@@ -48,7 +48,6 @@ public:
     finalize();
   }
   vector<bool> transitioned_objects_cache;
-  void add_chain(librados::ObjectWriteOperation& op, cls_rgw_gc_obj_info& info);
   int send_chain(cls_rgw_obj_chain& chain, const string& tag);
 
   // asynchronously defer garbage collection on an object that's still being read
index cd30af14ff96f5fcd63baf6ec65d53774b76e8e8..53dd7ec0efdeb6356c1518b2dff3163c53b9b40b 100644 (file)
@@ -14,7 +14,8 @@ void gc_log_init2(librados::ObjectWriteOperation& op,
   obj_version objv; // objv.ver = 0
   cls_version_check(op, objv, VER_COND_EQ);
   cls_rgw_gc_queue_init(op, max_size, max_urgent);
-  cls_version_inc(op); // objv.ver -> 1
+  objv.ver = 1;
+  cls_version_set(op, objv);
 }
 
 void gc_log_enqueue1(librados::ObjectWriteOperation& op,