]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: simplify buffer eviction logic of LRUCache
authorxie xingguo <xie.xingguo@zte.com.cn>
Sat, 2 Jul 2016 08:29:41 +0000 (16:29 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Tue, 5 Jul 2016 02:10:53 +0000 (10:10 +0800)
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueStore.cc

index 3ec1533bfb746ae3f17a07d75dfd0d8ceb6e1be5..8c2d5b12f49b73f4fdc94ab8d9da8064592028da 100644 (file)
@@ -507,20 +507,17 @@ void BlueStore::LRUCache::trim(uint64_t onode_max, uint64_t buffer_max)
   _audit("trim start");
 
   // buffers
-  auto i = buffer_lru.end();
-  if (buffer_size) {
-    assert(i != buffer_lru.begin());
-    --i;
-  }
   while (buffer_size > buffer_max) {
+    auto i = buffer_lru.rbegin();
+    if (i == buffer_lru.rend()) {
+      // stop if buffer_lru is now empty
+      break;
+    }
+
     Buffer *b = &*i;
     assert(b->is_clean());
-    auto p = b->space->buffer_map.find(b->offset);
-    if (i != buffer_lru.begin()) {
-      --i;
-    }
     dout(20) << __func__ << " rm " << *b << dendl;
-    b->space->_rm_buffer(p);
+    b->space->_rm_buffer(b);
   }
 
   // onodes