]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Add ability to partially print Onode
authorAdam Kupczyk <akupczyk@ibm.com>
Fri, 14 Jun 2024 10:54:01 +0000 (10:54 +0000)
committerAdam Kupczyk <akupczyk@ibm.com>
Wed, 7 Aug 2024 10:50:43 +0000 (10:50 +0000)
Now Onode can be printed in selected range.
It is useful in high-level dout modes that operate on a fragment of
entire Onode.

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

index cad3c86b0a94f00c6ee5acfca583f759e45a1f86..87fe96ccc988b4f7877732642a7b22190624ae85 100644 (file)
@@ -1451,14 +1451,18 @@ public:
     void finish_write(TransContext* txc, uint32_t offset, uint32_t length);
 
     struct printer : public BlueStore::printer {
-      const Onodeonode;
+      const Onode &onode;
       uint16_t mode;
-      printer(const Onode& onode, uint16_t mode)
-      :onode(onode), mode(mode) {}
+      uint32_t from = 0;
+      uint32_t end = OBJECT_MAX_SIZE;
+      printer(const Onode &onode, uint16_t mode) : onode(onode), mode(mode) {}
+      printer(const Onode &onode, uint16_t mode, uint32_t from, uint32_t end)
+          : onode(onode), mode(mode), from(from), end(end) {}
     };
-    friend std::ostream& operator<<(std::ostream& out, const printer &p);
-    printer print(uint16_t mode) const {
-      return printer(*this, mode);
+    friend std::ostream &operator<<(std::ostream &out, const printer &p);
+    printer print(uint16_t mode) const { return printer(*this, mode); }
+    printer print(uint16_t mode, uint32_t from, uint32_t end) const {
+      return printer(*this, mode, from, end);
     }
   };
 
index 3786f76869f94b8c1585a3afd97e010466881120..3fcf3310529735b2f18a2c528962a2592691ba0e 100644 (file)
@@ -258,25 +258,26 @@ std::ostream& operator<<(std::ostream& out, const BlueStore::Onode::printer &p)
       << " 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;
+      << " spanning blobs";
   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();
+  // to make printing extents in-sync with blobs
+  uint16_t mode_extent = (mode & (P::PTR | P::NICK)) | P::JUSTID;
+  auto i = map.seek_lextent(p.from);
+  while (i != map.extent_map.end() && i->logical_offset < p.end) {
+    BlueStore::Blob* b = i->blob.get();
+    out << std::endl << i->print(mode_extent);
     if (!visited.contains(b)) {
-      out << b->print(mode) << std::endl;
       visited.insert(b);
     }
+    ++i;
   }
-  // to make printing extents in-sync with blobs
-  uint16_t mode_extent = (mode & (P::PTR | P::NICK)) | P::JUSTID;
-  for (const auto& e : map.extent_map) {
-    out << e.print(mode_extent) << std::endl;
+  for (const auto& i : visited) {
+    out << std::endl << i->print(mode);
   }
   if (mode & P::ATTRS) {
     for (const auto& p : o.onode.attrs) {
-      out << "  attr " << p.first
-        << " len " << p.second.length() << std::endl;
+      out << std::endl << "attr " << p.first << " len " << p.second.length();
     }
   }
   return out;