]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
bitmap allocator dump functionality 12298/head
authorRamesh Chander <Ramesh.Chander@sandisk.com>
Sun, 4 Dec 2016 06:24:31 +0000 (22:24 -0800)
committerRamesh Chander <Ramesh.Chander@sandisk.com>
Mon, 5 Dec 2016 14:30:11 +0000 (06:30 -0800)
Signed-off-by: Ramesh Chander <Ramesh.Chander@sandisk.com>
src/os/bluestore/BitAllocator.cc
src/os/bluestore/BitAllocator.h
src/os/bluestore/BitMapAllocator.cc

index 308ea08ee05b6802c201f0eb421b3e701d9ca2ac..1c20b1187b012f3687bd51393d774fb1c5c17b00 100644 (file)
  * of the interfaces defined in BitMapArea.
  */
 
-#include "common/dout.h"
 #include "BitAllocator.h"
 #include <assert.h>
+#include "bluestore_types.h"
+#include "common/debug.h"
 #include <math.h>
 
+#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 <BmapEntry> iter = BitMapEntityIter<BmapEntry>(
+          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(); 
+}
index 985a1136e8bbc59e03c63cf92e0b40b951d33d1e..1c9c2bdc4bc6b6a9f314dc334852593b8ee76cad 100644 (file)
@@ -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
index 7992c8f30d4f62c977760d71fd50de784cb46117..3aac6d81a71b93cf96bfc76868526c71a2164be4 100644 (file)
@@ -255,6 +255,11 @@ uint64_t BitMapAllocator::get_free()
 void BitMapAllocator::dump()
 {
   std::lock_guard<std::mutex> 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;