Merge pull request #49000 from tchaikov/wip-crimson-fmt-v9

crimson: various fmt related changes and fixes.

Reviewed-by: Yingxin Cheng <yingxin.cheng@intel.com>
This commit is contained in:
Kefu Chai 2022-11-22 15:08:04 +08:00 committed by GitHub
commit 021fa45573
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 217 additions and 15 deletions

View File

@ -5,6 +5,7 @@
#include <boost/algorithm/string/join.hpp>
#include <fmt/format.h>
#include <fmt/ranges.h>
#include <seastar/net/api.hh>
#include <seastar/net/inet_address.hh>
#include <seastar/core/future-util.hh>

View File

@ -31,8 +31,12 @@ class Gated {
"{}, {} skipped, system shutdown", who, what);
return;
}
gated_logger().error(
"{} dispatch() {} caught exception: {}", who, what, eptr);
try {
std::rethrow_exception(eptr);
} catch (std::exception& e) {
gated_logger().error(
"{} dispatch() {} caught exception: {}", who, what, e.what());
}
assert(*eptr.__cxa_exception_type()
== typeid(seastar::gate_closed_exception));
});

View File

@ -1,4 +1,5 @@
#include "crimson/common/logclient.h"
#include <fmt/ranges.h>
#include "include/str_map.h"
#include "messages/MLog.h"
#include "messages/MLogAck.h"

View File

@ -757,3 +757,7 @@ public:
};
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::Operation> : fmt::ostream_formatter {};
#endif

View File

@ -64,3 +64,7 @@ inline std::ostream& operator<<(std::ostream& out, const Client& client) {
}
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::mgr::Client> : fmt::ostream_formatter {};
#endif

View File

@ -4,7 +4,7 @@
#include "MonClient.h"
#include <random>
#include <fmt/ranges.h>
#include <seastar/core/future-util.hh>
#include <seastar/core/lowres_clock.hh>
#include <seastar/core/shared_future.hh>

View File

@ -212,3 +212,7 @@ inline std::ostream& operator<<(std::ostream& out, const Client& client) {
}
} // namespace crimson::mon
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::mon::Client> : fmt::ostream_formatter {};
#endif

View File

@ -125,3 +125,7 @@ inline std::ostream& operator<<(std::ostream& out, const Connection& conn) {
}
} // namespace crimson::net
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::net::Connection> : fmt::ostream_formatter {};
#endif

View File

@ -123,3 +123,7 @@ inline std::ostream& operator<<(std::ostream& out, const Messenger& msgr) {
}
} // namespace crimson::net
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::net::Messenger> : fmt::ostream_formatter {};
#endif

View File

@ -192,3 +192,7 @@ struct fmt::formatter<crimson::net::Protocol::write_state_t>
return formatter<string_view>::format(name, ctx);
}
};
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::net::Protocol> : fmt::ostream_formatter {};
#endif

View File

