From 0dea44dad3a572cd966d22dd345c1e226c073f6e Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Thu, 14 Sep 2017 16:50:47 -0400 Subject: [PATCH] rgw: add RGWRadosBILogTrimCR Signed-off-by: Casey Bodley --- src/cls/rgw/cls_rgw_client.h | 1 + src/rgw/rgw_cr_rados.cc | 46 ++++++++++++++++++++++++++++++++++++ src/rgw/rgw_cr_rados.h | 14 +++++++++++ 3 files changed, 61 insertions(+) diff --git a/src/cls/rgw/cls_rgw_client.h b/src/cls/rgw/cls_rgw_client.h index 3a49c2dbbefd6..6b399890793d8 100644 --- a/src/cls/rgw/cls_rgw_client.h +++ b/src/cls/rgw/cls_rgw_client.h @@ -4,6 +4,7 @@ #include "include/str_list.h" #include "include/rados/librados.hpp" #include "cls_rgw_ops.h" +#include "cls_rgw_const.h" #include "common/RefCountedObj.h" #include "include/compat.h" #include "common/ceph_time.h" diff --git a/src/rgw/rgw_cr_rados.cc b/src/rgw/rgw_cr_rados.cc index 002220f2e421c..5f4fd72cf3a50 100644 --- a/src/rgw/rgw_cr_rados.cc +++ b/src/rgw/rgw_cr_rados.cc @@ -3,6 +3,7 @@ #include "rgw_cr_rados.h" #include "cls/lock/cls_lock_client.h" +#include "cls/rgw/cls_rgw_client.h" #include @@ -491,6 +492,51 @@ int RGWAsyncGetBucketInstanceInfo::_send_request() return 0; } +static std::string normalize_shard_marker(const std::string& marker) +{ + // markers may be formatted with '#' at the beginning. + // CLSRGWIssueBILogTrim would fix this for us, but it's synchronous + auto p = marker.find(BucketIndexShardsManager::KEY_VALUE_SEPARATOR); + if (p == marker.npos) { + return marker; + } + return marker.substr(p + 1); +} + +RGWRadosBILogTrimCR::RGWRadosBILogTrimCR(RGWRados *store, + const RGWBucketInfo& bucket_info, + int shard_id, + const std::string& start_marker, + const std::string& end_marker) + : RGWSimpleCoroutine(store->ctx()), bs(store), + start_marker(normalize_shard_marker(start_marker)), + end_marker(normalize_shard_marker(end_marker)) +{ + bs.init(bucket_info, shard_id); +} + +int RGWRadosBILogTrimCR::send_request() +{ + bufferlist in; + cls_rgw_bi_log_trim_op call; + call.start_marker = std::move(start_marker); + call.end_marker = std::move(end_marker); + ::encode(call, in); + + librados::ObjectWriteOperation op; + op.exec(RGW_CLASS, RGW_BI_LOG_TRIM, in); + + cn = stack->create_completion_notifier(); + return bs.index_ctx.aio_operate(bs.bucket_obj, cn->completion(), &op); +} + +int RGWRadosBILogTrimCR::request_complete() +{ + int r = cn->completion()->get_return_value(); + set_status() << "request complete; ret=" << r; + return r; +} + int RGWAsyncFetchRemoteObj::_send_request() { RGWObjectCtx obj_ctx(store); diff --git a/src/rgw/rgw_cr_rados.h b/src/rgw/rgw_cr_rados.h index 144ffbc0bf249..4f9089a986270 100644 --- a/src/rgw/rgw_cr_rados.h +++ b/src/rgw/rgw_cr_rados.h @@ -716,6 +716,20 @@ public: } }; +class RGWRadosBILogTrimCR : public RGWSimpleCoroutine { + RGWRados::BucketShard bs; + std::string start_marker; + std::string end_marker; + boost::intrusive_ptr cn; + public: + RGWRadosBILogTrimCR(RGWRados *store, const RGWBucketInfo& bucket_info, + int shard_id, const std::string& start_marker, + const std::string& end_marker); + + int send_request() override; + int request_complete() override; +}; + class RGWAsyncFetchRemoteObj : public RGWAsyncRadosRequest { RGWRados *store; string source_zone; -- 2.39.5