From 2c07d7dd0e6c358bcdba409747ebf13f846a77e1 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Fri, 1 Sep 2017 12:37:56 -0400 Subject: [PATCH] rgw: add BucketTrimStatus Signed-off-by: Casey Bodley --- src/rgw/rgw_sync_log_trim.cc | 7 +++++-- src/rgw/rgw_sync_log_trim.h | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_sync_log_trim.cc b/src/rgw/rgw_sync_log_trim.cc index 4eaddf71721..a83f37cd288 100644 --- a/src/rgw/rgw_sync_log_trim.cc +++ b/src/rgw/rgw_sync_log_trim.cc @@ -18,10 +18,10 @@ #include "common/bounded_key_counter.h" #include "common/errno.h" +#include "rgw_sync_log_trim.h" #include "rgw_cr_rados.h" #include "rgw_metadata.h" #include "rgw_rados.h" -#include "rgw_sync_log_trim.h" #include "rgw_sync.h" #include @@ -35,6 +35,9 @@ using rgw::BucketTrimConfig; using BucketChangeCounter = BoundedKeyCounter; +const std::string rgw::BucketTrimStatus::oid = "bilog.trim"; +using rgw::BucketTrimStatus; + // watch/notify api for gateways to coordinate about which buckets to trim enum TrimNotifyType { @@ -614,7 +617,7 @@ class BucketTrimManager::Impl : public TrimCounters::Server { Impl(RGWRados *store, const BucketTrimConfig& config) : store(store), config(config), - status_obj(store->get_zone_params().log_pool, "bilog.trim"), + status_obj(store->get_zone_params().log_pool, BucketTrimStatus::oid), counter(config.counter_size), watcher(store, status_obj, this) {} diff --git a/src/rgw/rgw_sync_log_trim.h b/src/rgw/rgw_sync_log_trim.h index ea47734e238..e54a74a582d 100644 --- a/src/rgw/rgw_sync_log_trim.h +++ b/src/rgw/rgw_sync_log_trim.h @@ -18,6 +18,7 @@ #include #include +#include "include/encoding.h" class CephContext; class RGWCoroutine; @@ -69,6 +70,27 @@ class BucketTrimManager : public BucketChangeObserver { RGWCoroutine* create_bucket_trim_cr(); }; +/// provides persistent storage for the trim manager's current position in the +/// list of bucket instance metadata +struct BucketTrimStatus { + std::string marker; //< metadata key of current bucket instance + + void encode(bufferlist& bl) const { + ENCODE_START(1, 1, bl); + ::encode(marker, bl); + ENCODE_FINISH(bl); + } + void decode(bufferlist::iterator& p) { + DECODE_START(1, p); + ::decode(marker, p); + DECODE_FINISH(p); + } + + static const std::string oid; +}; + } // namespace rgw +WRITE_CLASS_ENCODER(rgw::BucketTrimStatus); + #endif // RGW_SYNC_LOG_TRIM_H -- 2.39.5