packages/ceph/ceph-18.2.0-fmt10-fixes.patch
2023-12-14 14:23:41 +01:00

207 lines
6.3 KiB
Diff

diff --git a/src/common/LogEntry.h b/src/common/LogEntry.h
index 3ddebbd3043..b9096e2850a 100644
--- a/src/common/LogEntry.h
+++ b/src/common/LogEntry.h
@@ -15,7 +15,11 @@
#ifndef CEPH_LOGENTRY_H
#define CEPH_LOGENTRY_H
+#include <fmt/core.h>
#include <fmt/format.h>
+#if FMT_VERSION >= 90000
+#include <fmt/ostream.h>
+#endif
#include "include/utime.h"
#include "msg/msg_fmt.h"
@@ -194,19 +198,17 @@ inline std::ostream& operator<<(std::ostream& out, const LogEntry& e)
<< e.channel << " " << e.prio << " " << e.msg;
}
-template <> struct fmt::formatter<EntityName> : fmt::formatter<std::string_view> {
- template <typename FormatContext>
- auto format(const EntityName& e, FormatContext& ctx) {
- return formatter<std::string_view>::format(e.to_str(), ctx);
- }
-};
+template <>
+struct fmt::formatter<clog_type>: fmt::ostream_formatter {};
-template <> struct fmt::formatter<LogEntry> : fmt::formatter<std::string_view> {
- template <typename FormatContext>
- auto format(const LogEntry& e, FormatContext& ctx) {
- return fmt::format_to(ctx.out(), "{} {} ({}) {} : {} {} {}",
- e.stamp, e.name, e.rank, e.seq, e.channel, e.prio, e.msg);
+template <>
+struct fmt::formatter<EntityName> : fmt::formatter<std::string_view> {
+ auto format(const EntityName& e, format_context& ctx) {
+ return fmt::formatter<std::string_view>::format(e.to_str(), ctx);
}
};
+template <>
+struct fmt::formatter<LogEntry> : fmt::ostream_formatter {};
+
#endif
diff --git a/src/include/byteorder.h b/src/include/byteorder.h
index eb6d5e102b4..9a4d0be877a 100644
--- a/src/include/byteorder.h
+++ b/src/include/byteorder.h
@@ -53,3 +53,8 @@ inline ceph_les16 init_les16(__s16 x) {
v = x;
return v;
}
+
+template <typename T>
+auto format_as(ceph_le<T> c) {
+ return (T)c;
+}
diff --git a/src/include/neorados/RADOS_fmt.hpp b/src/include/neorados/RADOS_fmt.hpp
new file mode 100644
index 00000000000..1512ec965fe
--- /dev/null
+++ b/src/include/neorados/RADOS_fmt.hpp
@@ -0,0 +1,16 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+#pragma once
+/**
+ * \file fmtlib formatters for some neorados types
+ */
+
+#include <fmt/core.h>
+#if FMT_VERSION >= 90000
+#include <fmt/ostream.h>
+#endif
+
+#include <include/neorados/RADOS.hpp>
+
+template <>
+struct fmt::formatter<neorados::Object> : fmt::ostream_formatter {};
diff --git a/src/include/types_fmt.h b/src/include/types_fmt.h
new file mode 100644
index 00000000000..3d40085f0b2
--- /dev/null
+++ b/src/include/types_fmt.h
@@ -0,0 +1,16 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+#pragma once
+/**
+ * \file fmtlib formatters for some types.h classes
+ */
+
+#include <fmt/core.h>
+#if FMT_VERSION >= 90000
+#include <fmt/ostream.h>
+#endif
+
+#include <include/types.h>
+
+template <>
+struct fmt::formatter<shard_id_t> : fmt::ostream_formatter {};
diff --git a/src/osd/SnapMapper.cc b/src/osd/SnapMapper.cc
index 7893bc08fdc..e8d34cd25bc 100644
--- a/src/osd/SnapMapper.cc
+++ b/src/osd/SnapMapper.cc
@@ -211,7 +211,7 @@ string SnapMapper::get_prefix(int64_t pool, snapid_t snap)
return fmt::sprintf("%s%lld_%.16X_",
MAPPING_PREFIX,
pool,
- snap);
+ (uint64_t)snap);
}
string SnapMapper::to_raw_key(
@@ -650,7 +650,7 @@ string SnapMapper::make_purged_snap_key(int64_t pool, snapid_t last)
return fmt::sprintf("%s_%lld_%016llx",
PURGED_SNAP_PREFIX,
pool,
- last);
+ (uint64_t)last);
}
void SnapMapper::make_purged_snap_key_value(
@@ -866,7 +866,7 @@ string SnapMapper::get_legacy_prefix(snapid_t snap)
{
return fmt::sprintf("%s%.16X_",
LEGACY_MAPPING_PREFIX,
- snap);
+ (uint64_t)snap);
}
string SnapMapper::to_legacy_raw_key(
diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h
index afed5fa8351..e374369e8ba 100644
--- a/src/osd/osd_types.h
+++ b/src/osd/osd_types.h
@@ -35,6 +35,7 @@
#include "msg/msg_types.h"
#include "include/compat.h"
#include "include/types.h"
+#include "include/types_fmt.h"
#include "include/utime.h"
#include "include/CompatSet.h"
#include "common/ceph_context.h"
diff --git a/src/osd/osd_types_fmt.h b/src/osd/osd_types_fmt.h
index 8d48134106e..65a751469f7 100644
--- a/src/osd/osd_types_fmt.h
+++ b/src/osd/osd_types_fmt.h
@@ -57,7 +57,7 @@ struct fmt::formatter<chunk_info_t> {
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
template <typename FormatContext>
- auto format(const chunk_info_t& ci, FormatContext& ctx)
+ auto format(const chunk_info_t& ci, FormatContext& ctx) const
{
return fmt::format_to(ctx.out(), "(len: {} oid: {} offset: {} flags: {})",
ci.length, ci.oid, ci.offset,
@@ -169,7 +169,7 @@ struct fmt::formatter<pg_info_t> {
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
template <typename FormatContext>
- auto format(const pg_info_t& pgi, FormatContext& ctx)
+ auto format(const pg_info_t& pgi, FormatContext& ctx) const
{
fmt::format_to(ctx.out(), "{}({}", pgi.pgid, (pgi.dne() ? " DNE" : ""));
if (pgi.is_empty()) {
@@ -211,7 +211,7 @@ struct fmt::formatter<SnapSet> {
}
template <typename FormatContext>
- auto format(const SnapSet& snps, FormatContext& ctx)
+ auto format(const SnapSet& snps, FormatContext& ctx) const
{
if (verbose) {
// similar to SnapSet::dump()
@@ -265,7 +265,7 @@ struct fmt::formatter<ScrubMap::object> {
///\todo: consider passing the 'D" flag to control snapset dump
template <typename FormatContext>
- auto format(const ScrubMap::object& so, FormatContext& ctx)
+ auto format(const ScrubMap::object& so, FormatContext& ctx) const
{
fmt::format_to(ctx.out(),
"so{{ sz:{} dd:{} od:{} ",
@@ -308,7 +308,7 @@ struct fmt::formatter<ScrubMap> {
}
template <typename FormatContext>
- auto format(const ScrubMap& smap, FormatContext& ctx)
+ auto format(const ScrubMap& smap, FormatContext& ctx) const
{
fmt::format_to(ctx.out(),
"smap{{ valid:{} incr-since:{} #:{}",
diff --git a/src/tools/neorados.cc b/src/tools/neorados.cc
index 24966d2aee5..44ee1cf199c 100644
--- a/src/tools/neorados.cc
+++ b/src/tools/neorados.cc
@@ -36,6 +36,7 @@
#include "include/buffer.h" // :(
#include "include/neorados/RADOS.hpp"
+#include "include/neorados/RADOS_fmt.hpp"
using namespace std::literals;