Fix build with fmt 8/9
authorShengjing Zhu <zhushengjing@cambricon.com>
Sun, 31 Jul 2022 07:27:17 +0000 (15:27 +0800)
committerThomas Goirand <zigo@debian.org>
Mon, 28 Nov 2022 11:02:57 +0000 (11:02 +0000)
+ changes in segment_manager.cc and segment_manager.h are backported from
  part of the large changes in https://github.com/ceph/ceph/commit/d5b0cd13
+ change in node_extent_accessor.h is not forwarded to upstream since it's
  a workaround. However it doesn't harm since it's just a error message
  which shouldn't happen anyway.
+ changes in seastar is backported from
  https://github.com/scylladb/seastar/commit/dfb62861
+ changes in crimson/osd/main.cc is backported from
  https://github.com/ceph/ceph/commit/58cb9bac

Gbp-Pq: Name Fix-build-with-fmt-8-9.patch

src/crimson/os/seastore/CMakeLists.txt
src/crimson/os/seastore/onode_manager/staged-fltree/node_extent_accessor.h
src/crimson/os/seastore/segment_manager.cc [new file with mode: 0644]
src/crimson/os/seastore/segment_manager.h
src/crimson/osd/main.cc
src/seastar/include/seastar/core/print.hh

index 77f8465cf9a665bcf64dd815f8b957f6fbbf87d6..c6d4e937a370cef31c537af6a232a38a37944ddc 100644 (file)
@@ -1,6 +1,7 @@
 add_library(crimson-seastore STATIC
   cached_extent.cc
   seastore_types.cc
+  segment_manager.cc
   segment_manager/ephemeral.cc
   segment_manager/block.cc
   transaction_manager.cc
index 94782f50d4d9bbd4cf047290b8590152de076052..3c45861ff71d5e2f208464dbd4702a0ea881b4b4 100644 (file)
@@ -169,7 +169,7 @@ class DeltaRecorderT final: public DeltaRecorder {
       }
       default:
         logger().error("OTree::Extent::Replay: got unknown op {} when replay {:#x}",
-                       op, node.get_laddr());
+                       static_cast<uint8_t>(op), node.get_laddr());
         ceph_abort();
       }
     } catch (buffer::error& e) {
diff --git a/src/crimson/os/seastore/segment_manager.cc b/src/crimson/os/seastore/segment_manager.cc
new file mode 100644 (file)
index 0000000..d4a7132
--- /dev/null
@@ -0,0 +1,19 @@
+#include "crimson/os/seastore/segment_manager.h"
+
+namespace crimson::os::seastore {
+
+  std::ostream& operator<<(std::ostream &out, Segment::segment_state_t s)
+  {
+    using state_t = Segment::segment_state_t;
+    switch (s) {
+      case state_t::EMPTY:
+        return out << "EMPTY";
+      case state_t::OPEN:
+        return out << "OPEN";
+      case state_t::CLOSED:
+        return out << "CLOSED";
+      default:
+        return out << "INVALID_SEGMENT_STATE!";
+    }
+  }
+}
index 61c6509d19f7dbc503a262d4022b518775d792a0..30bdbc445b0d7e7560d8655b682702ef75dfa921 100644 (file)
@@ -73,6 +73,9 @@ public:
 
   virtual ~Segment() {}
 };
+
+std::ostream& operator<<(std::ostream& out, Segment::segment_state_t);
+
 using SegmentRef = boost::intrusive_ptr<Segment>;
 
 constexpr size_t PADDR_SIZE = sizeof(paddr_t);
index a90903e72271ef19972e14d5e917854ba1b1feb4..0db6496de4e516d725a559310f3184ef8da81783 100644 (file)
@@ -88,7 +88,7 @@ seastar::future<> make_keyring()
     if (exists &&
         keyring.load(nullptr, path) == 0 &&
         keyring.get_auth(name, auth)) {
-      seastar::fprint(std::cerr, "already have key in keyring: %s\n", path);
+      fmt::print(std::cerr, "already have key in keyring: %s\n", path);
       return seastar::now();
     } else {
       auth.key.create(std::make_unique<CephContext>().get(), CEPH_CRYPTO_AES);
@@ -100,7 +100,7 @@ seastar::future<> make_keyring()
       return crimson::write_file(std::move(bl), path, permissions);
     }
   }).handle_exception_type([path](const std::filesystem::filesystem_error& e) {
-    seastar::fprint(std::cerr, "FATAL: writing new keyring to %s: %s\n", path, e.what());
+    fmt::print(std::cerr, "FATAL: writing new keyring to %s: %s\n", path, e.what());
     throw e;
   });
 }
@@ -216,7 +216,7 @@ int main(int argc, char* argv[])
       });
     });
   } catch (...) {
-    seastar::fprint(std::cerr, "FATAL: Exception during startup, aborting: %s\n", std::current_exception());
+    fmt::print(std::cerr, "FATAL: Exception during startup, aborting: %s\n", std::current_exception());
     return EXIT_FAILURE;
   }
 }
index 72e3934db3083ea5003148587e6c7022b7a79b53..c1868e85ce4ffc7552c6682083332a6090762100 100644 (file)
@@ -133,7 +133,11 @@ template <typename... A>
 sstring
 format(const char* fmt, A&&... a) {
     fmt::memory_buffer out;
+#if FMT_VERSION >= 80000
+    fmt::format_to(fmt::appender(out), fmt::runtime(fmt), std::forward<A>(a)...);
+#else
     fmt::format_to(out, fmt, std::forward<A>(a)...);
+#endif
     return sstring{out.data(), out.size()};
 }