From: Adam Kupczyk Date: Fri, 14 Jun 2024 10:54:01 +0000 (+0000) Subject: os/bluestore: Add ability to partially print Onode X-Git-Tag: v20.0.0~1286^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c4fa859535b2965fbb16ead7e81ec16841c87e1e;p=ceph.git os/bluestore: Add ability to partially print Onode 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 --- diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index cad3c86b0a94..87fe96ccc988 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1451,14 +1451,18 @@ public: void finish_write(TransContext* txc, uint32_t offset, uint32_t length); struct printer : public BlueStore::printer { - const Onode& onode; + 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); } }; diff --git a/src/os/bluestore/BlueStore_debug.cc b/src/os/bluestore/BlueStore_debug.cc index 3786f76869f9..3fcf33105297 100644 --- a/src/os/bluestore/BlueStore_debug.cc +++ b/src/os/bluestore/BlueStore_debug.cc @@ -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 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;