]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add 'radosgw-admin bilog autotrim'
authorCasey Bodley <cbodley@redhat.com>
Wed, 6 Sep 2017 16:59:03 +0000 (12:59 -0400)
committerCasey Bodley <cbodley@redhat.com>
Fri, 10 Nov 2017 18:23:01 +0000 (13:23 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_sync_log_trim.cc
src/rgw/rgw_sync_log_trim.h

index 61220f36a761635d4903bed82860d4ae9f57e414..98e307cb3054f4f4f3fca1099734504796bd2426 100644 (file)
@@ -38,6 +38,7 @@
 #include "rgw_replica_log.h"
 #include "rgw_orphan.h"
 #include "rgw_sync.h"
+#include "rgw_sync_log_trim.h"
 #include "rgw_data_sync.h"
 #include "rgw_rest_conn.h"
 #include "rgw_realm_watcher.h"
@@ -434,6 +435,7 @@ enum {
   OPT_BILOG_LIST,
   OPT_BILOG_TRIM,
   OPT_BILOG_STATUS,
+  OPT_BILOG_AUTOTRIM,
   OPT_DATA_SYNC_STATUS,
   OPT_DATA_SYNC_INIT,
   OPT_DATA_SYNC_RUN,
@@ -858,6 +860,8 @@ static int get_cmd(const char *cmd, const char *prev_cmd, const char *prev_prev_
       return OPT_BILOG_TRIM;
     if (strcmp(cmd, "status") == 0)
       return OPT_BILOG_STATUS;
+    if (strcmp(cmd, "autotrim") == 0)
+      return OPT_BILOG_AUTOTRIM;
   } else if (strcmp(prev_cmd, "data") == 0) {
     if (strcmp(cmd, "sync") == 0) {
       *need_more = true;
@@ -6728,6 +6732,25 @@ next:
     formatter->flush(cout);
   }
 
+  if (opt_cmd == OPT_BILOG_AUTOTRIM) {
+    rgw::BucketTrimConfig config;
+    configure_bucket_trim(store->ctx(), config);
+
+    rgw::BucketTrimManager trim(store, config);
+    ret = trim.init();
+    if (ret < 0) {
+      cerr << "trim manager init failed with " << cpp_strerror(ret) << std::endl;
+      return -ret;
+    }
+
+    RGWCoroutinesManager crs(store->ctx(), store->get_cr_registry());
+    ret = crs.run(trim.create_admin_bucket_trim_cr());
+    if (ret < 0) {
+      cerr << "automated bilog trim failed with " << cpp_strerror(ret) << std::endl;
+      return -ret;
+    }
+  }
+
   if (opt_cmd == OPT_DATALOG_LIST) {
     formatter->open_array_section("entries");
     bool truncated;
index 0ff0b0e169bc7eb3cc7ec2dcf9dcb30c64ee8dab..260848ac9c2311b92fe2e46e348c302b06a2ba94 100644 (file)
@@ -840,4 +840,11 @@ RGWCoroutine* BucketTrimManager::create_bucket_trim_cr()
                               impl.get(), impl->status_obj);
 }
 
+RGWCoroutine* BucketTrimManager::create_admin_bucket_trim_cr()
+{
+  // return the trim coroutine without any polling
+  return new BucketTrimCR(impl->store, impl->config,
+                          impl.get(), impl->status_obj);
+}
+
 } // namespace rgw
index d8a1cacc74110b0ef2081aeeac9a653ab2b036bc..9585426927fdc6ef235c66a7858edd2b405f7c4c 100644 (file)
@@ -77,6 +77,9 @@ class BucketTrimManager : public BucketChangeObserver {
 
   /// create a coroutine to run the bucket trim process every trim interval
   RGWCoroutine* create_bucket_trim_cr();
+
+  /// create a coroutine to trim buckets directly via radosgw-admin
+  RGWCoroutine* create_admin_bucket_trim_cr();
 };
 
 /// provides persistent storage for the trim manager's current position in the