From d89df9dfe8e441d57943b96915568cc281fbb264 Mon Sep 17 00:00:00 2001 From: Ramesh Chander Date: Sat, 3 Dec 2016 22:24:31 -0800 Subject: [PATCH] bitmap allocator dump functionality Signed-off-by: Ramesh Chander --- src/os/bluestore/BitAllocator.cc | 48 ++++++++++++++++++++++++++++- src/os/bluestore/BitAllocator.h | 5 +++ src/os/bluestore/BitMapAllocator.cc | 5 +++ 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/os/bluestore/BitAllocator.cc b/src/os/bluestore/BitAllocator.cc index 308ea08ee05b6..1c20b1187b012 100644 --- a/src/os/bluestore/BitAllocator.cc +++ b/src/os/bluestore/BitAllocator.cc @@ -18,11 +18,16 @@ * of the interfaces defined in BitMapArea. */ -#include "common/dout.h" #include "BitAllocator.h" #include +#include "bluestore_types.h" +#include "common/debug.h" #include +#define dout_subsys ceph_subsys_bluestore +#undef dout_prefix +#define dout_prefix *_dout << "bitalloc:" + MEMPOOL_DEFINE_OBJECT_FACTORY(BitMapArea, BitMapArea, bluestore_alloc); MEMPOOL_DEFINE_OBJECT_FACTORY(BitMapAreaIN, BitMapAreaIN, bluestore_alloc); MEMPOOL_DEFINE_OBJECT_FACTORY(BitMapAreaLeaf, BitMapAreaLeaf, bluestore_alloc); @@ -340,6 +345,11 @@ int BmapEntry::find_any_free_bits(int start_offset, int64_t num_blocks, return allocated; } +void BmapEntry::dump_state(int& count) +{ + dout(0) << count << ":: 0x" << std::hex << m_bits << dendl; +} + /* * Zone related functions. */ @@ -631,6 +641,22 @@ int64_t BitMapZone::alloc_blocks_dis(int64_t num_blocks, return allocated; } +void BitMapZone::dump_state(int& count) +{ + BmapEntry *bmap = NULL; + int bmap_idx = 0; + BitMapEntityIter iter = BitMapEntityIter( + m_bmap_list, 0); + dout(0) << __func__ << " zone " << count << " dump start " << dendl; + while ((bmap = (BmapEntry *) iter.next())) { + bmap->dump_state(bmap_idx); + bmap_idx++; + } + dout(0) << __func__ << " zone " << count << " dump end " << dendl; + count++; +} + + /* * BitMapArea Leaf and non-Leaf functions. */ @@ -1060,6 +1086,18 @@ void BitMapAreaIN::free_blocks(int64_t start_block, int64_t num_blocks) unlock(); } +void BitMapAreaIN::dump_state(int& count) +{ + BitMapArea *child = NULL; + + BmapEntityListIter iter = BmapEntityListIter( + m_child_list, 0, false); + + while ((child = (BitMapArea *) iter.next())) { + child->dump_state(count); + } +} + /* * BitMapArea Leaf */ @@ -1669,3 +1707,11 @@ void BitAllocator::free_blocks_dis(int64_t num_blocks, ExtentList *block_list) alloc_assert(get_used_blocks() >= 0); unlock(); } + +void BitAllocator::dump() +{ + int count = 0; + serial_lock(); + dump_state(count); + serial_unlock(); +} diff --git a/src/os/bluestore/BitAllocator.h b/src/os/bluestore/BitAllocator.h index 985a1136e8bbc..1c9c2bdc4bc6b 100644 --- a/src/os/bluestore/BitAllocator.h +++ b/src/os/bluestore/BitAllocator.h @@ -180,6 +180,7 @@ public: ExtentList *alloc_list, int64_t block_offset, int64_t *scanned); + void dump_state(int& count); ~BmapEntry(); }; @@ -264,6 +265,7 @@ public: int64_t get_index(); int64_t get_level(); bmap_area_type_t get_type(); + virtual void dump_state(int& count) = 0; virtual ~BitMapArea() { } }; @@ -381,6 +383,7 @@ public: void set_blocks_used(int64_t start_block, int64_t num_blocks); void free_blocks(int64_t start_block, int64_t num_blocks); + void dump_state(int& count); }; class BitMapAreaIN: public BitMapArea{ @@ -457,6 +460,7 @@ public: virtual void free_blocks_int(int64_t start_block, int64_t num_blocks); virtual void free_blocks(int64_t start_block, int64_t num_blocks); + void dump_state(int& count); }; class BitMapAreaLeaf: public BitMapAreaIN{ @@ -562,6 +566,7 @@ public: BitAllocatorStats *get_stats() { return m_stats; } + void dump(); }; #endif //End of file diff --git a/src/os/bluestore/BitMapAllocator.cc b/src/os/bluestore/BitMapAllocator.cc index 7992c8f30d4f6..3aac6d81a71b9 100644 --- a/src/os/bluestore/BitMapAllocator.cc +++ b/src/os/bluestore/BitMapAllocator.cc @@ -255,6 +255,11 @@ uint64_t BitMapAllocator::get_free() void BitMapAllocator::dump() { std::lock_guard l(m_lock); + + dout(0) << __func__ << " instance " << (uint64_t) this + << " Allocator Status dump : " << dendl; + + m_bit_alloc->dump(); dout(0) << __func__ << " instance " << (uint64_t) this << " committing: " << m_committing.num_intervals() << " extents" << dendl; -- 2.39.5