From 59d60d01a6529f76eea75c052beb9a304da1b82f Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Tue, 24 Jan 2023 16:35:23 -0500 Subject: [PATCH] cls/log: C++ namespaces exist Signed-off-by: Adam C. Emerson --- src/cls/log/cls_log.cc | 32 ++++----- src/cls/log/cls_log_client.cc | 36 +++++----- src/cls/log/cls_log_client.h | 10 +-- src/cls/log/cls_log_ops.h | 94 ++++++++++++++------------ src/cls/log/cls_log_types.h | 38 +++++------ src/rgw/driver/rados/rgw_cr_rados.cc | 2 +- src/rgw/driver/rados/rgw_cr_rados.h | 4 +- src/rgw/driver/rados/rgw_datalog.cc | 12 ++-- src/rgw/driver/rados/rgw_datalog.h | 3 +- src/rgw/driver/rados/rgw_metadata.cc | 6 +- src/rgw/driver/rados/rgw_metadata.h | 2 +- src/rgw/driver/rados/rgw_rest_log.cc | 2 +- src/rgw/driver/rados/rgw_rest_log.h | 2 +- src/rgw/driver/rados/rgw_sync.cc | 16 ++--- src/rgw/driver/rados/rgw_sync.h | 2 +- src/rgw/radosgw-admin/radosgw-admin.cc | 8 +-- src/rgw/rgw_mdlog.h | 10 +-- src/rgw/rgw_metadata.cc | 2 +- src/rgw/services/svc_cls.cc | 10 +-- src/rgw/services/svc_cls.h | 10 +-- src/test/cls_log/test_cls_log.cc | 42 ++++++------ src/test/rgw/test_log_backing.cc | 4 +- src/tools/ceph-dencoder/common_types.h | 10 +-- src/tools/ceph-dencoder/rgw_types.h | 4 +- 24 files changed, 181 insertions(+), 180 deletions(-) diff --git a/src/cls/log/cls_log.cc b/src/cls/log/cls_log.cc index 65b070756e7..c1126b5659d 100644 --- a/src/cls/log/cls_log.cc +++ b/src/cls/log/cls_log.cc @@ -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) diff --git a/src/cls/log/cls_log_client.cc b/src/cls/log/cls_log_client.cc index 531cb765f72..5af994d4ffa 100644 --- a/src/cls/log/cls_log_client.cc +++ b/src/cls/log/cls_log_client.cc @@ -16,25 +16,25 @@ using namespace librados; -void cls_log_add(librados::ObjectWriteOperation& op, vector& entries, bool monotonic_inc) +void cls_log_add(librados::ObjectWriteOperation& op, vector& 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 *entries; + vector* entries; string *marker; bool *truncated; public: - LogListCtx(vector *_entries, string *_marker, bool *_truncated) : - entries(_entries), marker(_marker), truncated(_truncated) {} + LogListCtx(vector *_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& entries, + vector& 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); diff --git a/src/cls/log/cls_log_client.h b/src/cls/log/cls_log_client.h index 12cd88c2601..0b6eac6e9cb 100644 --- a/src/cls/log/cls_log_client.h +++ b/src/cls/log/cls_log_client.h @@ -11,18 +11,18 @@ * 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& entries, bool monotonic_inc); -void cls_log_add(librados::ObjectWriteOperation& op, cls_log_entry& entry); +void cls_log_add(librados::ObjectWriteOperation& op, std::vector& 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& entries, + int max_entries, std::vector& 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 diff --git a/src/cls/log/cls_log_ops.h b/src/cls/log/cls_log_ops.h index a1477ccc603..6c1e5bb224b 100644 --- a/src/cls/log/cls_log_ops.h +++ b/src/cls/log/cls_log_ops.h @@ -4,14 +4,20 @@ #ifndef CEPH_CLS_LOG_OPS_H #define CEPH_CLS_LOG_OPS_H +#include +#include + #include "common/ceph_json.h" +#include "common/ceph_time.h" + #include "cls_log_types.h" -struct cls_log_add_op { - std::vector entries; - bool monotonic_inc; +namespace cls::log::ops { +struct add_op { + std::vector 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); @@ -34,12 +40,12 @@ struct cls_log_add_op { encode_json("monotonic_inc", monotonic_inc, f); } - static void generate_test_instances(std::list& l) { + static void generate_test_instances(std::list& 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}; @@ -47,16 +53,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); @@ -82,24 +88,24 @@ struct cls_log_list_op { f->dump_stream("to_time") << to_time; f->dump_int("max_entries", max_entries); } - static void generate_test_instances(std::list& ls) { + static void generate_test_instances(std::list& ls) { using namespace std::literals; - ls.push_back(new cls_log_list_op); - ls.push_back(new cls_log_list_op); + ls.push_back(new list_op); + ls.push_back(new list_op); ls.back()->from_time = ceph::real_time{1s + 2ns}; ls.back()->marker = "marker"; ls.back()->to_time = ceph::real_time{3s + 4ns}; ls.back()->max_entries = 5; } }; -WRITE_CLASS_ENCODER(cls_log_list_op) +WRITE_CLASS_ENCODER(list_op) -struct cls_log_list_ret { - std::vector entries; +struct list_ret { + std::vector 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); @@ -122,12 +128,12 @@ struct cls_log_list_ret { f->dump_string("marker", marker); f->dump_bool("truncated", truncated); } - static void generate_test_instances(std::list& ls) { + static void generate_test_instances(std::list& ls) { using namespace std::literals; - ls.push_back(new cls_log_list_ret); - ls.push_back(new cls_log_list_ret); - ls.back()->entries.push_back(cls_log_entry()); - ls.back()->entries.push_back(cls_log_entry()); + ls.push_back(new list_ret); + ls.push_back(new list_ret); + ls.back()->entries.push_back(entry{}); + ls.back()->entries.push_back(entry{}); ls.back()->entries.back().section = "section"; ls.back()->entries.back().name = "name"; ls.back()->entries.back().timestamp = ceph::real_time{1s + 2ns}; @@ -137,20 +143,19 @@ struct cls_log_list_ret { ls.back()->truncated = true; } }; -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); @@ -177,20 +182,20 @@ struct cls_log_trim_op { f->dump_string("from_marker", from_marker); f->dump_string("to_marker", to_marker); } - static void generate_test_instances(std::list& ls) { + static void generate_test_instances(std::list& ls) { using namespace std::literals; - ls.push_back(new cls_log_trim_op); - ls.push_back(new cls_log_trim_op); + ls.push_back(new trim_op); + ls.push_back(new trim_op); ls.back()->from_time = ceph::real_time{1s + 2ns}; ls.back()->to_time = ceph::real_time(3s + 4ns); ls.back()->from_marker = "from_marker"; ls.back()->to_marker = "to_marker"; } }; -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); @@ -207,27 +212,28 @@ struct cls_log_info_op { void dump(ceph::Formatter* f) const { } - static void generate_test_instances(std::list& ls) { - ls.push_back(new cls_log_info_op); + static void generate_test_instances(std::list& ls) { + ls.push_back(new info_op); } }; -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 diff --git a/src/cls/log/cls_log_types.h b/src/cls/log/cls_log_types.h index c96b56503f7..2e31313c4a1 100644 --- a/src/cls/log/cls_log_types.h +++ b/src/cls/log/cls_log_types.h @@ -17,17 +17,18 @@ 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& l) { - l.push_back(new cls_log_entry{}); - l.push_back(new cls_log_entry); + static void generate_test_instances(std::list& 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,25 +100,20 @@ struct cls_log_header { decode(max_time, bl); DECODE_FINISH(bl); } + void dump(ceph::Formatter* f) const { f->dump_string("max_marker", max_marker); f->dump_stream("max_time") << max_time; } - static void generate_test_instances(std::list& o) { - o.push_back(new cls_log_header); - o.push_back(new cls_log_header); + static void generate_test_instances(std::list& o) { + o.push_back(new header); + o.push_back(new header); o.back()->max_marker = "test_marker"; o.back()->max_time = ceph::real_clock::zero(); } + friend auto operator <=>(const header&, const header&) = default; }; -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) - +WRITE_CLASS_ENCODER(header) +} // namespace cls::log #endif diff --git a/src/rgw/driver/rados/rgw_cr_rados.cc b/src/rgw/driver/rados/rgw_cr_rados.cc index ddc8f152d8e..f77965b1c8c 100644 --- a/src/rgw/driver/rados/rgw_cr_rados.cc +++ b/src/rgw/driver/rados/rgw_cr_rados.cc @@ -1002,7 +1002,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) diff --git a/src/rgw/driver/rados/rgw_cr_rados.h b/src/rgw/driver/rados/rgw_cr_rados.h index ce84fce4017..6f243f08cd1 100644 --- a/src/rgw/driver/rados/rgw_cr_rados.h +++ b/src/rgw/driver/rados/rgw_cr_rados.h @@ -1519,7 +1519,7 @@ public: class RGWRadosTimelogAddCR : public RGWSimpleCoroutine { const DoutPrefixProvider *dpp; rgw::sal::RadosStore* store; - std::vector entries; + std::vector entries; std::string oid; @@ -1527,7 +1527,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; diff --git a/src/rgw/driver/rados/rgw_datalog.cc b/src/rgw/driver/rados/rgw_datalog.cc index 7988fc122d9..d223932bb2c 100644 --- a/src/rgw/driver/rados/rgw_datalog.cc +++ b/src/rgw/driver/rados/rgw_datalog.cc @@ -99,7 +99,7 @@ void rgw_data_notify_entry::decode_json(JSONObj *obj) { } class RGWDataChangesOmap final : public RGWDataChangesBE { - using centries = std::vector; + using centries = std::vector; std::vector oids; public: @@ -122,7 +122,7 @@ public: out = centries(); } - cls_log_entry e; + cls::log::entry e; cls_log_add_prepare_entry(e, ut, {}, key, entry); std::get(out).push_back(std::move(e)); } @@ -155,7 +155,7 @@ public: std::optional marker, std::string* out_marker, bool* truncated, optional_yield y) override { - std::vector log_entries; + std::vector log_entries; lr::ObjectReadOperation op; cls_log_list(op, {}, {}, std::string(marker.value_or("")), max_entries, log_entries, out_marker, truncated); @@ -190,7 +190,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], std::move(op), nullptr, y); @@ -236,7 +236,7 @@ public: } int is_empty(const DoutPrefixProvider *dpp, optional_yield y) override { for (auto shard = 0u; shard < oids.size(); ++shard) { - std::vector log_entries; + std::vector log_entries; lr::ObjectReadOperation op; std::string out_marker; bool truncated; @@ -540,7 +540,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, RGWDataChangesBE::entries>> m; diff --git a/src/rgw/driver/rados/rgw_datalog.h b/src/rgw/driver/rados/rgw_datalog.h index 74073a4e7f8..7efa3e57223 100644 --- a/src/rgw/driver/rados/rgw_datalog.h +++ b/src/rgw/driver/rados/rgw_datalog.h @@ -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" @@ -354,7 +353,7 @@ protected: return datalog.get_oid(gen_id, shard_id); } public: - using entries = std::variant, + using entries = std::variant, std::vector>; const uint64_t gen_id; diff --git a/src/rgw/driver/rados/rgw_metadata.cc b/src/rgw/driver/rados/rgw_metadata.cc index 988087ca97a..5928279dc43 100644 --- a/src/rgw/driver/rados/rgw_metadata.cc +++ b/src/rgw/driver/rados/rgw_metadata.cc @@ -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& entries, int shard_id, librados::AioCompletion *completion) +int RGWMetadataLog::store_entries_in_shard(const DoutPrefixProvider *dpp, vector& 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& entries, + vector& 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)) diff --git a/src/rgw/driver/rados/rgw_metadata.h b/src/rgw/driver/rados/rgw_metadata.h index 30425542a1b..154f50a4fe2 100644 --- a/src/rgw/driver/rados/rgw_metadata.h +++ b/src/rgw/driver/rados/rgw_metadata.h @@ -132,7 +132,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& sections); diff --git a/src/rgw/driver/rados/rgw_rest_log.cc b/src/rgw/driver/rados/rgw_rest_log.cc index d8e6511dd23..19e7ea6a72d 100644 --- a/src/rgw/driver/rados/rgw_rest_log.cc +++ b/src/rgw/driver/rados/rgw_rest_log.cc @@ -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(driver)->ctl()->meta.mgr->dump_log_entry(entry, s->formatter); flusher.flush(); } diff --git a/src/rgw/driver/rados/rgw_rest_log.h b/src/rgw/driver/rados/rgw_rest_log.h index 0fbeb00e3e0..7fbadce918d 100644 --- a/src/rgw/driver/rados/rgw_rest_log.h +++ b/src/rgw/driver/rados/rgw_rest_log.h @@ -88,7 +88,7 @@ public: }; class RGWOp_MDLog_List : public RGWRESTOp { - std::vector entries; + std::vector entries; std::string last_marker; bool truncated; public: diff --git a/src/rgw/driver/rados/rgw_sync.cc b/src/rgw/driver/rados/rgw_sync.cc index a2e5446b1ab..03643abf305 100644 --- a/src/rgw/driver/rados/rgw_sync.cc +++ b/src/rgw/driver/rados/rgw_sync.cc @@ -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 entries; + vector 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 *entries; + vector *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 *_entries, bool *_truncated) + vector *_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) {} @@ -1450,7 +1450,7 @@ class RGWMetaSyncShardCR : public RGWCoroutine { RGWMetaSyncShardMarkerTrack *marker_tracker = nullptr; - vector log_entries; + vector log_entries; decltype(log_entries)::iterator log_iter; bool truncated = false; @@ -2476,7 +2476,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 " @@ -2583,14 +2583,14 @@ int RGWCloneMetaLogCoroutine::state_receive_rest_response() int RGWCloneMetaLogCoroutine::state_store_mdlog_entries() { - vector dest_entries; + vector dest_entries; vector::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; diff --git a/src/rgw/driver/rados/rgw_sync.h b/src/rgw/driver/rados/rgw_sync.h index e7d482abac8..8dd7e6b8320 100644 --- a/src/rgw/driver/rados/rgw_sync.h +++ b/src/rgw/driver/rados/rgw_sync.h @@ -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; diff --git a/src/rgw/radosgw-admin/radosgw-admin.cc b/src/rgw/radosgw-admin/radosgw-admin.cc index 9df14dfe72a..2dcd2650f76 100644 --- a/src/rgw/radosgw-admin/radosgw-admin.cc +++ b/src/rgw/radosgw-admin/radosgw-admin.cc @@ -9704,7 +9704,7 @@ next: formatter->open_array_section("entries"); for (; i < g_ceph_context->_conf->rgw_md_log_max_shards; i++) { void *handle; - vector entries; + vector entries; meta_log->init_list_entries(i, {}, {}, marker, &handle); bool truncated; @@ -9716,7 +9716,7 @@ next: } for (auto iter = entries.begin(); iter != entries.end(); ++iter) { - cls_log_entry& entry = *iter; + cls::log::entry& entry = *iter; static_cast(driver)->ctl()->meta.mgr->dump_log_entry(entry, formatter.get()); } formatter->flush(cout); @@ -10329,7 +10329,7 @@ next: string oid = RGWSyncErrorLogger::get_shard_oid(RGW_SYNC_ERROR_LOG_SHARD_PREFIX, shard_id); do { - vector entries; + vector entries; ret = static_cast(driver)->svc()->cls->timelog.list(dpp(), oid, {}, {}, max_entries - count, entries, marker, &marker, &truncated, null_yield); if (ret == -ENOENT) { @@ -10898,7 +10898,7 @@ next: formatter->open_array_section("entries"); for (; i < g_ceph_context->_conf->rgw_data_log_num_shards; i++) { - vector entries; + vector entries; RGWDataChangesLogInfo info; static_cast(driver)->svc()-> diff --git a/src/rgw/rgw_mdlog.h b/src/rgw/rgw_mdlog.h index 496fc5ff164..7922988c811 100644 --- a/src/rgw/rgw_mdlog.h +++ b/src/rgw/rgw_mdlog.h @@ -41,9 +41,9 @@ class RGWCompletionManager; class RGWMetadataLogInfoCompletion : public RefCountedObject { public: - using info_callback_t = std::function; + using info_callback_t = std::function; private: - cls_log_header header; + cls::log::header header; rgw_rados_ref io_obj; librados::AioCompletion *completion; std::mutex mutex; //< protects callback between cancel/complete @@ -53,7 +53,7 @@ class RGWMetadataLogInfoCompletion : public RefCountedObject { ~RGWMetadataLogInfoCompletion() override; rgw_rados_ref& 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) { @@ -108,7 +108,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& entries, int shard_id, librados::AioCompletion *completion); + int store_entries_in_shard(const DoutPrefixProvider *dpp, std::vector& entries, int shard_id, librados::AioCompletion *completion); struct LogListCtx { int cur_shard; @@ -130,7 +130,7 @@ public: int list_entries(const DoutPrefixProvider *dpp, void *handle, int max_entries, - std::vector& entries, + std::vector& entries, std::string *out_marker, bool *truncated, optional_yield y); diff --git a/src/rgw/rgw_metadata.cc b/src/rgw/rgw_metadata.cc index fe1bc71d820..d84ff16f711 100644 --- a/src/rgw/rgw_metadata.cc +++ b/src/rgw/rgw_metadata.cc @@ -459,7 +459,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); diff --git a/src/rgw/services/svc_cls.cc b/src/rgw/services/svc_cls.cc index 76ff34bc831..ed0a14e7620 100644 --- a/src/rgw/services/svc_cls.cc +++ b/src/rgw/services/svc_cls.cc @@ -244,7 +244,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, @@ -281,7 +281,7 @@ int RGWSI_Cls::TimeLog::add(const DoutPrefixProvider *dpp, int RGWSI_Cls::TimeLog::add(const DoutPrefixProvider *dpp, const string& oid, - std::vector& entries, + std::vector& entries, librados::AioCompletion *completion, bool monotonic_inc, optional_yield y) @@ -308,7 +308,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& entries, + int max_entries, std::vector& entries, const string& marker, string *out_marker, bool *truncated, @@ -337,7 +337,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) { rgw_rados_ref obj; @@ -363,7 +363,7 @@ int RGWSI_Cls::TimeLog::info(const DoutPrefixProvider *dpp, int RGWSI_Cls::TimeLog::info_async(const DoutPrefixProvider *dpp, rgw_rados_ref& obj, const string& oid, - cls_log_header *header, + cls::log::header *header, librados::AioCompletion *completion) { int r = init_obj(dpp, oid, obj); diff --git a/src/rgw/services/svc_cls.h b/src/rgw/services/svc_cls.h index d3da4a1e9c9..08aaec2db2e 100644 --- a/src/rgw/services/svc_cls.h +++ b/src/rgw/services/svc_cls.h @@ -80,7 +80,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, @@ -94,7 +94,7 @@ public: optional_yield y); int add(const DoutPrefixProvider *dpp, const std::string& oid, - std::vector& entries, + std::vector& entries, librados::AioCompletion *completion, bool monotonic_inc, optional_yield y); @@ -102,19 +102,19 @@ public: const std::string& oid, const real_time& start_time, const real_time& end_time, - int max_entries, std::vector& entries, + int max_entries, std::vector& 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, rgw_rados_ref& 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, diff --git a/src/test/cls_log/test_cls_log.cc b/src/test/cls_log/test_cls_log.cc index e725bc87c2a..51c33a3a38c 100644 --- a/src/test/cls_log/test_cls_log.cc +++ b/src/test/cls_log/test_cls_log.cc @@ -101,7 +101,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); @@ -115,7 +115,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& entries, + vector& entries, string *out_marker, bool *truncated) { librados::ObjectReadOperation rop; @@ -127,7 +127,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& entries, bool *truncated) + vector& entries, bool *truncated) { std::string marker; return log_list(ioctx, oid, from, to, marker, max_entries, @@ -135,7 +135,7 @@ static int log_list(librados::IoCtx& ioctx, const std::string& oid, } static int log_list(librados::IoCtx& ioctx, const std::string& oid, - vector& entries) + vector& entries) { real_time from, to; bool truncated{false}; @@ -155,7 +155,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 entries; + vector entries; bool truncated; /* check list */ @@ -165,13 +165,13 @@ TEST_F(cls_log, test_log_add_same_time) ASSERT_EQ(10, (int)entries.size()); ASSERT_EQ(0, (int)truncated); } - vector::iterator iter; + vector::iterator iter; /* need to sort returned entries, all were using the same time as key */ - map check_ents; + map 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)); @@ -181,14 +181,14 @@ TEST_F(cls_log, test_log_add_same_time) ASSERT_EQ(10, (int)check_ents.size()); - map::iterator ei; + map::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); @@ -215,7 +215,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 entries; + vector entries; bool truncated; auto to_time = start_time + (10 * 1s); @@ -228,15 +228,15 @@ TEST_F(cls_log, test_log_add_different_time) ASSERT_EQ(0, (int)truncated); } - vector::iterator iter; + vector::iterator iter; /* returned entries should be sorted by time */ - map check_ents; + map 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; @@ -300,7 +300,7 @@ TEST_F(cls_log, trim_by_time) auto start_time = real_clock::now(); generate_log(ioctx, oid, 10, start_time, true); - vector entries; + vector entries; bool truncated; /* check list */ @@ -331,9 +331,9 @@ TEST_F(cls_log, trim_by_marker) auto start_time = real_clock::now(); generate_log(ioctx, oid, 10, start_time, true); - std::vector log1; + std::vector log1; { - vector entries; + vector entries; ASSERT_EQ(0, log_list(ioctx, oid, entries)); ASSERT_EQ(10u, entries.size()); @@ -345,7 +345,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 entries; + vector entries; ASSERT_EQ(0, log_list(ioctx, oid, entries)); ASSERT_EQ(9u, entries.size()); EXPECT_EQ(log1[1].id, entries.begin()->id); @@ -356,7 +356,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 entries; + vector entries; ASSERT_EQ(0, log_list(ioctx, oid, entries)); ASSERT_EQ(8u, entries.size()); EXPECT_EQ(log1[8].id, entries.rbegin()->id); @@ -367,7 +367,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 entries; + vector entries; ASSERT_EQ(0, log_list(ioctx, oid, entries)); ASSERT_EQ(7u, entries.size()); ASSERT_EQ(-ENODATA, do_log_trim(ioctx, oid, from, to)); @@ -377,7 +377,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 entries; + vector entries; ASSERT_EQ(0, log_list(ioctx, oid, entries)); ASSERT_EQ(0u, entries.size()); ASSERT_EQ(-ENODATA, do_log_trim(ioctx, oid, from, to)); diff --git a/src/test/rgw/test_log_backing.cc b/src/test/rgw/test_log_backing.cc index 79e90f83a50..984d03d2ee0 100644 --- a/src/test/rgw/test_log_backing.cc +++ b/src/test/rgw/test_log_backing.cc @@ -96,7 +96,7 @@ protected: std::string to_marker; { lr::ObjectReadOperation op; - std::vector entries; + std::vector entries; bool truncated = false; cls_log_list(op, {}, {}, {}, 1, entries, &to_marker, &truncated); auto r = rgw_rados_operate(&dp, ioctx, oid, std::move(op), nullptr, null_yield); @@ -111,7 +111,7 @@ protected: } { lr::ObjectReadOperation op; - std::vector entries; + std::vector entries; bool truncated = false; cls_log_list(op, {}, {}, {}, 1, entries, &to_marker, &truncated); auto r = rgw_rados_operate(&dp, ioctx, oid, std::move(op), nullptr, null_yield); diff --git a/src/tools/ceph-dencoder/common_types.h b/src/tools/ceph-dencoder/common_types.h index 37870b64879..fc515183fd5 100644 --- a/src/tools/ceph-dencoder/common_types.h +++ b/src/tools/ceph-dencoder/common_types.h @@ -155,13 +155,13 @@ TYPE(cls_2pc_reservation) TYPE_NONDETERMINISTIC(cls_2pc_urgent_data) #include "cls/log/cls_log_types.h" -TYPE(cls_log_header) +TYPE(cls::log::header) #include "cls/log/cls_log_ops.h" -TYPE(cls_log_info_op) -TYPE(cls_log_list_op) -TYPE(cls_log_list_ret) -TYPE(cls_log_trim_op) +TYPE(cls::log::ops::info_op) +TYPE(cls::log::ops::list_op) +TYPE(cls::log::ops::list_ret) +TYPE(cls::log::ops::trim_op) #include "cls/version/cls_version_ops.h" TYPE(cls_version_check_op) diff --git a/src/tools/ceph-dencoder/rgw_types.h b/src/tools/ceph-dencoder/rgw_types.h index 7575a8f00ce..604532670af 100644 --- a/src/tools/ceph-dencoder/rgw_types.h +++ b/src/tools/ceph-dencoder/rgw_types.h @@ -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) -- 2.39.5