From e3c3e1e8611c00ff33326cc6e9e3a70a64b26dff Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Wed, 5 May 2021 16:02:24 +0300 Subject: [PATCH] os/bluestore: do not count pinned entries as trimmed ones. Signed-off-by: Igor Fedotov --- src/os/bluestore/BlueStore.cc | 17 +++++++++++------ src/test/objectstore/store_test.cc | 11 ++++++----- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index d701ef4d1c838..036a77b369d62 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -1170,8 +1170,12 @@ void BlueStore::LRUCache::_trim(uint64_t onode_max, uint64_t buffer_max) } // onodes - if (onode_max >= onode_lru.size() || - last_pinned == onode_lru.begin()) { + + if (last_pinned == onode_lru.begin()) { + //start over + last_pinned = onode_lru.end(); + } + if (onode_max >= onode_lru.size()) { return; // don't even try } uint64_t num = onode_lru.size() - onode_max; @@ -1199,7 +1203,6 @@ void BlueStore::LRUCache::_trim(uint64_t onode_max, uint64_t buffer_max) break; } else { p--; - num--; continue; } } @@ -1471,8 +1474,11 @@ void BlueStore::TwoQCache::_trim(uint64_t onode_max, uint64_t buffer_max) } // onodes - if (onode_max >= onode_lru.size() || - last_pinned == onode_lru.begin()) { + if (last_pinned == onode_lru.begin()) { + //start over + last_pinned = onode_lru.end(); + } + if (onode_max >= onode_lru.size()) { return; // don't even try } uint64_t num = onode_lru.size() - onode_max; @@ -1501,7 +1507,6 @@ void BlueStore::TwoQCache::_trim(uint64_t onode_max, uint64_t buffer_max) break; } else { p--; - num--; continue; } } diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index bc70ca91315a6..66d8176bf0917 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -8108,6 +8108,7 @@ void StoreTest::doOnodeCacheTrimTest() { const size_t max_pinned_onodes = 200; const size_t max_cached_onodes = max_pinned_onodes / 2; const PerfCounters* logger = store->get_perf_counters(); + size_t onodes; { ObjectStore::Transaction t; @@ -8132,7 +8133,7 @@ void StoreTest::doOnodeCacheTrimTest() { break; sleep(1); } - ceph_assert(onodes == max_onodes); + ASSERT_EQ(onodes, max_onodes); SetVal(g_conf(), "bluestore_debug_max_cached_onodes", stringify(max_cached_onodes).c_str()); @@ -8144,7 +8145,7 @@ void StoreTest::doOnodeCacheTrimTest() { sleep(1); } onodes = logger->get(l_bluestore_onodes); - ceph_assert(onodes == max_cached_onodes); + ASSERT_EQ(onodes, max_cached_onodes); // revert cache size cap @@ -8171,7 +8172,7 @@ void StoreTest::doOnodeCacheTrimTest() { break; sleep(1); } - ceph_assert(onodes == max_onodes); + ASSERT_EQ(onodes, max_onodes); SetVal(g_conf(), "bluestore_debug_max_cached_onodes", stringify(max_cached_onodes).c_str()); @@ -8183,7 +8184,7 @@ void StoreTest::doOnodeCacheTrimTest() { sleep(1); } onodes = logger->get(l_bluestore_onodes); - ceph_assert(onodes == max_pinned_onodes); + ASSERT_EQ(onodes, max_pinned_onodes); // unpin onodes omap_iterators.resize(0); @@ -8195,7 +8196,7 @@ void StoreTest::doOnodeCacheTrimTest() { sleep(1); } onodes = logger->get(l_bluestore_onodes); - ceph_assert(onodes == max_cached_onodes); + ASSERT_LE(onodes, max_cached_onodes); { ObjectStore::Transaction t; -- 2.39.5