From: Kefu Chai Date: Tue, 16 Jun 2026 12:19:11 +0000 (+0800) Subject: crimson, osd: declare fmt formatters before they are used X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d5d2ff2e49352314734561ad1129a33d62bf36a3;p=ceph.git crimson, osd: declare fmt formatters before they are used the seastar logger checks log format strings with a consteval call at the use site, which instantiates fmt::formatter there. a specialization declared at the bottom of a header, after inline methods that already log T, is then "explicit specialization after instantiation". move the offending specializations ahead of the type: PG, LBALeafNode, DummyNodeExtent and WatchTimeoutRequest get a forward declaration plus the formatter before the class; overwrite_range_t, data_t and edge_t in object_data_handler.cc move ahead of the functions that log them. while here, trim_data_reservation() formatted a laddr_t base with 0x{:x}, but laddr_t's formatter takes no spec, so use {}. osd_types_fmt.h includes msg/msg_fmt.h: formatter formats req_id.name (an entity_name_t), so it depends on that type's formatter and must pull it in. otherwise logging a reqid instantiates formatter before msg_fmt.h is seen. Signed-off-by: Kefu Chai --- diff --git a/src/crimson/os/seastore/lba/lba_btree_node.h b/src/crimson/os/seastore/lba/lba_btree_node.h index dd15c2a8cf2..de7e18d8e6e 100644 --- a/src/crimson/os/seastore/lba/lba_btree_node.h +++ b/src/crimson/os/seastore/lba/lba_btree_node.h @@ -7,6 +7,7 @@ #include #include +#include #include "include/buffer.h" @@ -24,6 +25,16 @@ namespace crimson::os::seastore { class LogicalChildNode; } +namespace crimson::os::seastore::lba { +struct LBALeafNode; +} + +// declared ahead of the struct so the consteval {fmt} check sees it from +// LBALeafNode's own inline logging methods. +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : fmt::ostream_formatter {}; +#endif + namespace crimson::os::seastore::lba { using LBANode = FixedKVNode; @@ -470,6 +481,5 @@ using LBACursorRef = boost::intrusive_ptr; template <> struct fmt::formatter : fmt::ostream_formatter {}; template <> struct fmt::formatter : fmt::ostream_formatter {}; template <> struct fmt::formatter : fmt::ostream_formatter {}; -template <> struct fmt::formatter : fmt::ostream_formatter {}; template <> struct fmt::formatter : fmt::ostream_formatter {}; #endif diff --git a/src/crimson/os/seastore/object_data_handler.cc b/src/crimson/os/seastore/object_data_handler.cc index a586a606d68..a71de486352 100644 --- a/src/crimson/os/seastore/object_data_handler.cc +++ b/src/crimson/os/seastore/object_data_handler.cc @@ -4,10 +4,23 @@ #include #include +#include + #include "crimson/common/log.h" #include "crimson/os/seastore/object_data_handler.h" +// declared ahead of the logging functions below so the consteval {fmt} +// check can see them at the call sites. +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter + : fmt::ostream_formatter {}; +template <> struct fmt::formatter + : fmt::ostream_formatter {}; +template <> struct fmt::formatter + : fmt::ostream_formatter {}; +#endif + namespace { seastar::logger& logger() { return crimson::get_logger(ceph_subsys_seastore_odata); @@ -1881,11 +1894,3 @@ ObjectDataHandler::rename(context_t ctx) } // namespace crimson::os::seastore -#if FMT_VERSION >= 90000 -template <> struct fmt::formatter - : fmt::ostream_formatter {}; -template <> struct fmt::formatter - : fmt::ostream_formatter {}; -template <> struct fmt::formatter - : fmt::ostream_formatter {}; -#endif diff --git a/src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager/dummy.h b/src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager/dummy.h index 6852ec0298c..3a1610d1578 100644 --- a/src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager/dummy.h +++ b/src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager/dummy.h @@ -11,12 +11,22 @@ #include "crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager.h" +#include + /** * dummy.h * * Dummy backend implementations for test purposes. */ +namespace crimson::os::seastore::onode { +class DummyNodeExtent; +} + +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : fmt::ostream_formatter {}; +#endif + namespace crimson::os::seastore::onode { class DummySuper final: public Super { @@ -191,7 +201,3 @@ class DummyNodeExtentManager final: public NodeExtentManager { }; } - -#if FMT_VERSION >= 90000 -template <> struct fmt::formatter : fmt::ostream_formatter {}; -#endif diff --git a/src/crimson/osd/pg.h b/src/crimson/osd/pg.h index 6e5e47c591c..d44f4455a01 100644 --- a/src/crimson/osd/pg.h +++ b/src/crimson/osd/pg.h @@ -11,6 +11,8 @@ #include #include +#include + #include "common/dout.h" #include "common/ostream_temp.h" #include "include/interval_set.h" @@ -67,6 +69,16 @@ namespace crimson::os { class FuturizedStore; } +namespace crimson::osd { +class PG; +} + +// declared ahead of the class so the consteval {fmt} check can see it from +// PG's own inline logging methods (which format *this) above the class. +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : fmt::ostream_formatter {}; +#endif + namespace crimson::osd { class OpsExecuter; class SnapTrimEvent; @@ -1356,7 +1368,3 @@ struct PG::do_osd_ops_params_t { std::ostream& operator<<(std::ostream&, const PG& pg); } - -#if FMT_VERSION >= 90000 -template <> struct fmt::formatter : fmt::ostream_formatter {}; -#endif diff --git a/src/crimson/osd/watch.cc b/src/crimson/osd/watch.cc index d8db6ba628e..08534540941 100644 --- a/src/crimson/osd/watch.cc +++ b/src/crimson/osd/watch.cc @@ -11,6 +11,8 @@ #include "messages/MWatchNotify.h" +#include + namespace { seastar::logger& logger() { @@ -18,6 +20,14 @@ namespace { } } +namespace crimson::osd { +class WatchTimeoutRequest; +} + +#if FMT_VERSION >= 90000 +template <> struct fmt::formatter : fmt::ostream_formatter {}; +#endif + namespace crimson::osd { // a watcher can remove itself if it has not seen a notification after a period of time. @@ -348,7 +358,3 @@ void Notify::do_notify_timeout() } } // namespace crimson::osd - -#if FMT_VERSION >= 90000 -template <> struct fmt::formatter : fmt::ostream_formatter {}; -#endif diff --git a/src/osd/osd_types_fmt.h b/src/osd/osd_types_fmt.h index 0e36755782a..402453bc2e9 100644 --- a/src/osd/osd_types_fmt.h +++ b/src/osd/osd_types_fmt.h @@ -8,6 +8,11 @@ #include "common/hobject.h" #include "include/types_fmt.h" +// formatter below formats req_id.name (entity_name_t), so its +// formatter must be visible here, otherwise it gets instantiated before +// msg_fmt.h is pulled in by a later include (explicit-specialization-after- +// instantiation under compile-time {fmt} checking). +#include "msg/msg_fmt.h" #include "osd/osd_types.h" #include #include