]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: trim onode_map when adding new items
authorSage Weil <sage@redhat.com>
Mon, 21 Mar 2016 21:00:52 +0000 (17:00 -0400)
committerSage Weil <sage@redhat.com>
Wed, 30 Mar 2016 15:23:15 +0000 (11:23 -0400)
This ensures we maintain the cache size even for read workloads.

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

index 5708174beb72d2eb81f72e948ea340a9ce123df4..ac99ae83c1db82abc72b68e009fc08a351128702 100644 (file)
@@ -507,6 +507,7 @@ void BlueStore::OnodeHashLRU::add(const ghobject_t& oid, OnodeRef o)
   assert(onode_map.count(oid) == 0);
   onode_map[oid] = o;
   lru.push_front(*o);
+  _trim(max_size);
 }
 
 BlueStore::OnodeRef BlueStore::OnodeHashLRU::lookup(const ghobject_t& oid)
@@ -594,8 +595,15 @@ bool BlueStore::OnodeHashLRU::get_next(
 int BlueStore::OnodeHashLRU::trim(int max)
 {
   std::lock_guard<std::mutex> l(lock);
-  dout(20) << __func__ << " max " << max
-          << " size " << onode_map.size() << dendl;
+  if (max < 0) {
+    max = max_size;
+  }
+  return _trim(max);
+}
+
+int BlueStore::OnodeHashLRU::_trim(int max)
+{
+  dout(20) << __func__ << " max " << max << " size " << onode_map.size() << dendl;
   int trimmed = 0;
   int num = onode_map.size() - max;
   if (onode_map.size() == 0 || num <= 0)
index 404c9579ed8faf1f5d0cfb07d3f9dcc3a40fc149..4cd7375e5965fdebdade9d93c3b7feb4a7de09f1 100644 (file)
@@ -185,6 +185,7 @@ public:
     void clear();
     bool get_next(const ghobject_t& after, pair<ghobject_t,OnodeRef> *next);
     int trim(int max=-1);
+    int _trim(int max);
   };
 
   struct Collection : public CollectionImpl {