@ -5,8 +5,10 @@
#include <seastar/core/lowres_clock.hh>
#include <fmt/format.h>
#include <fmt/ranges.h>
#include "include/msgr.h"
#include "include/random.h"
#include "msg/msg_fmt.h"
#include "crimson/auth/AuthClient.h"
#include "crimson/auth/AuthServer.h"
@ -100,6 +102,13 @@ inline uint64_t generate_client_cookie() {
} // namespace anonymous
namespace fmt {
template <typename T> auto ptr(const ::seastar::shared_ptr<T>& p) -> const void* {
return p.get();
}
}
namespace crimson::net {
#ifdef UNIT_TESTS_BUILT
@ -604,7 +613,7 @@ seastar::future<> ProtocolV2::client_auth(std::vector<uint32_t> &allowed_methods
return handle_auth_reply();
});
} catch (const crimson::auth::error& e) {
logger().error("{} get_initial_auth_request returned {}", conn, e);
logger().error("{} get_initial_auth_request returned {}", conn, e.what());
abort_in_close(*this, true);
return seastar::now();
}
@ -1095,7 +1104,7 @@ ProtocolV2::handle_existing_connection(SocketConnectionRef existing_conn)
" found existing {}(state={}, gs={}, pgs={}, cs={}, cc={}, sc={})",
conn, global_seq, peer_global_seq, connect_seq,
client_cookie, server_cookie,
existing_conn, get_state_name(existing_proto->state),
fmt::ptr(existing_conn), get_state_name(existing_proto->state),
existing_proto->global_seq,
existing_proto->peer_global_seq,
existing_proto->connect_seq,
@ -1104,7 +1113,7 @@ ProtocolV2::handle_existing_connection(SocketConnectionRef existing_conn)
if (!validate_peer_name(existing_conn->get_peer_name())) {
logger().error("{} server_connect: my peer_name doesn't match"
" the existing connection {}, abort", conn, existing_conn);
" the existing connection {}, abort", conn, fmt::ptr(existing_conn));
abort_in_fault();
}
@ -1360,7 +1369,7 @@ ProtocolV2::server_reconnect()
" found existing {}(state={}, gs={}, pgs={}, cs={}, cc={}, sc={})",
conn, global_seq, peer_global_seq, reconnect.connect_seq(),
reconnect.client_cookie(), reconnect.server_cookie(),
existing_conn,
fmt::ptr(existing_conn),
get_state_name(existing_proto->state),
existing_proto->global_seq,
existing_proto->peer_global_seq,
@ -1370,7 +1379,7 @@ ProtocolV2::server_reconnect()
if (!validate_peer_name(existing_conn->get_peer_name())) {
logger().error("{} server_reconnect: my peer_name doesn't match"
" the existing connection {}, abort", conn, existing_conn);
" the existing connection {}, abort", conn, fmt::ptr(existing_conn));
abort_in_fault();
}

View File

@ -231,3 +231,7 @@ class ProtocolV2 final : public Protocol {
};
} // namespace crimson::net
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::net::ProtocolV2> : fmt::ostream_formatter {};
#endif

View File

@ -213,3 +213,7 @@ class SocketConnection : public Connection {
};
} // namespace crimson::net
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::net::SocketConnection> : fmt::ostream_formatter {};
#endif

View File

@ -18,6 +18,7 @@
#include <tuple>
#include <boost/functional/hash.hpp>
#include <fmt/os.h>
#include "auth/Auth.h"
#include "Errors.h"

View File

@ -164,3 +164,7 @@ class SocketMessenger final : public Messenger {
};
} // namespace crimson::net
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::net::SocketMessenger> : fmt::ostream_formatter {};
#endif

View File

@ -133,3 +133,8 @@ public:
using BackrefLeafNodeRef = BackrefLeafNode::Ref;
} // namespace crimson::os::seastore::backref
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::os::seastore::backref::BackrefInternalNode> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::os::seastore::backref::BackrefLeafNode> : fmt::ostream_formatter {};
#endif

View File

@ -513,3 +513,7 @@ public:
};
}
#if FMT_VERSION >= 90000
template <typename node_bound_t> struct fmt::formatter<crimson::os::seastore::btree_range_pin_t<node_bound_t>> : fmt::ostream_formatter {};
#endif

View File

@ -933,3 +933,9 @@ using lextent_list_t = addr_extent_list_base_t<
laddr_t, TCachedExtentRef<T>>;
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::os::seastore::CachedExtent> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::os::seastore::LogicalCachedExtent> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::os::seastore::LBAPin> : fmt::ostream_formatter {};
#endif

View File

@ -180,3 +180,7 @@ struct CollectionNode
};
using CollectionNodeRef = CollectionNode::CollectionNodeRef;
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::os::seastore::collection_manager::CollectionNode> : fmt::ostream_formatter {};
#endif

View File

@ -125,3 +125,7 @@ public:
WRITE_CLASS_DENC_BOUNDED(crimson::os::seastore::device_spec_t)
WRITE_CLASS_DENC(crimson::os::seastore::device_config_t)
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::os::seastore::device_config_t> : fmt::ostream_formatter {};
#endif

View File

@ -217,3 +217,8 @@ struct LBALeafNode
using LBALeafNodeRef = TCachedExtentRef<LBALeafNode>;
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::os::seastore::lba_manager::btree::LBAInternalNode> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::os::seastore::lba_manager::btree::LBALeafNode> : fmt::ostream_formatter {};
#endif

View File

@ -135,3 +135,7 @@ private:
};
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::os::seastore::ObjectDataBlock> : fmt::ostream_formatter {};
#endif

