]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Add improved printer for Onode
authorAdam Kupczyk <akupczyk@ibm.com>
Wed, 29 Nov 2023 11:55:44 +0000 (11:55 +0000)
committerAdam Kupczyk <akupczyk@ibm.com>
Wed, 7 Aug 2024 10:48:55 +0000 (10:48 +0000)
Added nice replacement for dump_onode function.
Introduce printer class that allows to select parts of Onode that are to be printed.
It severly reduced amount of clutter in output.
Usage:
using P = Bluestore::printer;
dout << blob->print(P::ptr + P::sdisk + P::schk + P::buf + P::attrs);

Signed-off-by: Adam Kupczyk <akupczyk@ibm.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 6b8ef773f4e6a2ff94095eab95cba0ae42e7c7c2..01eff1fa9ba745240d4a0c5f3fef16129c70cbad 100644 (file)
@@ -631,6 +631,43 @@ void _dump_onode(CephContext *cct, const BlueStore::Onode& o)
   }
 }
 
+std::ostream& operator<<(std::ostream& out, const BlueStore::Onode::printer &p)
+{
+  using P = BlueStore::printer;
+  const BlueStore::Onode& o = p.onode;
+  uint16_t mode = p.mode;
+  out << &o << " " << o.oid
+      << " nid " << o.onode.nid
+      << " size 0x" << std::hex << o.onode.size
+      << " (" << std::dec << o.onode.size << ")"
+      << " expected_object_size " << o.onode.expected_object_size
+      << " expected_write_size " << o.onode.expected_write_size
+      << " in " << o.onode.extent_map_shards.size() << " shards"
+      << ", " << o.extent_map.spanning_blob_map.size()
+      << " spanning blobs" << std::endl;
+  const BlueStore::ExtentMap& map = o.extent_map;
+  std::set<BlueStore::Blob*> visited;
+  for (const auto& e : map.extent_map) {
+    BlueStore::Blob* b = e.blob.get();
+    if (!visited.contains(b)) {
+      out << b->print(mode) << std::endl;
+      visited.insert(b);
+    }
+  }
+  // to make printing extents in-sync with blobs
+  bool mode_extent = mode & (P::ptr | P::nick);
+  for (const auto& e : map.extent_map) {
+    out << e.print(mode_extent) << std::endl;
+  }
+  if (mode & P::attrs) {
+    for (const auto& p : o.onode.attrs) {
+      out << "  attr " << p.first
+        << " len " << p.second.length() << std::endl;
+    }
+  }
+  return out;
+}
+
 template <int LogLevelV>
 void _dump_transaction(CephContext *cct, ObjectStore::Transaction *t)
 {
index 597aa5df133a54e630f3d00e9c62974f3d756096..bce32882ea69a56f3ae9c7dd54c2b37968a8cb4b 100644 (file)
@@ -285,6 +285,7 @@ public:
     static constexpr uint16_t schk = 128; // only base checksum info
     static constexpr uint16_t buf = 256;  // print Blob's buffers (takes cache lock)
     static constexpr uint16_t sbuf = 512; // short print Blob's buffers (takes cache lock)
+    static constexpr uint16_t attrs = 1024; // print attrs in onode
   };
 
   /// cached buffer
@@ -1446,6 +1447,17 @@ public:
     void decode_omap_key(const std::string& key, std::string *user_key);
 
     void finish_write(TransContext* txc, uint32_t offset, uint32_t length);
+
+    struct printer : public BlueStore::printer {
+      const Onode& onode;
+      uint16_t mode;
+      printer(const Onode& onode, uint16_t mode)
+      :onode(onode), mode(mode) {}
+    };
+    friend std::ostream& operator<<(std::ostream& out, const printer &p);
+    printer print(uint16_t mode) const {
+      return printer(*this, mode);
+    }
   };
 
   /// A generic Cache Shard