]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: audit LRU at various points
authorSage Weil <sage@redhat.com>
Thu, 2 Jun 2016 17:56:46 +0000 (13:56 -0400)
committerSage Weil <sage@redhat.com>
Fri, 3 Jun 2016 15:00:30 +0000 (11:00 -0400)
This is purely for debugging.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 93b975bbbf467a8da84e1f975cb4a5b9bdc58841..5fbae40d998102d6311f6dee04f2827e3225f115 100644 (file)
@@ -453,6 +453,7 @@ ostream& operator<<(ostream& out, const BlueStore::Buffer& b)
 
 void BlueStore::BufferCache::trim(uint64_t keep)
 {
+  audit_lru();
   lru_list_t::iterator i = lru.end();
   if (size) {
     assert(i != lru.begin());
@@ -478,6 +479,26 @@ void BlueStore::BufferCache::trim(uint64_t keep)
   }
 }
 
+#ifdef DEBUG_CACHE
+void BlueStore::BufferCache::audit_lru()
+{
+  if (true) {
+    uint64_t s = 0;
+    for (auto i = lru.begin(); i != lru.end(); ++i) {
+      s += i->length;
+    }
+    if (s != size) {
+      derr << __func__ << " size " << size << " actual " << s << dendl;
+      for (auto i = lru.begin(); i != lru.end(); ++i) {
+       derr << __func__ << " " << *i << dendl;
+      }
+      assert(s == size);
+    }
+    dout(20) << __func__ << " size " << size << " ok" << dendl;
+  }
+}
+#endif
+
 // BufferSpace
 
 #undef dout_prefix
@@ -485,6 +506,7 @@ void BlueStore::BufferCache::trim(uint64_t keep)
 
 void BlueStore::BufferSpace::discard(uint64_t offset, uint64_t length)
 {
+  cache->audit_lru();
   auto i = _data_lower_bound(offset);
   uint64_t end = offset + length;
   while (i != buffer_map.end()) {
@@ -506,6 +528,7 @@ void BlueStore::BufferSpace::discard(uint64_t offset, uint64_t length)
        }
        cache->size -= b->length - front;
        b->truncate(front);
+       cache->audit_lru();
        return;
       } else {
        // drop tail
@@ -531,6 +554,7 @@ void BlueStore::BufferSpace::discard(uint64_t offset, uint64_t length)
       _add_buffer(new Buffer(this, b->state, b->seq, end, keep));
       _rm_buffer(i);
     }
+    cache->audit_lru();
     return;
   }
 }
@@ -600,6 +624,7 @@ void BlueStore::BufferSpace::finish_write(uint64_t seq)
       ++i;
     }
   }
+  cache->audit_lru();
 }
 
 
index 6026d9d66eac20a60cdcae165658187e0ebd1b5b..7e909528e4abc96257eb07e770bab5704191cf44 100644 (file)
@@ -40,6 +40,8 @@ class Allocator;
 class FreelistManager;
 class BlueFS;
 
+//#define DEBUG_CACHE
+
 enum {
   l_bluestore_first = 732430,
   l_bluestore_state_prepare_lat,
@@ -192,6 +194,12 @@ public:
     uint64_t size = 0;
 
     void trim(uint64_t keep);
+
+#ifdef DEBUG_CACHE
+    void audit_lru();
+#else
+    void audit_lru() { /* no-op */ }
+#endif
   };
 
   /// map logical extent range (object) onto buffers
@@ -216,6 +224,7 @@ public:
       if (b->is_writing()) {
        writing.push_back(*b);
       }
+      cache->audit_lru();
     }
     void _rm_buffer(Buffer *b) {
       _rm_buffer(buffer_map.find(b->offset));
@@ -227,6 +236,7 @@ public:
        writing.erase(writing.iterator_to(*p->second));
       }
       buffer_map.erase(p);
+      cache->audit_lru();
     }
 
     /// move to top of lru