]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/log: C++ namespaces exist
authorAdam C. Emerson <aemerson@redhat.com>
Tue, 24 Jan 2023 21:35:23 +0000 (16:35 -0500)
committerAdam Emerson <aemerson@redhat.com>
Thu, 14 Sep 2023 21:48:00 +0000 (17:48 -0400)
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
23 files changed:
src/cls/log/cls_log.cc
src/cls/log/cls_log_client.cc
src/cls/log/cls_log_client.h
src/cls/log/cls_log_ops.h
src/cls/log/cls_log_types.h
src/rgw/driver/rados/rgw_cr_rados.cc
src/rgw/driver/rados/rgw_cr_rados.h
src/rgw/driver/rados/rgw_datalog.cc
src/rgw/driver/rados/rgw_datalog.h
src/rgw/driver/rados/rgw_metadata.cc
src/rgw/driver/rados/rgw_metadata.h
src/rgw/driver/rados/rgw_rest_log.cc
src/rgw/driver/rados/rgw_rest_log.h
src/rgw/driver/rados/rgw_sync.cc
src/rgw/driver/rados/rgw_sync.h
src/rgw/rgw_admin.cc
src/rgw/rgw_mdlog.h
src/rgw/rgw_metadata.cc
src/rgw/services/svc_cls.cc
src/rgw/services/svc_cls.h
src/test/cls_log/test_cls_log.cc
src/test/rgw/test_log_backing.cc
src/tools/ceph-dencoder/rgw_types.h

index 65b070756e7128ce4e37e63b42d3d03a8cb9cf20..c1126b5659d88785105d31d31c2925039d7c9c94 100644 (file)
@@ -25,7 +25,7 @@ CLS_NAME(log)
 static string log_index_prefix = "1_";
 
 
-static int write_log_entry(cls_method_context_t hctx, string& index, cls_log_entry& entry)
+static int write_log_entry(cls_method_context_t hctx, string& index, cls::log::entry& entry)
 {
   bufferlist bl;
   encode(entry, bl);
@@ -46,7 +46,7 @@ static void get_index_time_prefix(ceph::real_time ts, string& index)
   index = log_index_prefix + buf;
 }
 
-static int read_header(cls_method_context_t hctx, cls_log_header& header)
+static int read_header(cls_method_context_t hctx, cls::log::header& header)
 {
   bufferlist header_bl;
 
@@ -55,7 +55,7 @@ static int read_header(cls_method_context_t hctx, cls_log_header& header)
     return ret;
 
   if (header_bl.length() == 0) {
-    header = cls_log_header();
+    header = cls::log::header();
     return 0;
   }
 
@@ -69,7 +69,7 @@ static int read_header(cls_method_context_t hctx, cls_log_header& header)
   return 0;
 }
 
