From: Sage Weil Date: Mon, 21 Mar 2016 21:00:52 +0000 (-0400) Subject: os/bluestore: trim onode_map when adding new items X-Git-Tag: v10.1.1~28^2~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=91faa7ed18ca85cc25fa1137632bf58d2648eac5;p=ceph.git os/bluestore: trim onode_map when adding new items This ensures we maintain the cache size even for read workloads. Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 5708174beb72..ac99ae83c1db 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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 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) diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 404c9579ed8f..4cd7375e5965 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -185,6 +185,7 @@ public: void clear(); bool get_next(const ghobject_t& after, pair *next); int trim(int max=-1); + int _trim(int max); }; struct Collection : public CollectionImpl {