From a2dafa172b7b78cada68d6de5da426778fc94654 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 2 Jun 2016 13:56:46 -0400 Subject: [PATCH] os/bluestore: audit LRU at various points This is purely for debugging. Signed-off-by: Sage Weil --- src/os/bluestore/BlueStore.cc | 25 +++++++++++++++++++++++++ src/os/bluestore/BlueStore.h | 10 ++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 93b975bbbf467..5fbae40d99810 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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(); } diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 6026d9d66eac2..7e909528e4abc 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -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 -- 2.39.5