-static int write_header(cls_method_context_t hctx, cls_log_header& header)
+static int write_header(cls_method_context_t hctx, cls::log::header& header)
 {
   bufferlist header_bl;
   encode(header, header_bl);
@@ -96,22 +96,22 @@ static int cls_log_add(cls_method_context_t hctx, bufferlist *in, bufferlist *ou
 {
   auto in_iter = in->cbegin();
 
-  cls_log_add_op op;
+  cls::log::ops::add_op op;
   try {
     decode(op, in_iter);
   } catch (ceph::buffer::error& err) {
-    CLS_LOG(1, "ERROR: cls_log_add_op(): failed to decode op");
+    CLS_LOG(1, "ERROR: cls::log::ops::add_op(): failed to decode op");
     return -EINVAL;
   }
 
-  cls_log_header header;
+  cls::log::header header;
 
   int ret = read_header(hctx, header);
   if (ret < 0)
     return ret;
 
   for (auto iter = op.entries.begin(); iter != op.entries.end(); ++iter) {
-    cls_log_entry& entry = *iter;
+    cls::log::entry& entry = *iter;
 
     string index;
 
@@ -150,11 +150,11 @@ static int cls_log_list(cls_method_context_t hctx, bufferlist *in, bufferlist *o
 {
   auto in_iter = in->cbegin();
 
-  cls_log_list_op op;
+  cls::log::ops::list_op op;
   try {
     decode(op, in_iter);
   } catch (ceph::buffer::error& err) {
-    CLS_LOG(1, "ERROR: cls_log_list_op(): failed to decode op");
+    CLS_LOG(1, "ERROR: cls::log::ops::list_op(): failed to decode op");
     return -EINVAL;
   }
 
@@ -178,7 +178,7 @@ static int cls_log_list(cls_method_context_t hctx, bufferlist *in, bufferlist *o
   if (!max_entries || max_entries > MAX_ENTRIES)
     max_entries = MAX_ENTRIES;
 
-  cls_log_list_ret ret;
+  cls::log::ops::list_ret ret;
 
   int rc = cls_cxx_map_get_vals(hctx, from_index, log_index_prefix, max_entries, &keys, &ret.truncated);
   if (rc < 0)
@@ -200,7 +200,7 @@ static int cls_log_list(cls_method_context_t hctx, bufferlist *in, bufferlist *o
     bufferlist& bl = iter->second;
     auto biter = bl.cbegin();
     try {
-      cls_log_entry e;
+      cls::log::entry e;
       decode(e, biter);
       entries.push_back(e);
     } catch (ceph::buffer::error& err) {
@@ -220,7 +220,7 @@ static int cls_log_trim(cls_method_context_t hctx, bufferlist *in, bufferlist *o
 {
   auto in_iter = in->cbegin();
 
-  cls_log_trim_op op;
+  cls::log::ops::trim_op op;
   try {
     decode(op, in_iter);
   } catch (ceph::buffer::error& err) {
@@ -284,15 +284,15 @@ static int cls_log_info(cls_method_context_t hctx, bufferlist *in, bufferlist *o
 {
   auto in_iter = in->cbegin();
 
-  cls_log_info_op op;
+  cls::log::ops::info_op op;
   try {
     decode(op, in_iter);
   } catch (ceph::buffer::error& err) {
-    CLS_LOG(1, "ERROR: cls_log_add_op(): failed to decode op");
+    CLS_LOG(1, "ERROR: cls::log::ops::add_op(): failed to decode op");
     return -EINVAL;
   }
 
-  cls_log_info_ret ret;
+  cls::log::ops::info_ret ret;
 
   int rc = read_header(hctx, ret.header);
   if (rc < 0)
index 531cb765f72806a1622dccd10424ab05b732bdba..5af994d4ffa1898683b4a8f135794e4693b3063b 100644 (file)
@@ -16,25 +16,25 @@ using namespace librados;
 
 
 
-void cls_log_add(librados::ObjectWriteOperation& op, vector<cls_log_entry>& entries, bool monotonic_inc)
+void cls_log_add(librados::ObjectWriteOperation& op, vector<cls::log::entry>& entries, bool monotonic_inc)
 {
   bufferlist in;
-  cls_log_add_op call;
+  cls::log::ops::add_op call;
   call.entries = entries;
   encode(call, in);
   op.exec("log", "add", in);
 }
 
-void cls_log_add(librados::ObjectWriteOperation& op, cls_log_entry& entry)
+void cls_log_add(librados::ObjectWriteOperation& op, cls::log::entry& entry)
 {
   bufferlist in;
-  cls_log_add_op call;
+  cls::log::ops::add_op call;
   call.entries.push_back(entry);
   encode(call, in);
   op.exec("log", "add", in);
 }
 
-void cls_log_add_prepare_entry(cls_log_entry& entry, ceph::real_time timestamp,
+void cls_log_add_prepare_entry(cls::log::entry& entry, ceph::real_time timestamp,
                               const string& section, const string& name, bufferlist& bl)
 {
   entry.timestamp = timestamp;
@@ -46,7 +46,7 @@ void cls_log_add_prepare_entry(cls_log_entry& entry, ceph::real_time timestamp,
 void cls_log_add(librados::ObjectWriteOperation& op, ceph::real_time timestamp,
                  const string& section, const string& name, bufferlist& bl)
 {
-  cls_log_entry entry;
+  cls::log::entry entry;
 
   cls_log_add_prepare_entry(entry, timestamp, section, name, bl);
   cls_log_add(op, entry);
@@ -56,7 +56,7 @@ void cls_log_trim(librados::ObjectWriteOperation& op, ceph::real_time from_time,
                  ceph::real_time to_time, const string& from_marker, const string& to_marker)
 {
   bufferlist in;
-  cls_log_trim_op call;
+  cls::log::ops::trim_op call;
   call.from_time = from_time;
   call.to_time = to_time;
   call.from_marker = from_marker;
@@ -89,15 +89,15 @@ int cls_log_trim(librados::IoCtx& io_ctx, const string& oid,
 }
 
 class LogListCtx : public ObjectOperationCompletion {
-  vector<cls_log_entry> *entries;
+  vector<cls::log::entry>* entries;
   string *marker;
   bool *truncated;
 public:
-  LogListCtx(vector<cls_log_entry> *_entries, string *_marker, bool *_truncated) :
-                                      entries(_entries), marker(_marker), truncated(_truncated) {}
+  LogListCtx(vector<cls::log::entry> *_entries, string *_marker, bool *_truncated) :
+    entries(_entries), marker(_marker), truncated(_truncated) {}
   void handle_completion(int r, bufferlist& outbl) override {
     if (r >= 0) {
-      cls_log_list_ret ret;
+      cls::log::ops::list_ret ret;
       try {
         auto iter = outbl.cbegin();
         decode(ret, iter);
@@ -116,11 +116,11 @@ public:
 
 void cls_log_list(librados::ObjectReadOperation& op, ceph::real_time from,
                  ceph::real_time to, const string& in_marker, int max_entries,
-                 vector<cls_log_entry>& entries,
+                 vector<cls::log::entry>& entries,
                   string *out_marker, bool *truncated)
 {
   bufferlist inbl;
-  cls_log_list_op call;
+  cls::log::ops::list_op call;
   call.from_time = from;
   call.to_time = to;
   call.marker = in_marker;
@@ -132,12 +132,12 @@ void cls_log_list(librados::ObjectReadOperation& op, ceph::real_time from,
 }
 
 class LogInfoCtx : public ObjectOperationCompletion {
-  cls_log_header *header;
+  cls::log::header* header;
 public:
-  explicit LogInfoCtx(cls_log_header *_header) : header(_header) {}
+  explicit LogInfoCtx(cls::log::header *_header) : header(_header) {}
   void handle_completion(int r, bufferlist& outbl) override {
     if (r >= 0) {
-      cls_log_info_ret ret;
+      cls::log::ops::info_ret ret;
       try {
         auto iter = outbl.cbegin();
         decode(ret, iter);
@@ -150,10 +150,10 @@ public:
   }
 };
 
-void cls_log_info(librados::ObjectReadOperation& op, cls_log_header *header)
+void cls_log_info(librados::ObjectReadOperation& op, cls::log::header *header)
 {
   bufferlist inbl;
-  cls_log_info_op call;
+  cls::log::ops::info_op call;
 
   encode(call, inbl);
 
index 12cd88c2601706d4dd8d0eba5e594b15b83f8f01..0b6eac6e9cb536b75a8c620786bcddf480e3c8a2 100644 (file)
  * log objclass
  */
 
-void cls_log_add_prepare_entry(cls_log_entry& entry, ceph::real_time timestamp,
+void cls_log_add_prepare_entry(cls::log::entry& entry, ceph::real_time timestamp,
                               const std::string& section,
                               const std::string& name, ceph::buffer::list& bl);
 
-void cls_log_add(librados::ObjectWriteOperation& op, std::vector<cls_log_entry>& entries, bool monotonic_inc);
-void cls_log_add(librados::ObjectWriteOperation& op, cls_log_entry& entry);
+void cls_log_add(librados::ObjectWriteOperation& op, std::vector<cls::log::entry>& entries, bool monotonic_inc);
+void cls_log_add(librados::ObjectWriteOperation& op, cls::log::entry& entry);
 void cls_log_add(librados::ObjectWriteOperation& op, ceph::real_time timestamp,
                  const std::string& section, const std::string& name, ceph::buffer::list& bl);
 
 void cls_log_list(librados::ObjectReadOperation& op, ceph::real_time from,
                  ceph::real_time to, const std::string& in_marker,
-                 int max_entries, std::vector<cls_log_entry>& entries,
+                 int max_entries, std::vector<cls::log::entry>& entries,
                   std::string *out_marker, bool *truncated);
 
 void cls_log_trim(librados::ObjectWriteOperation& op, ceph::real_time from_time,
@@ -37,6 +37,6 @@ int cls_log_trim(librados::IoCtx& io_ctx, const std::string& oid,
                  const std::string& from_marker, const std::string& to_marker);
 #endif
 
-void cls_log_info(librados::ObjectReadOperation& op, cls_log_header *header);
+void cls_log_info(librados::ObjectReadOperation& op, cls::log::header* header);
 
 #endif
index 6d0c687e996a316582d8278b895a30012a2c1fca..cf8edcd87f8d72264f93670e30b1bfb5d36b6f44 100644 (file)
@@ -4,13 +4,19 @@
 #ifndef CEPH_CLS_LOG_OPS_H
 #define CEPH_CLS_LOG_OPS_H
 
+#include <string>
+#include <vector>
+
+#include "common/ceph_time.h"
+
 #include "cls_log_types.h"
 
-struct cls_log_add_op {
-  std::vector<cls_log_entry> entries;
-  bool monotonic_inc;
+namespace cls::log::ops {
+struct add_op {
+  std::vector<entry> entries;
+  bool monotonic_inc = true;
 
-  cls_log_add_op() : monotonic_inc(true) {}
+  add_op() = default;
 
   void encode(ceph::buffer::list& bl) const {
     ENCODE_START(2, 1, bl);
@@ -33,12 +39,12 @@ struct cls_log_add_op {
     encode_json("monotonic_inc", monotonic_inc, f);
   }
 
-  static void generate_test_instances(std::list<cls_log_add_op *>& l) {
+  static void generate_test_instances(std::list<add_op *>& l) {
     using namespace std::literals;
-    l.push_back(new cls_log_add_op);
-    l.push_back(new cls_log_add_op);
-    l.back()->entries.push_back(cls_log_entry());
-    l.back()->entries.push_back(cls_log_entry());
+    l.push_back(new add_op);
+    l.push_back(new add_op);
+    l.back()->entries.push_back(entry{});
+    l.back()->entries.push_back(entry{});
     l.back()->entries.back().section = "section";
     l.back()->entries.back().name = "name";
     l.back()->entries.back().timestamp = ceph::real_time{1s + 2ns};
@@ -46,16 +52,16 @@ struct cls_log_add_op {
     l.back()->entries.back().id = "id";
   }
 };
-WRITE_CLASS_ENCODER(cls_log_add_op)
+WRITE_CLASS_ENCODER(add_op)
 
-struct cls_log_list_op {
+struct list_op {
   ceph::real_time from_time;
   std::string marker; /* if not empty, overrides from_time */
   ceph::real_time to_time; /* not inclusive */
-  int max_entries; /* upperbound to returned num of entries
-                      might return less than that and still be truncated */
+  int max_entries = 0; /* upperbound to returned num of entries
+                         might return less than that and still be truncated */
 
-  cls_log_list_op() : max_entries(0) {}
+  list_op() = default;
 
   void encode(ceph::buffer::list& bl) const {
     ENCODE_START(1, 1, bl);
@@ -75,14 +81,14 @@ struct cls_log_list_op {
     DECODE_FINISH(bl);
   }
 };
-WRITE_CLASS_ENCODER(cls_log_list_op)
+WRITE_CLASS_ENCODER(list_op)
 
-struct cls_log_list_ret {
-  std::vector<cls_log_entry> entries;
+struct list_ret {
+  std::vector<entry> entries;
   std::string marker;
   bool truncated;
 
-  cls_log_list_ret() : truncated(false) {}
+  list_ret() : truncated(false) {}
 
   void encode(ceph::buffer::list& bl) const {
     ENCODE_START(1, 1, bl);
@@ -100,20 +106,19 @@ struct cls_log_list_ret {
     DECODE_FINISH(bl);
   }
 };
-WRITE_CLASS_ENCODER(cls_log_list_ret)
-
+WRITE_CLASS_ENCODER(list_ret)
 
 /*
  * operation will return 0 when successfully removed but not done. Will return
  * -ENODATA when done, so caller needs to repeat sending request until that.
  */
-struct cls_log_trim_op {
+struct trim_op {
   ceph::real_time from_time;
   ceph::real_time to_time; /* inclusive */
   std::string from_marker;
   std::string to_marker;
 
-  cls_log_trim_op() {}
+  trim_op() = default;
 
   void encode(ceph::buffer::list& bl) const {
     ENCODE_START(2, 1, bl);
@@ -135,10 +140,10 @@ struct cls_log_trim_op {
     DECODE_FINISH(bl);
   }
 };
-WRITE_CLASS_ENCODER(cls_log_trim_op)
+WRITE_CLASS_ENCODER(trim_op)
 
-struct cls_log_info_op {
-  cls_log_info_op() {}
+struct info_op {
+  info_op() = default;
 
   void encode(ceph::buffer::list& bl) const {
     ENCODE_START(1, 1, bl);
@@ -152,23 +157,24 @@ struct cls_log_info_op {
     DECODE_FINISH(bl);
   }
 };
-WRITE_CLASS_ENCODER(cls_log_info_op)
+WRITE_CLASS_ENCODER(info_op)
 
-struct cls_log_info_ret {
-  cls_log_header header;
+struct info_ret {
+  cls::log::header header;
 
   void encode(ceph::buffer::list& bl) const {
     ENCODE_START(1, 1, bl);
-    encode(header, bl);
+    encode(this->header, bl);
     ENCODE_FINISH(bl);
   }
 
   void decode(ceph::buffer::list::const_iterator& bl) {
     DECODE_START(1, bl);
-    decode(header, bl);
+    decode(this->header, bl);
     DECODE_FINISH(bl);
   }
 };
-WRITE_CLASS_ENCODER(cls_log_info_ret)
+WRITE_CLASS_ENCODER(info_ret)
+} // namespace cls::log::ops
 
 #endif
index f137dbbfca6d3abd8301d0379c1ddac3e346bdb4..b228f07e352e71eb0fcbca591c44e45d64e3beef 100644 (file)
 class JSONObj;
 class JSONDecoder;
 
-struct cls_log_entry {
+namespace cls::log {
+struct entry {
   std::string id;
   std::string section;
   std::string name;
   ceph::real_time timestamp;
   ceph::buffer::list data;
 
-  cls_log_entry() = default;
+  entry() = default;
 
-  cls_log_entry(ceph::real_time timestamp, std::string section,
-               std::string name, ceph::buffer::list&& data)
+  entry(ceph::real_time timestamp, std::string section,
+       std::string name, ceph::buffer::list&& data)
     : section(std::move(section)), name(std::move(name)),
       timestamp(timestamp), data(std::move(data)) {}
 
@@ -68,9 +69,9 @@ struct cls_log_entry {
     JSONDecoder::decode_json("id", id, obj);
   }
 
-  static void generate_test_instances(std::list<cls_log_entry *>& l) {
-    l.push_back(new cls_log_entry{});
-    l.push_back(new cls_log_entry);
+  static void generate_test_instances(std::list<cls::log::entry *>& l) {
+    l.push_back(new cls::log::entry{});
+    l.push_back(new cls::log::entry);
     l.back()->id = "test_id";
     l.back()->section = "test_section";
     l.back()->name = "test_name";
@@ -80,9 +81,9 @@ struct cls_log_entry {
     l.back()->data = bl;
   }
 };
-WRITE_CLASS_ENCODER(cls_log_entry)
+WRITE_CLASS_ENCODER(entry)
 
-struct cls_log_header {
+struct header {
   std::string max_marker;
   ceph::real_time max_time;
 
@@ -99,15 +100,10 @@ struct cls_log_header {
     decode(max_time, bl);
     DECODE_FINISH(bl);
   }
-};
-inline bool operator ==(const cls_log_header& lhs, const cls_log_header& rhs) {
-  return (lhs.max_marker == rhs.max_marker &&
-         lhs.max_time == rhs.max_time);
-}
-inline bool operator !=(const cls_log_header& lhs, const cls_log_header& rhs) {
-  return !(lhs == rhs);
-}
-WRITE_CLASS_ENCODER(cls_log_header)
 
+  friend auto operator <=>(const header&, const header&) = default;
+};
+WRITE_CLASS_ENCODER(header)
+} // namespace cls::log
 
 #endif
index 6556d116b8f49b942cd1d3f6e6bb21c53f2e0245..7892747bce0ce0e91234fe74c8aa52411513a9ad 100644 (file)
@@ -983,7 +983,7 @@ int RGWContinuousLeaseCR::operate(const DoutPrefixProvider *dpp)
 }
 
 RGWRadosTimelogAddCR::RGWRadosTimelogAddCR(const DoutPrefixProvider *_dpp, rgw::sal::RadosStore* _store, const string& _oid,
-                      const cls_log_entry& entry) : RGWSimpleCoroutine(_store->ctx()),
+                      const cls::log::entry& entry) : RGWSimpleCoroutine(_store->ctx()),
                                                 dpp(_dpp),
                                                 store(_store),
                                                 oid(_oid), cn(NULL)
index bac210bc23d692e2657fe56958b0cb0ec7c3863c..dcf7dd67fa38ee818d215fca0f93c779f185cd1c 100644 (file)
@@ -1524,7 +1524,7 @@ public:
 class RGWRadosTimelogAddCR : public RGWSimpleCoroutine {
   const DoutPrefixProvider *dpp;
   rgw::sal::RadosStore* store;
-  std::vector<cls_log_entry> entries;
+  std::vector<cls::log::entry> entries;
 
   std::string oid;
 
@@ -1532,7 +1532,7 @@ class RGWRadosTimelogAddCR : public RGWSimpleCoroutine {
 
 public:
   RGWRadosTimelogAddCR(const DoutPrefixProvider *dpp, rgw::sal::RadosStore* _store, const std::string& _oid,
-                       const cls_log_entry& entry);
+                       const cls::log::entry& entry);
 
   int send_request(const DoutPrefixProvider *dpp) override;
   int request_complete() override;
index ea2a3548ad45a612d03b28e995f067d0ed770807..4a15a1e485795f417149dfc35a28017d3c467a47 100644 (file)
@@ -98,7 +98,7 @@ void rgw_data_notify_entry::decode_json(JSONObj *obj) {
 }
 
 class RGWDataChangesOmap final : public RGWDataChangesBE {
-  using centries = std::vector<cls_log_entry>;
+  using centries = std::vector<cls::log::entry>;
   std::vector<std::string> oids;
 
 public:
@@ -121,7 +121,7 @@ public:
       out = centries();
     }
 
-    cls_log_entry e;
+    cls::log::entry e;
     cls_log_add_prepare_entry(e, ut, {}, key, entry);
     std::get<centries>(out).push_back(std::move(e));
   }
@@ -154,7 +154,7 @@ public:
           std::optional<std::string_view> marker,
           std::string* out_marker, bool* truncated,
           optional_yield y) override {
-    std::vector<cls_log_entry> log_entries;
+    std::vector<cls::log::entry> log_entries;
     lr::ObjectReadOperation op;
     cls_log_list(op, {}, {}, std::string(marker.value_or("")),
                 max_entries, log_entries, out_marker, truncated);
@@ -189,7 +189,7 @@ public:
   }
   int get_info(const DoutPrefixProvider *dpp, int index,
               RGWDataChangesLogInfo *info, optional_yield y) override {
-    cls_log_header header;
+    cls::log::header header;
     lr::ObjectReadOperation op;
     cls_log_info(op, &header);
     auto r = rgw_rados_operate(dpp, ioctx, oids[index], &op, nullptr, y);
@@ -235,7 +235,7 @@ public:
   }
   int is_empty(const DoutPrefixProvider *dpp, optional_yield y) override {
     for (auto shard = 0u; shard < oids.size(); ++shard) {
-      std::vector<cls_log_entry> log_entries;
+      std::vector<cls::log::entry> log_entries;
       lr::ObjectReadOperation op;
       std::string out_marker;
       bool truncated;
@@ -539,7 +539,7 @@ int RGWDataChangesLog::renew_entries(const DoutPrefixProvider *dpp)
   if (!zone->log_data)
     return 0;
 
-  /* we can't keep the bucket name as part of the cls_log_entry, and we need
+  /* we can't keep the bucket name as part of the cls::log::entry, and we need
    * it later, so we keep two lists under the map */
   bc::flat_map<int, std::pair<std::vector<BucketGen>,
                              RGWDataChangesBE::entries>> m;
index e2fc16dd305cbc4167bcf929f938b3defaa4ee3e..ba91a02ee1e692ea971aefad2143845fe2ba0a50 100644 (file)
@@ -33,7 +33,6 @@
 #include "common/RefCountedObj.h"
 
 #include "cls/log/cls_log_types.h"
-
 #include "rgw_basic_types.h"
 #include "rgw_log_backing.h"
 #include "rgw_sync_policy.h"
@@ -357,7 +356,7 @@ protected:
     return datalog.get_oid(gen_id, shard_id);
   }
 public:
-  using entries = std::variant<std::vector<cls_log_entry>,
+  using entries = std::variant<std::vector<cls::log::entry>,
                               std::vector<ceph::buffer::list>>;
 
   const uint64_t gen_id;
index 988087ca97a938afb4d2f0a75fa48253d6cde666..5928279dc4312b9301c60b96b4c68e76435b1838 100644 (file)
@@ -65,7 +65,7 @@ int RGWMetadataLog::get_shard_id(const string& hash_key, int *shard_id)
   return 0;
 }
 
-int RGWMetadataLog::store_entries_in_shard(const DoutPrefixProvider *dpp, vector<cls_log_entry>& entries, int shard_id, librados::AioCompletion *completion)
+int RGWMetadataLog::store_entries_in_shard(const DoutPrefixProvider *dpp, vector<cls::log::entry>& entries, int shard_id, librados::AioCompletion *completion)
 {
   string oid;
 
@@ -96,7 +96,7 @@ void RGWMetadataLog::complete_list_entries(void *handle) {
 
 int RGWMetadataLog::list_entries(const DoutPrefixProvider *dpp, void *handle,
                                 int max_entries,
-                                vector<cls_log_entry>& entries,
+                                vector<cls::log::entry>& entries,
                                 string *last_marker,
                                 bool *truncated,
                                 optional_yield y) {
@@ -130,7 +130,7 @@ int RGWMetadataLog::get_info(const DoutPrefixProvider *dpp, int shard_id, RGWMet
   string oid;
   get_shard_oid(shard_id, oid);
 
-  cls_log_header header;
+  cls::log::header header;
 
   int ret = svc.cls->timelog.info(dpp, oid, &header, y);
   if ((ret < 0) && (ret != -ENOENT))
index c83db7c40437bf041eced51fc0de057c75bc6a87..a79c81817d6a080914cabef2b597d3758b53f252 100644 (file)
@@ -260,7 +260,7 @@ public:
 
   std::string get_marker(void *handle);
 
-  void dump_log_entry(cls_log_entry& entry, Formatter *f);
+  void dump_log_entry(cls::log::entry& entry, Formatter *f);
 
   void get_sections(std::list<std::string>& sections);
 
index 61e67f7c3afabf28a0477cb35a4d4a1e0f72028b..c31404e1bcd3d997fa0fb26da73ff6c240600bc5 100644 (file)
@@ -111,7 +111,7 @@ void RGWOp_MDLog_List::send_response() {
     s->formatter->open_array_section("entries");
     for (auto iter = entries.begin();
         iter != entries.end(); ++iter) {
-      cls_log_entry& entry = *iter;
+      auto& entry = *iter;
       static_cast<rgw::sal::RadosStore*>(driver)->ctl()->meta.mgr->dump_log_entry(entry, s->formatter);
       flusher.flush();
     }
index b54cdb425bb573240f77002922dde4db648e7d3c..2d71e23786f7df9ac9927cbf71df017a3498adce 100644 (file)
@@ -88,7 +88,7 @@ public:
 };
 
 class RGWOp_MDLog_List : public RGWRESTOp {
-  std::vector<cls_log_entry> entries;
+  std::vector<cls::log::entry> entries;
   std::string last_marker;
   bool truncated;
 public:
index 182b81655659e08bff83f89489eceef4d7d82f70..a817d8318ba563ed89dc619259a27579a221fbdc 100644 (file)
@@ -39,7 +39,7 @@ string RGWSyncErrorLogger::get_shard_oid(const string& oid_prefix, int shard_id)
 }
 
 RGWCoroutine *RGWSyncErrorLogger::log_error_cr(const DoutPrefixProvider *dpp, const string& source_zone, const string& section, const string& name, uint32_t error_code, const string& message) {
-  cls_log_entry entry;
+  cls::log::entry entry;
 
   rgw_sync_error_info info(source_zone, error_code, message);
   bufferlist bl;
@@ -399,7 +399,7 @@ protected:
   }
 public:
   string marker;
-  vector<cls_log_entry> entries;
+  vector<cls::log::entry> entries;
   bool truncated;
 
   RGWAsyncReadMDLogEntries(const DoutPrefixProvider *dpp, RGWCoroutine *caller, RGWAioCompletionNotifier *cn, rgw::sal::RadosStore* _store,
@@ -416,7 +416,7 @@ class RGWReadMDLogEntriesCR : public RGWSimpleCoroutine {
   string marker;
   string *pmarker;
   int max_entries;
-  vector<cls_log_entry> *entries;
+  vector<cls::log::entry> *entries;
   bool *truncated;
 
   RGWAsyncReadMDLogEntries *req{nullptr};
@@ -424,7 +424,7 @@ class RGWReadMDLogEntriesCR : public RGWSimpleCoroutine {
 public:
   RGWReadMDLogEntriesCR(RGWMetaSyncEnv *_sync_env, RGWMetadataLog* mdlog,
                         int _shard_id, string*_marker, int _max_entries,
-                        vector<cls_log_entry> *_entries, bool *_truncated)
+                        vector<cls::log::entry> *_entries, bool *_truncated)
     : RGWSimpleCoroutine(_sync_env->cct), sync_env(_sync_env), mdlog(mdlog),
       shard_id(_shard_id), pmarker(_marker), max_entries(_max_entries),
       entries(_entries), truncated(_truncated) {}
@@ -1416,7 +1416,7 @@ class RGWMetaSyncShardCR : public RGWCoroutine {
 
   RGWMetaSyncShardMarkerTrack *marker_tracker = nullptr;
 
-  vector<cls_log_entry> log_entries;
+  vector<cls::log::entry> log_entries;
   decltype(log_entries)::iterator log_iter;
   bool truncated = false;
 
@@ -2426,7 +2426,7 @@ int RGWCloneMetaLogCoroutine::state_read_shard_status()
   const bool add_ref = false; // default constructs with refs=1
 
   completion.reset(new RGWMetadataLogInfoCompletion(
-    [this](int ret, const cls_log_header& header) {
+    [this](int ret, const cls::log::header& header) {
       if (ret < 0) {
         if (ret != -ENOENT) {
           ldpp_dout(sync_env->dpp, 1) << "ERROR: failed to read mdlog info with "
@@ -2529,14 +2529,14 @@ int RGWCloneMetaLogCoroutine::state_receive_rest_response()
 
 int RGWCloneMetaLogCoroutine::state_store_mdlog_entries()
 {
-  vector<cls_log_entry> dest_entries;
+  vector<cls::log::entry> dest_entries;
 
   vector<rgw_mdlog_entry>::iterator iter;
   for (iter = data.entries.begin(); iter != data.entries.end(); ++iter) {
     rgw_mdlog_entry& entry = *iter;
     ldpp_dout(sync_env->dpp, 20) << "entry: name=" << entry.name << dendl;
 
-    cls_log_entry dest_entry;
+    cls::log::entry dest_entry;
     dest_entry.id = entry.id;
     dest_entry.section = entry.section;
     dest_entry.name = entry.name;
index e7d482abac81fe0b94620b8e584e90f29211fda3..8dd7e6b832035cda12db0a8def46a83e6b8471b5 100644 (file)
@@ -40,7 +40,7 @@ struct rgw_mdlog_entry {
 
   void decode_json(JSONObj *obj);
 
-  bool convert_from(cls_log_entry& le) {
+  bool convert_from(cls::log::entry& le) {
     id = le.id;
     section = le.section;
     name = le.name;
index 300302f5b46e012d407df159ea93c51002924d2d..470b26dc87a0a0f848830a3c72cfca3080c10aef 100644 (file)
@@ -8850,7 +8850,7 @@ next:
     formatter->open_array_section("entries");
     for (; i < g_ceph_context->_conf->rgw_md_log_max_shards; i++) {
       void *handle;
-      vector<cls_log_entry> entries;
+      vector<cls::log::entry> entries;
 
       meta_log->init_list_entries(i, {}, {}, marker, &handle);
       bool truncated;
@@ -8862,7 +8862,7 @@ next:
         }
 
         for (auto iter = entries.begin(); iter != entries.end(); ++iter) {
-          cls_log_entry& entry = *iter;
+          cls::log::entry& entry = *iter;
           static_cast<rgw::sal::RadosStore*>(driver)->ctl()->meta.mgr->dump_log_entry(entry, formatter.get());
         }
         formatter->flush(cout);
@@ -9464,7 +9464,7 @@ next:
       string oid = RGWSyncErrorLogger::get_shard_oid(RGW_SYNC_ERROR_LOG_SHARD_PREFIX, shard_id);
 
       do {
-        vector<cls_log_entry> entries;
+        vector<cls::log::entry> entries;
         ret = static_cast<rgw::sal::RadosStore*>(driver)->svc()->cls->timelog.list(dpp(), oid, {}, {}, max_entries - count, entries, marker, &marker, &truncated,
                                              null_yield);
        if (ret == -ENOENT) {
@@ -10031,7 +10031,7 @@ next:
 
     formatter->open_array_section("entries");
     for (; i < g_ceph_context->_conf->rgw_data_log_num_shards; i++) {
-      vector<cls_log_entry> entries;
+      vector<cls::log::entry> entries;
 
       RGWDataChangesLogInfo info;
       static_cast<rgw::sal::RadosStore*>(driver)->svc()->
index 589a340837e08d24b827647111e2f0d6e68a0491..ea9484cd5fbc3154353ed1158e9d7dfcb0e25ec6 100644 (file)
@@ -37,9 +37,9 @@ class RGWCompletionManager;
 
 class RGWMetadataLogInfoCompletion : public RefCountedObject {
  public:
-  using info_callback_t = std::function<void(int, const cls_log_header&)>;
+  using info_callback_t = std::function<void(int, const cls::log::header&)>;
  private:
-  cls_log_header header;
+  cls::log::header header;
   RGWSI_RADOS::Obj io_obj;
   librados::AioCompletion *completion;
   std::mutex mutex; //< protects callback between cancel/complete
@@ -49,7 +49,7 @@ class RGWMetadataLogInfoCompletion : public RefCountedObject {
   ~RGWMetadataLogInfoCompletion() override;
 
   RGWSI_RADOS::Obj& get_io_obj() { return io_obj; }
-  cls_log_header& get_header() { return header; }
+  cls::log::header& get_header() { return header; }
   librados::AioCompletion* get_completion() { return completion; }
 
   void finish(librados::completion_t cb) {
@@ -104,7 +104,7 @@ public:
 
   int add_entry(const DoutPrefixProvider *dpp, const std::string& hash_key, const std::string& section, const std::string& key, bufferlist& bl, optional_yield y);
   int get_shard_id(const std::string& hash_key, int *shard_id);
-  int store_entries_in_shard(const DoutPrefixProvider *dpp, std::vector<cls_log_entry>& entries, int shard_id, librados::AioCompletion *completion);
+  int store_entries_in_shard(const DoutPrefixProvider *dpp, std::vector<cls::log::entry>& entries, int shard_id, librados::AioCompletion *completion);
 
   struct LogListCtx {
     int cur_shard;
@@ -126,7 +126,7 @@ public:
   int list_entries(const DoutPrefixProvider *dpp,
                    void *handle,
                    int max_entries,
-                   std::vector<cls_log_entry>& entries,
+                   std::vector<cls::log::entry>& entries,
                   std::string *out_marker,
                   bool *truncated,
                   optional_yield y);
index d1f1a32d4fd69599f9b7bd3d1044d93dca21066e..6b65d708e115589ba616668e0c685c3c958a90f4 100644 (file)
@@ -664,7 +664,7 @@ string RGWMetadataManager::get_marker(void *handle)
   return h->handler->get_marker(h->handle);
 }
 
-void RGWMetadataManager::dump_log_entry(cls_log_entry& entry, Formatter *f)
+void RGWMetadataManager::dump_log_entry(cls::log::entry& entry, Formatter *f)
 {
   f->open_object_section("entry");
   f->dump_string("id", entry.id);
index c076f72cab475bf8a2b6b3378c9a527bb7114269..6b30b4a03631037922ddf4fdfd5484d0457d0243 100644 (file)
@@ -256,7 +256,7 @@ int RGWSI_Cls::MFA::list_mfa(const DoutPrefixProvider *dpp, const string& oid, l
   return 0;
 }
 
-void RGWSI_Cls::TimeLog::prepare_entry(cls_log_entry& entry,
+void RGWSI_Cls::TimeLog::prepare_entry(cls::log::entry& entry,
                                        const real_time& ut,
                                        const string& section,
                                        const string& key,
@@ -295,7 +295,7 @@ int RGWSI_Cls::TimeLog::add(const DoutPrefixProvider *dpp,
 
 int RGWSI_Cls::TimeLog::add(const DoutPrefixProvider *dpp,
                             const string& oid,
-                            std::vector<cls_log_entry>& entries,
+                            std::vector<cls::log::entry>& entries,
                             librados::AioCompletion *completion,
                             bool monotonic_inc,
                             optional_yield y)
@@ -322,7 +322,7 @@ int RGWSI_Cls::TimeLog::list(const DoutPrefixProvider *dpp,
                              const string& oid,
                              const real_time& start_time,
                              const real_time& end_time,
-                             int max_entries, std::vector<cls_log_entry>& entries,
+                             int max_entries, std::vector<cls::log::entry>& entries,
                              const string& marker,
                              string *out_marker,
                              bool *truncated,
@@ -351,7 +351,7 @@ int RGWSI_Cls::TimeLog::list(const DoutPrefixProvider *dpp,
 
 int RGWSI_Cls::TimeLog::info(const DoutPrefixProvider *dpp, 
                              const string& oid,
-                             cls_log_header *header,
+                             cls::log::header *header,
                              optional_yield y)
 {
   RGWSI_RADOS::Obj obj;
@@ -377,7 +377,7 @@ int RGWSI_Cls::TimeLog::info(const DoutPrefixProvider *dpp,
 int RGWSI_Cls::TimeLog::info_async(const DoutPrefixProvider *dpp,
                                    RGWSI_RADOS::Obj& obj,
                                    const string& oid,
-                                   cls_log_header *header,
+                                   cls::log::header *header,
                                    librados::AioCompletion *completion)
 {
   int r = init_obj(dpp, oid, obj);
index eab1711d1d94db47d30b4b4e0f1f151b67c6f1ce..a148fcf64a14a4c8fc2e01b31079ce3d3dfd7b7d 100644 (file)
@@ -85,7 +85,7 @@ public:
   public:
     TimeLog(CephContext *cct): ClsSubService(cct) {}
 
-    void prepare_entry(cls_log_entry& entry,
+    void prepare_entry(cls::log::entry& entry,
                        const real_time& ut,
                        const std::string& section,
                        const std::string& key,
@@ -99,7 +99,7 @@ public:
             optional_yield y);
     int add(const DoutPrefixProvider *dpp, 
             const std::string& oid,
-            std::vector<cls_log_entry>& entries,
+            std::vector<cls::log::entry>& entries,
             librados::AioCompletion *completion,
             bool monotonic_inc,
             optional_yield y);
@@ -107,19 +107,19 @@ public:
              const std::string& oid,
              const real_time& start_time,
              const real_time& end_time,
-             int max_entries, std::vector<cls_log_entry>& entries,
+             int max_entries, std::vector<cls::log::entry>& entries,
              const std::string& marker,
              std::string *out_marker,
              bool *truncated,
              optional_yield y);
     int info(const DoutPrefixProvider *dpp, 
              const std::string& oid,
-             cls_log_header *header,
+             cls::log::header *header,
              optional_yield y);
     int info_async(const DoutPrefixProvider *dpp,
                    RGWSI_RADOS::Obj& obj,
                    const std::string& oid,
-                   cls_log_header *header,
+                   cls::log::header *header,
                    librados::AioCompletion *completion);
     int trim(const DoutPrefixProvider *dpp, 
              const std::string& oid,
index a52604659f85c7cf826225589b721d6214d174db..353704cfaf5e98d90ab0f70c8d46f569291d614c 100644 (file)
@@ -99,7 +99,7 @@ real_time get_time(real_time start_time, int i, bool modify_time)
   return modify_time ? start_time + (i * 1s) : start_time;
 }
 
-void check_entry(cls_log_entry& entry, real_time start_time, int i, bool modified_time)
+void check_entry(cls::log::entry& entry, real_time start_time, int i, bool modified_time)
 {
   string section = "global";
   string name = get_name(i);
@@ -113,7 +113,7 @@ void check_entry(cls_log_entry& entry, real_time start_time, int i, bool modifie
 static int log_list(librados::IoCtx& ioctx, const std::string& oid,
                     real_time from, real_time to,
                     const string& in_marker, int max_entries,
-                    vector<cls_log_entry>& entries,
+                    vector<cls::log::entry>& entries,
                     string *out_marker, bool *truncated)
 {
   librados::ObjectReadOperation rop;
@@ -125,7 +125,7 @@ static int log_list(librados::IoCtx& ioctx, const std::string& oid,
 
 static int log_list(librados::IoCtx& ioctx, const std::string& oid,
                     real_time from, real_time to, int max_entries,
-                    vector<cls_log_entry>& entries, bool *truncated)
+                    vector<cls::log::entry>& entries, bool *truncated)
 {
   std::string marker;
   return log_list(ioctx, oid, from, to, marker, max_entries,
@@ -133,7 +133,7 @@ static int log_list(librados::IoCtx& ioctx, const std::string& oid,
 }
 
 static int log_list(librados::IoCtx& ioctx, const std::string& oid,
-                    vector<cls_log_entry>& entries)
+                    vector<cls::log::entry>& entries)
 {
   real_time from, to;
   bool truncated{false};
@@ -153,7 +153,7 @@ TEST_F(cls_log, test_log_add_same_time)
   auto to_time = get_time(start_time, 1, true);
   generate_log(ioctx, oid, 10, start_time, false);
 
-  vector<cls_log_entry> entries;
+  vector<cls::log::entry> entries;
   bool truncated;
 
   /* check list */
@@ -163,13 +163,13 @@ TEST_F(cls_log, test_log_add_same_time)
     ASSERT_EQ(10, (int)entries.size());
     ASSERT_EQ(0, (int)truncated);
   }
-  vector<cls_log_entry>::iterator iter;
+  vector<cls::log::entry>::iterator iter;
 
   /* need to sort returned entries, all were using the same time as key */
-  map<int, cls_log_entry> check_ents;
+  map<int, cls::log::entry> check_ents;
 
   for (iter = entries.begin(); iter != entries.end(); ++iter) {
-    cls_log_entry& entry = *iter;
+    cls::log::entry& entry = *iter;
 
     int num;
     ASSERT_EQ(0, read_bl(entry.data, &num));
@@ -179,14 +179,14 @@ TEST_F(cls_log, test_log_add_same_time)
 
   ASSERT_EQ(10, (int)check_ents.size());
 
-  map<int, cls_log_entry>::iterator ei;
+  map<int, cls::log::entry>::iterator ei;
 
   /* verify entries are as expected */
 
   int i;
 
   for (i = 0, ei = check_ents.begin(); i < 10; i++, ++ei) {
-    cls_log_entry& entry = ei->second;
+    cls::log::entry& entry = ei->second;
 
     ASSERT_EQ(i, ei->first);
     check_entry(entry, start_time, i, false);
@@ -213,7 +213,7 @@ TEST_F(cls_log, test_log_add_different_time)
   auto start_time = real_clock::now();
   generate_log(ioctx, oid, 10, start_time, true);
 
-  vector<cls_log_entry> entries;
+  vector<cls::log::entry> entries;
   bool truncated;
 
   auto to_time = start_time + (10 * 1s);
@@ -226,15 +226,15 @@ TEST_F(cls_log, test_log_add_different_time)
     ASSERT_EQ(0, (int)truncated);
   }
 
-  vector<cls_log_entry>::iterator iter;
+  vector<cls::log::entry>::iterator iter;
 
   /* returned entries should be sorted by time */
-  map<int, cls_log_entry> check_ents;
+  map<int, cls::log::entry> check_ents;
 
   int i;
 
   for (i = 0, iter = entries.begin(); iter != entries.end(); ++iter, ++i) {
-    cls_log_entry& entry = *iter;
+    cls::log::entry& entry = *iter;
 
     int num;
 
@@ -298,7 +298,7 @@ TEST_F(cls_log, trim_by_time)
   auto start_time = real_clock::now();
   generate_log(ioctx, oid, 10, start_time, true);
 
-  vector<cls_log_entry> entries;
+  vector<cls::log::entry> entries;
   bool truncated;
 
   /* check list */
@@ -329,9 +329,9 @@ TEST_F(cls_log, trim_by_marker)
   auto start_time = real_clock::now();
   generate_log(ioctx, oid, 10, start_time, true);
 
-  std::vector<cls_log_entry> log1;
+  std::vector<cls::log::entry> log1;
   {
-    vector<cls_log_entry> entries;
+    vector<cls::log::entry> entries;
     ASSERT_EQ(0, log_list(ioctx, oid, entries));
     ASSERT_EQ(10u, entries.size());
 
@@ -343,7 +343,7 @@ TEST_F(cls_log, trim_by_marker)
     const std::string from = "";
     const std::string to = log1[0].id;
     ASSERT_EQ(0, do_log_trim(ioctx, oid, from, to));
-    vector<cls_log_entry> entries;
+    vector<cls::log::entry> entries;
     ASSERT_EQ(0, log_list(ioctx, oid, entries));
     ASSERT_EQ(9u, entries.size());
     EXPECT_EQ(log1[1].id, entries.begin()->id);
@@ -354,7 +354,7 @@ TEST_F(cls_log, trim_by_marker)
     const std::string from = log1[8].id;
     const std::string to = "9";
     ASSERT_EQ(0, do_log_trim(ioctx, oid, from, to));
-    vector<cls_log_entry> entries;
+    vector<cls::log::entry> entries;
     ASSERT_EQ(0, log_list(ioctx, oid, entries));
     ASSERT_EQ(8u, entries.size());
     EXPECT_EQ(log1[8].id, entries.rbegin()->id);
@@ -365,7 +365,7 @@ TEST_F(cls_log, trim_by_marker)
     const std::string from = log1[3].id;
     const std::string to = log1[4].id;
     ASSERT_EQ(0, do_log_trim(ioctx, oid, from, to));
-    vector<cls_log_entry> entries;
+    vector<cls::log::entry> entries;
     ASSERT_EQ(0, log_list(ioctx, oid, entries));
     ASSERT_EQ(7u, entries.size());
     ASSERT_EQ(-ENODATA, do_log_trim(ioctx, oid, from, to));
@@ -375,7 +375,7 @@ TEST_F(cls_log, trim_by_marker)
     const std::string from = "";
     const std::string to = "9";
     ASSERT_EQ(0, do_log_trim(ioctx, oid, from, to));
-    vector<cls_log_entry> entries;
+    vector<cls::log::entry> entries;
     ASSERT_EQ(0, log_list(ioctx, oid, entries));
     ASSERT_EQ(0u, entries.size());
     ASSERT_EQ(-ENODATA, do_log_trim(ioctx, oid, from, to));
index e03ee0c5f12dcf13ba28388f12fb03aae1f152c4..2dbddcd01d4c19064e69ad7868da20f99bb2306d 100644 (file)
@@ -94,7 +94,7 @@ protected:
       std::string to_marker;
       {
        lr::ObjectReadOperation op;
-       std::vector<cls_log_entry> entries;
+       std::vector<cls::log::entry> entries;
        bool truncated = false;
        cls_log_list(op, {}, {}, {}, 1, entries, &to_marker, &truncated);
        auto r = rgw_rados_operate(&dp, ioctx, oid, &op, nullptr, null_yield);
@@ -109,7 +109,7 @@ protected:
       }
       {
        lr::ObjectReadOperation op;
-       std::vector<cls_log_entry> entries;
+       std::vector<cls::log::entry> entries;
        bool truncated = false;
        cls_log_list(op, {}, {}, {}, 1, entries, &to_marker, &truncated);
        auto r = rgw_rados_operate(&dp, ioctx, oid, &op, nullptr, null_yield);
index 45d6921c5be286bae3bedfd8e94c07604ee224ce..b8097643950c072d7d5b72098ecbf99c7a7f37c7 100644 (file)
@@ -33,10 +33,10 @@ TYPE(RGWCacheNotifyInfo)
 TYPE(RGWLifecycleConfiguration)
 
 #include "cls/log/cls_log_types.h"
-TYPE(cls_log_entry)
+TYPE(cls::log::entry)
 
 #include "cls/log/cls_log_ops.h"
-TYPE(cls_log_add_op)
+TYPE(cls::log::ops::add_op)
 
 #include "cls/rgw/cls_rgw_types.h"
 TYPE(rgw_bucket_pending_info)