]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ObjectCacher: add debug function to check BufferHead consistency
authorJosh Durgin <josh.durgin@inktank.com>
Fri, 16 Nov 2012 01:32:08 +0000 (17:32 -0800)
committerJosh Durgin <josh.durgin@inktank.com>
Fri, 16 Nov 2012 23:22:38 +0000 (15:22 -0800)
This isn't called because it's potentially expensive, but calling it
in various places can help future debugging.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
src/osdc/ObjectCacher.cc
src/osdc/ObjectCacher.h

index 16020e76d5c057dc16bce065dc3987c138569d40..c3e83c32e6c6faaaefd393261f94f2cd2f89d550 100644 (file)
@@ -264,6 +264,39 @@ int ObjectCacher::Object::map_read(OSDRead *rd,
   return 0;
 }
 
+void ObjectCacher::Object::audit_buffers()
+{
+  loff_t offset = 0;
+  for (map<loff_t, BufferHead*>::const_iterator it = data.begin();
+       it != data.end(); ++it) {
+    if (it->first != it->second->start()) {
+      lderr(oc->cct) << "AUDIT FAILURE: map position " << it->first
+                    << " does not match bh start position: "
+                    << *it->second << dendl;
+      assert(it->first == it->second->start());
+    }
+    if (it->first < offset) {
+      lderr(oc->cct) << "AUDIT FAILURE: " << it->first << " " << *it->second
+                    << " overlaps with previous bh " << *((--it)->second)
+                    << dendl;
+      assert(it->first >= offset);
+    }
+    BufferHead *bh = it->second;
+    map<loff_t, list<Context*> >::const_iterator w_it;
+    for (w_it = bh->waitfor_read.begin();
+        w_it != bh->waitfor_read.end(); ++w_it) {
+      if (w_it->first < bh->start() ||
+           w_it->first >= bh->start() + bh->length()) {
+       lderr(oc->cct) << "AUDIT FAILURE: waiter at " << w_it->first
+                      << " is not within bh " << *bh << dendl;
+       assert(w_it->first >= bh->start());
+       assert(w_it->first < bh->start() + bh->length());
+      }
+    }
+    offset = it->first + it->second->length();
+  }
+}
+
 /*
  * map a range of extents on an object's buffer cache.
  * - combine any bh's we're writing into one
index 5e8417a563e196c337dd46862a1cda655e3d5283..b431463cdee5c7d6caf24c9c3a7b4498d1df17c1 100644 (file)
@@ -225,6 +225,14 @@ class ObjectCacher {
       return false;
     }
 
+    /**
+     * Check buffers and waiters for consistency
+     * - no overlapping buffers
+     * - index in map matches BH
+     * - waiters fall within BH
+     */
+    void audit_buffers();
+
     /**
      * find first buffer that includes or follows an offset
      *