From 21aef40b727ddfd7fba4e4c341ddd1cf2e21c404 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Fri, 15 Sep 2017 14:09:14 -0400 Subject: [PATCH] rgw: start BucketTrimManager in RGWRados Signed-off-by: Casey Bodley (cherry picked from commit 74aedaef0757f56a77671d6de59628538cfa0bbb) --- src/rgw/rgw_rados.cc | 23 +++++++++++++++++++++-- src/rgw/rgw_rados.h | 2 ++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index fc480a516de6..5c34c063de66 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -3247,15 +3247,18 @@ class RGWSyncLogTrimThread : public RGWSyncProcessorThread { RGWCoroutinesManager crs; RGWRados *store; + rgw::BucketTrimManager *bucket_trim; RGWHTTPManager http; const utime_t trim_interval; uint64_t interval_msec() override { return 0; } void stop_process() override { crs.stop(); } public: - RGWSyncLogTrimThread(RGWRados *store, int interval) + RGWSyncLogTrimThread(RGWRados *store, rgw::BucketTrimManager *bucket_trim, + int interval) : RGWSyncProcessorThread(store, "sync-log-trim"), crs(store->ctx(), store->get_cr_registry()), store(store), + bucket_trim(bucket_trim), http(store->ctx(), crs.get_completion_mgr()), trim_interval(interval, 0) {} @@ -3277,6 +3280,10 @@ public: trim_interval)); stacks.push_back(data); + auto bucket = new RGWCoroutinesStack(store->ctx(), &crs); + bucket->call(bucket_trim->create_bucket_trim_cr(&http)); + stacks.push_back(bucket); + crs.run(stacks); return 0; } @@ -3687,6 +3694,7 @@ void RGWRados::finalize() data_sync_processor_threads.clear(); delete sync_log_trimmer; sync_log_trimmer = nullptr; + bucket_trim = boost::none; } if (finisher) { finisher->stop(); @@ -4532,6 +4540,17 @@ int RGWRados::init_complete() } meta_sync_processor_thread->start(); + // configure the bucket trim manager + rgw::BucketTrimConfig config; + rgw::configure_bucket_trim(cct, config); + + bucket_trim.emplace(this, config); + ret = bucket_trim->init(); + if (ret < 0) { + ldout(cct, 0) << "ERROR: failed to start bucket trim manager" << dendl; + return ret; + } + Mutex::Locker dl(data_sync_thread_lock); for (auto iter : zone_data_sync_from_map) { ldout(cct, 5) << "starting data sync thread for zone " << iter.first << dendl; @@ -4546,7 +4565,7 @@ int RGWRados::init_complete() } auto interval = cct->_conf->rgw_sync_log_trim_interval; if (interval > 0) { - sync_log_trimmer = new RGWSyncLogTrimThread(this, interval); + sync_log_trimmer = new RGWSyncLogTrimThread(this, &*bucket_trim, interval); ret = sync_log_trimmer->init(); if (ret < 0) { ldout(cct, 0) << "ERROR: failed to initialize sync log trim thread" << dendl; diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index faabb9cec216..5ed33343bf23 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -23,6 +23,7 @@ #include "rgw_meta_sync_status.h" #include "rgw_period_puller.h" #include "rgw_sync_module.h" +#include "rgw_sync_log_trim.h" class RGWWatcher; class SafeTimer; @@ -2267,6 +2268,7 @@ class RGWRados RGWMetaSyncProcessorThread *meta_sync_processor_thread; map data_sync_processor_threads; + boost::optional bucket_trim; RGWSyncLogTrimThread *sync_log_trimmer{nullptr}; Mutex meta_sync_thread_lock; -- 2.47.3