]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/FreelistManager: audit
authorSage Weil <sage@redhat.com>
Tue, 22 Dec 2015 21:36:42 +0000 (16:36 -0500)
committerSage Weil <sage@redhat.com>
Fri, 1 Jan 2016 18:07:26 +0000 (13:07 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/config_opts.h
src/os/bluestore/FreelistManager.cc
src/os/bluestore/FreelistManager.h
src/test/objectstore/store_test.cc

index e4721d2c21b6bd29cf765d1e1edda062b54a2279..26fae376a5c05c2189f9f28528ae050666b34042 100644 (file)
@@ -890,6 +890,7 @@ OPTION(bluestore_clone_cow, OPT_BOOL, true)  // do copy-on-write for clones
 OPTION(bluestore_debug_misc, OPT_BOOL, false)
 OPTION(bluestore_debug_no_reuse_blocks, OPT_BOOL, false)
 OPTION(bluestore_debug_small_allocations, OPT_INT, 0)
+OPTION(bluestore_debug_freelist, OPT_BOOL, false)
 
 OPTION(kstore_max_ops, OPT_U64, 512)
 OPTION(kstore_max_bytes, OPT_U64, 64*1024*1024)
index fc38188546e6699bc5fcd5268713ca04787f0bb0..b3694fb7bbed35678050bb6617ec4fc425745739 100644 (file)
@@ -87,6 +87,21 @@ void FreelistManager::dump()
   }
 }
 
+void FreelistManager::_audit()
+{
+  assert(lock.is_locked());
+  uint64_t sum = 0;
+  for (auto& p : kv_free) {
+    sum += p.second;
+  }
+  if (total_free != sum) {
+    derr << __func__ << " sum " << sum << " != total_free " << total_free
+        << dendl;
+    derr << kv_free << dendl;
+    assert(0 == "freelistmanager bug");
+  }
+}
+
 int FreelistManager::allocate(
   uint64_t offset, uint64_t length,
   KeyValueDB::Transaction txn)
@@ -155,7 +170,8 @@ int FreelistManager::allocate(
     }
     p->second = newlen;
   }
-
+  if (g_conf->bluestore_debug_freelist)
+    _audit();
   return 0;
 }
 
@@ -221,5 +237,8 @@ int FreelistManager::release(
   dout(20) << __func__ << "  set " << offset << "~" << length << dendl;
 
   kv_free[offset] = length;
+
+  if (g_conf->bluestore_debug_freelist)
+    _audit();
   return 0;
 }
index de75d2b5009c9b6cdcbd502b863bbaf895486074..7993a510e76050836f6c0f7e1ea424b2281b5ef6 100644 (file)
@@ -17,6 +17,8 @@ class FreelistManager {
 
   std::map<uint64_t, uint64_t> kv_free;    ///< mirrors our kv values in the db
 
+  void _audit();
+
 public:
   FreelistManager() :
     lock("FreelistManager::lock"),
index cd1a2157fafb00e4f2ba8467002bfe807573518d..b67000e4f5508a7d636c71f20ac3f4628ce68932 100644 (file)
@@ -3194,6 +3194,7 @@ int main(int argc, char **argv) {
   g_ceph_context->_conf->set_val("bluestore_fsck_on_umount", "true");
   g_ceph_context->_conf->set_val("bluestore_debug_misc", "true");
   g_ceph_context->_conf->set_val("bluestore_debug_small_allocations", "4");
+  g_ceph_context->_conf->set_val("bluestore_debug_freelist", "true");
   g_ceph_context->_conf->set_val(
     "enable_experimental_unrecoverable_data_corrupting_features", "*");
   g_ceph_context->_conf->apply_changes(NULL);