using ceph::bufferlist;
using ceph::Formatter;
+using namespace std::literals;
+
void ECSubWrite::encode(bufferlist &bl) const
{
ENCODE_START(4, 1, bl);
void ECSubRead::dump(Formatter *f) const
{
+ using extent_t = boost::tuple<uint64_t, uint64_t, uint32_t>;
+
f->dump_stream("from") << from;
f->dump_unsigned("tid", tid);
- f->open_array_section("objects");
- for (auto i = to_read.cbegin(); i != to_read.cend(); ++i) {
- f->open_object_section("object");
- f->dump_stream("oid") << i->first;
- f->open_array_section("extents");
- for (auto j = i->second.cbegin(); j != i->second.cend(); ++j) {
- f->open_object_section("extent");
- f->dump_unsigned("off", j->get<0>());
- f->dump_unsigned("len", j->get<1>());
- f->dump_unsigned("flags", j->get<2>());
- f->close_section();
- }
- f->close_section();
- f->close_section();
- }
- f->close_section();
- f->open_array_section("object_attrs_requested");
- for (auto i = attrs_to_read.cbegin(); i != attrs_to_read.cend(); ++i) {
- f->open_object_section("object");
- f->dump_stream("oid") << *i;
- f->close_section();
- }
- f->close_section();
+ // 'to_read' (map<hobject_t, list<tuple<offset, length, flags>>>)
+ f->with_obj_array_section(
+ "object"sv, to_read,
+ [](Formatter& f, const hobject_t& oid, const list<extent_t>& extents) {
+ f.dump_stream("oid") << oid;
+ f.with_obj_array_section(
+ "extent", extents, [](Formatter& f, const extent_t& extent) {
+ f.dump_unsigned("off", extent.get<0>());
+ f.dump_unsigned("len", extent.get<1>());
+ f.dump_unsigned("flags", extent.get<2>());
+ });
+ });
+
+ // 'object_attrs_requested': 'attrs_to_read' (set<hobject_t>)
+ f->with_obj_array_section(
+ "object_attrs_requested"sv, attrs_to_read,
+ [](Formatter& f, const hobject_t& oid) { f.dump_stream("oid") << oid; });
}
void ECSubRead::generate_test_instances(list<ECSubRead*>& o)
<< ")";
}
-void ECSubReadReply::dump(Formatter *f) const
+
+void ECSubReadReply::dump(Formatter* f) const
{
+ using offset_pair_t = pair<uint64_t, bufferlist>;
+ using extents_list_t = list<offset_pair_t>;
+
f->dump_stream("from") << from;
f->dump_unsigned("tid", tid);
- f->open_array_section("buffers_read");
- for (auto i = buffers_read.cbegin(); i != buffers_read.cend(); ++i) {
- f->open_object_section("object");
- f->dump_stream("oid") << i->first;
- f->open_array_section("data");
- for (auto j = i->second.cbegin(); j != i->second.cend(); ++j) {
- f->open_object_section("extent");
- f->dump_unsigned("off", j->first);
- f->dump_unsigned("buf_len", j->second.length());
- f->close_section();
- }
- f->close_section();
- f->close_section();
- }
- f->close_section();
-
- f->open_array_section("attrs_returned");
- for (auto i = attrs_read.cbegin(); i != attrs_read.cend(); ++i) {
- f->open_object_section("object_attrs");
- f->dump_stream("oid") << i->first;
- f->open_array_section("attrs");
- for (auto j = i->second.cbegin(); j != i->second.cend(); ++j) {
- f->open_object_section("attr");
- f->dump_string("attr", j->first);
- f->dump_unsigned("val_len", j->second.length());
- f->close_section();
- }
- f->close_section();
- f->close_section();
- }
- f->close_section();
-
- f->open_array_section("errors");
- for (auto i = errors.cbegin(); i != errors.cend(); ++i) {
- f->open_object_section("error_pair");
- f->dump_stream("oid") << i->first;
- f->dump_int("error", i->second);
- f->close_section();
- }
- f->close_section();
+
+ // 'buffers_read' (map<hobject_t, list<pair<uint64_t, bufferlist>>>)
+ f->with_obj_array_section(
+ "object"sv, buffers_read,
+ [](Formatter& f, const hobject_t& oid, const extents_list_t& l) {
+ f.dump_stream("oid") << oid;
+ f.with_obj_array_section(
+ "extent", l,
+ [](Formatter& f, const offset_pair_t& offset_n_bl) {
+ const auto& [off, bl] = offset_n_bl;
+ f.dump_unsigned("off", off);
+ f.dump_unsigned("buf_len", bl.length());
+ });
+ });
+
+ // "attrs_returned" (mapping hobject_t to a <string to bl> table)
+ f->with_obj_array_section(
+ "object_attrs"sv, attrs_read,
+ [](Formatter& f, const hobject_t& oid,
+ const std::map<std::string, ceph::buffer::list, std::less<>>& m) {
+ f.dump_stream("oid") << oid;
+ f.with_obj_array_section(
+ "attr", m,
+ [](Formatter& f, const std::string& attr,
+ const ceph::buffer::list& bl) {
+ f.dump_string("attr", attr);
+ f.dump_unsigned("val_len", bl.length());
+ });
+ });
+
+ // "errors": map<hobject_t, int>
+ f->with_obj_array_section(
+ "error_pair"sv, errors,
+ [](Formatter& f, const hobject_t& oid, int err) {
+ f.dump_stream("oid") << oid;
+ f.dump_int("error", err);
+ });
}
void ECSubReadReply::generate_test_instances(list<ECSubReadReply*>& o)
f->dump_int("shallow_errors", m_shallow_errors);
f->dump_int("deep_errors", m_deep_errors);
f->dump_int("fixed", m_fixed_count);
- {
- Formatter::ArraySection waiting_on_whom{*f, "waiting_on_whom"sv};
- for (const auto& p : m_maps_status.get_awaited()) {
- f->dump_stream("shard") << p;
- }
- }
+ f->with_array_section(
+ "waiting_on_whom"sv, m_maps_status.get_awaited(),
+ [](Formatter& f, const pg_shard_t& sh) { f.dump_stream("shard") << sh; });
+
if (m_scrub_job->blocked) {
f->dump_string("schedule", "blocked");
} else {
f->dump_stream("scrubber.max_end") << m_max_end;
f->dump_stream("scrubber.subset_last_update") << m_subset_last_update;
f->dump_bool("scrubber.deep", m_is_deep);
- {
- Formatter::ArraySection waiting_on_whom{*f, "waiting_on_whom"sv};
- for (const auto& p : m_maps_status.get_awaited()) {
- f->dump_stream("shard") << p;
- }
- }
-
+ f->with_array_section(
+ "waiting_on_whom"sv, m_maps_status.get_awaited(),
+ [](Formatter& f, const pg_shard_t& sh) { f.dump_stream("shard") << sh; });
f->dump_string("comment", "DEPRECATED - may be removed in the next release");
}