From: Casey Bodley Date: Wed, 6 Sep 2017 16:59:03 +0000 (-0400) Subject: rgw: add 'radosgw-admin bilog autotrim' X-Git-Tag: v13.0.1~210^2~20 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4f736f1ec74f74e8dc1ae4ffb5b71274351c66f0;p=ceph.git rgw: add 'radosgw-admin bilog autotrim' Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 61220f36a761..98e307cb3054 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -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; diff --git a/src/rgw/rgw_sync_log_trim.cc b/src/rgw/rgw_sync_log_trim.cc index 0ff0b0e169bc..260848ac9c23 100644 --- a/src/rgw/rgw_sync_log_trim.cc +++ b/src/rgw/rgw_sync_log_trim.cc @@ -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 diff --git a/src/rgw/rgw_sync_log_trim.h b/src/rgw/rgw_sync_log_trim.h index d8a1cacc7411..9585426927fd 100644 --- a/src/rgw/rgw_sync_log_trim.h +++ b/src/rgw/rgw_sync_log_trim.h @@ -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