View File

@ -241,3 +241,8 @@ using OMapLeafNodeRef = OMapLeafNode::OMapLeafNodeRef;
std::ostream &operator<<(std::ostream &out, const omap_inner_key_t &rhs);
std::ostream &operator<<(std::ostream &out, const omap_leaf_key_t &rhs);
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::os::seastore::omap_manager::OMapInnerNode> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::os::seastore::omap_manager::OMapLeafNode> : fmt::ostream_formatter {};
#endif

View File

@ -217,3 +217,7 @@ class SeastoreNodeExtentManager final: public TransactionManagerHandle {
};
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::os::seastore::onode::SeastoreNodeExtent> : fmt::ostream_formatter {};
#endif

View File

@ -88,3 +88,7 @@ struct RootBlock : CachedExtent {
using RootBlockRef = RootBlock::Ref;
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::os::seastore::RootBlock> : fmt::ostream_formatter {};
#endif

View File

@ -591,7 +591,7 @@ try_decode_records_header(
journal_logger().debug(
"try_decode_records_header: failed, "
"cannot decode record_group_header_t, got {}.",
e);
e.what());
return std::nullopt;
}
if (header.segment_nonce != expected_nonce) {
@ -654,7 +654,7 @@ try_decode_record_headers(
journal_logger().debug(
"try_decode_record_headers: failed, "
"cannot decode record_header_t, got {}.",
e);
e.what());
return std::nullopt;
}
}
@ -690,7 +690,7 @@ try_decode_extent_infos(
journal_logger().debug(
"try_decode_extent_infos: failed, "
"cannot decode extent_info_t, got {}.",
e);
e.what());
return std::nullopt;
}
}
@ -734,7 +734,7 @@ try_decode_deltas(
journal_logger().debug(
"try_decode_deltas: failed, "
"cannot decode delta_info_t, got {}.",
e);
e.what());
return std::nullopt;
}
}

View File

@ -2180,3 +2180,20 @@ struct denc_traits<crimson::os::seastore::segment_type_t> {
reinterpret_cast<char*>(&o));
}
};
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::os::seastore::delta_info_t> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::os::seastore::device_id_printer_t> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::os::seastore::extent_types_t> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::os::seastore::journal_seq_t> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::os::seastore::journal_tail_delta_t> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::os::seastore::paddr_t> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::os::seastore::placement_hint_t> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::os::seastore::record_locator_t> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::os::seastore::rewrite_gen_printer_t> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::os::seastore::sea_time_point_printer_t> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::os::seastore::segment_id_t> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::os::seastore::segment_seq_printer_t> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::os::seastore::segment_type_t> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::os::seastore::transaction_type_t> : fmt::ostream_formatter {};
#endif

View File

@ -191,3 +191,7 @@ public:
WRITE_CLASS_DENC(
crimson::os::seastore::block_sm_superblock_t
)
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::os::seastore::block_sm_superblock_t> : fmt::ostream_formatter {};
#endif

View File

@ -153,3 +153,7 @@ public:
};
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::os::seastore::segment_manager::ephemeral_config_t> : fmt::ostream_formatter {};
#endif

View File

@ -590,3 +590,7 @@ template <typename T>
using with_trans_ertr = typename T::base_ertr::template extend<crimson::ct_error::eagain>;
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::os::seastore::io_stat_t> : fmt::ostream_formatter {};
#endif

View File

