From 481cb190960d84aab6e3e9aa95b360fcc8c1e417 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 | 68 +++++++++++++++------------- src/cls/log/cls_log_types.h | 32 ++++++------- 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/rgw_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/rgw_types.h | 4 +- 23 files changed, 160 insertions(+), 159 deletions(-) diff --git a/src/cls/log/cls_log.cc b/src/cls/log/cls_log.cc index 65b070756e712..c1126b5659d88 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 531cb765f7280..5af994d4ffa18 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 12cd88c260170..0b6eac6e9cb53 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 6d0c687e996a3..cf8edcd87f8d7 100644 --- a/src/cls/log/cls_log_ops.h +++ b/src/cls/log/cls_log_ops.h @@ -4,13 +4,19 @@ #ifndef CEPH_CLS_LOG_OPS_H #define CEPH_CLS_LOG_OPS_H +#include +#include + +#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); @@ -33,12 +39,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}; @@ -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 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); @@ -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 diff --git a/src/cls/log/cls_log_types.h b/src/cls/log/cls_log_types.h index f137dbbfca6d3..b228f07e352e7 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,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 diff --git a/src/rgw/driver/rados/rgw_cr_rados.cc b/src/rgw/driver/rados/rgw_cr_rados.cc index 6556d116b8f49..7892747bce0ce 100644 --- a/src/rgw/driver/rados/rgw_cr_rados.cc +++ b/src/rgw/driver/rados/rgw_cr_rados.cc @@ -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) diff --git a/src/rgw/driver/rados/rgw_cr_rados.h b/src/rgw/driver/rados/rgw_cr_rados.h index bac210bc23d69..dcf7dd67fa38e 100644 --- a/src/rgw/driver/rados/rgw_cr_rados.h +++ b/src/rgw/driver/rados/rgw_cr_rados.h @@ -1524,7 +1524,7 @@ public: class RGWRadosTimelogAddCR : public RGWSimpleCoroutine { const DoutPrefixProvider *dpp; rgw::sal::RadosStore* store; - std::vector entries; + std::vector 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; diff --git a/src/rgw/driver/rados/rgw_datalog.cc b/src/rgw/driver/rados/rgw_datalog.cc index ea2a3548ad45a..4a15a1e485795 100644 --- a/src/rgw/driver/rados/rgw_datalog.cc +++ b/src/rgw/driver/rados/rgw_datalog.cc @@ -98,7 +98,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: @@ -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(out).push_back(std::move(e)); } @@ -154,7 +154,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); @@ -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 log_entries; + std::vector 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, RGWDataChangesBE::entries>> m; diff --git a/src/rgw/driver/rados/rgw_datalog.h b/src/rgw/driver/rados/rgw_datalog.h index e2fc16dd305cb..ba91a02ee1e69 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" @@ -357,7 +356,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 988087ca97a93..5928279dc4312 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 c83db7c40437b..a79c81817d6a0 100644 --- a/src/rgw/driver/rados/rgw_metadata.h +++ b/src/rgw/driver/rados/rgw_metadata.h @@ -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& sections); diff --git a/src/rgw/driver/rados/rgw_rest_log.cc b/src/rgw/driver/rados/rgw_rest_log.cc index 61e67f7c3afab..c31404e1bcd3d 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 b54cdb425bb57..2d71e23786f7d 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 182b81655659e..a817d8318ba56 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) {} @@ -1416,7 +1416,7 @@ class RGWMetaSyncShardCR : public RGWCoroutine { RGWMetaSyncShardMarkerTrack *marker_tracker = nullptr; - vector log_entries; + vector 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 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 e7d482abac81f..8dd7e6b832035 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/rgw_admin.cc b/src/rgw/rgw_admin.cc index 300302f5b46e0..470b26dc87a0a 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -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 entries; + vector 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(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 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) { @@ -10031,7 +10031,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 589a340837e08..ea9484cd5fbc3 100644 --- a/src/rgw/rgw_mdlog.h +++ b/src/rgw/rgw_mdlog.h @@ -37,9 +37,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; 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& 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; @@ -126,7 +126,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 d1f1a32d4fd69..6b65d708e1155 100644 --- a/src/rgw/rgw_metadata.cc +++ b/src/rgw/rgw_metadata.cc @@ -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); diff --git a/src/rgw/services/svc_cls.cc b/src/rgw/services/svc_cls.cc index c076f72cab475..6b30b4a036310 100644 --- a/src/rgw/services/svc_cls.cc +++ b/src/rgw/services/svc_cls.cc @@ -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& entries, + std::vector& 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& entries, + int max_entries, std::vector& 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); diff --git a/src/rgw/services/svc_cls.h b/src/rgw/services/svc_cls.h index eab1711d1d94d..a148fcf64a14a 100644 --- a/src/rgw/services/svc_cls.h +++ b/src/rgw/services/svc_cls.h @@ -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& entries, + std::vector& 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& 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, 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, diff --git a/src/test/cls_log/test_cls_log.cc b/src/test/cls_log/test_cls_log.cc index a52604659f85c..353704cfaf5e9 100644 --- a/src/test/cls_log/test_cls_log.cc +++ b/src/test/cls_log/test_cls_log.cc @@ -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& entries, + vector& 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& entries, bool *truncated) + vector& 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& entries) + vector& 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 entries; + vector 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::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)); @@ -179,14 +179,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); @@ -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 entries; + vector 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::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; @@ -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 entries; + vector 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 log1; + std::vector log1; { - vector entries; + vector 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 entries; + vector 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 entries; + vector 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 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)); @@ -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 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 e03ee0c5f12dc..2dbddcd01d4c1 100644 --- a/src/test/rgw/test_log_backing.cc +++ b/src/test/rgw/test_log_backing.cc @@ -94,7 +94,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, &op, nullptr, null_yield); @@ -109,7 +109,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, &op, nullptr, null_yield); diff --git a/src/tools/ceph-dencoder/rgw_types.h b/src/tools/ceph-dencoder/rgw_types.h index 45d6921c5be28..b8097643950c0 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