]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: do not count pinned entries as trimmed ones. 41173/head
authorIgor Fedotov <ifedotov@suse.com>
Wed, 5 May 2021 13:02:24 +0000 (16:02 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Wed, 5 May 2021 13:02:24 +0000 (16:02 +0300)
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
src/os/bluestore/BlueStore.cc
src/test/objectstore/store_test.cc

index d701ef4d1c8381455c1f56c983c189b2fd8ccf5b..036a77b369d62632156d0a1953bfb0816a0bdf51 100644 (file)
@@ -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;
       }
     }
index bc70ca91315a653f5ccf4bfaa99fea788955cd8d..66d8176bf0917d9bc1cae1e8104d3459ed9fc423 100644 (file)
@@ -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;