@ -3,8 +3,10 @@
#include <algorithm>
#include <boost/type_index.hpp>
#include <fmt/ranges.h>
#include "common/hobject_fmt.h"
#include "crimson/osd/backfill_state.h"
#include "osd/osd_types_fmt.h"
namespace {
seastar::logger& logger() {

View File

@ -4,6 +4,8 @@
#include "heartbeat.h"
#include <boost/range/join.hpp>
#include <fmt/chrono.h>
#include <fmt/os.h>
#include "messages/MOSDPing.h"
#include "messages/MOSDFailure.h"

View File

@ -246,6 +246,10 @@ class Heartbeat::Connection {
}
};
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<Heartbeat::Connection> : fmt::ostream_formatter {};
#endif
/*
* Track the ping history and ping reply (the pong) from the same session, clean up
* history once hb_front or hb_back loses connection and restart the session once
@ -454,3 +458,7 @@ class Heartbeat::Peer final : private Heartbeat::ConnectionListener {
Connection con_front;
Connection con_back;
};
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<Heartbeat> : fmt::ostream_formatter {};
#endif

View File

@ -8,6 +8,7 @@
#include <boost/iterator/counting_iterator.hpp>
#include <boost/range/join.hpp>
#include <fmt/format.h>
#include <fmt/os.h>
#include <fmt/ostream.h>
#include <seastar/core/timer.hh>

View File

@ -235,3 +235,7 @@ inline std::ostream& operator<<(std::ostream& out, const OSD& osd) {
}
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::osd::OSD> : fmt::ostream_formatter {};
#endif

View File

@ -142,5 +142,8 @@ BackfillRecovery::BackfillRecovery(
evt(evt.intrusive_from_this())
{}
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::osd::UrgentRecovery> : fmt::ostream_formatter {};
#endif

View File

@ -260,3 +260,7 @@ public:
};
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::osd::ClientRequest> : fmt::ostream_formatter {};
#endif

View File

@ -68,3 +68,7 @@ private:
};
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::osd::LogMissingRequest> : fmt::ostream_formatter {};
#endif

View File

@ -68,3 +68,7 @@ private:
};
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::osd::LogMissingRequestReply> : fmt::ostream_formatter {};
#endif

View File

@ -187,3 +187,8 @@ public:
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::osd::LocalPeeringEvent> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::osd::RemotePeeringEvent> : fmt::ostream_formatter {};
#endif

View File

@ -52,3 +52,7 @@ public:
};
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::osd::PGAdvanceMap> : fmt::ostream_formatter {};
#endif

View File

@ -62,3 +62,7 @@ private:
};
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::osd::RecoverySubRequest> : fmt::ostream_formatter {};
#endif

View File

@ -66,3 +66,7 @@ private:
};
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::osd::RepRequest> : fmt::ostream_formatter {};
#endif

View File

@ -14,12 +14,15 @@
#include <fmt/format.h>
#include <fmt/ostream.h>
#include "common/hobject_fmt.h"
#include "messages/MOSDOp.h"
#include "messages/MOSDOpReply.h"
#include "messages/MOSDRepOp.h"
#include "messages/MOSDRepOpReply.h"
#include "osd/OSDMap.h"
#include "osd/osd_types_fmt.h"
#include "os/Transaction.h"
@ -58,6 +61,17 @@ std::ostream& operator<<(std::ostream& out, const signedspan& d)
}
}
template <typename T>
struct fmt::formatter<std::optional<T>> : fmt::formatter<T> {
template <typename FormatContext>
auto format(const std::optional<T>& v, FormatContext& ctx) const {
if (v.has_value()) {
return fmt::formatter<T>::format(*v, ctx);
}
return fmt::format_to(ctx.out(), "<null>");
}
};
namespace crimson::osd {
using crimson::common::local_conf;
@ -1067,7 +1081,7 @@ PG::with_clone_obc(hobject_t oid, with_obc_func_t&& func)
}
auto coid = resolve_oid(head->get_ro_ss(), oid);
if (!coid) {
logger().error("with_clone_obc: {} clone not found", coid);
logger().error("with_clone_obc: {} clone not found", oid);
return load_obc_iertr::future<>{crimson::ct_error::enoent::make()};
}
auto [clone, existed] = shard_services.get_cached_obc(*coid);

View File

@ -833,3 +833,7 @@ struct PG::do_osd_ops_params_t {
std::ostream& operator<<(std::ostream&, const PG& pg);
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::osd::PG> : fmt::ostream_formatter {};
#endif

View File

@ -531,3 +531,7 @@ public:
};
}
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::osd::OSDSingletonState::pg_temp_t> : fmt::ostream_formatter {};
#endif

View File

@ -146,3 +146,8 @@ struct test_block_mutator_t {
}
WRITE_CLASS_DENC_BOUNDED(crimson::os::seastore::test_block_delta_t)
#if FMT_VERSION >= 90000
template <> struct fmt::formatter<crimson::os::seastore::TestBlock> : fmt::ostream_formatter {};
template <> struct fmt::formatter<crimson::os::seastore::TestBlockPhysical> : fmt::ostream_formatter {};
#endif