]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add RGWRadosBILogTrimCR
authorCasey Bodley <cbodley@redhat.com>
Thu, 14 Sep 2017 20:50:47 +0000 (16:50 -0400)
committerCasey Bodley <cbodley@redhat.com>
Fri, 10 Nov 2017 18:23:02 +0000 (13:23 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/cls/rgw/cls_rgw_client.h
src/rgw/rgw_cr_rados.cc
src/rgw/rgw_cr_rados.h

index 3a49c2dbbefd6b6e36d365febc892ee4eb144706..6b399890793d86f1db081a70447f1de5b35bb0d5 100644 (file)
@@ -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"
index 002220f2e421cdbc9f7d9207fa920ad3254b8408..5f4fd72cf3a50c133fdd4acafd0073dfa4bf3e14 100644 (file)
@@ -3,6 +3,7 @@
 #include "rgw_cr_rados.h"
 
 #include "cls/lock/cls_lock_client.h"
+#include "cls/rgw/cls_rgw_client.h"
 
 #include <boost/asio/yield.hpp>
 
@@ -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 '<shard-id>#' 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);
index 144ffbc0bf2494d73c056e694035a27b5060f256..4f9089a9862703b7ae4087dada8c7e9cef8a3575 100644 (file)
@@ -716,6 +716,20 @@ public:
   }
 };
 
+class RGWRadosBILogTrimCR : public RGWSimpleCoroutine {
+  RGWRados::BucketShard bs;
+  std::string start_marker;
+  std::string end_marker;
+  boost::intrusive_ptr<RGWAioCompletionNotifier> 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;