]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/bluestore: make onode lru private
authorSage Weil <sage@redhat.com>
Fri, 10 Jun 2016 12:33:42 +0000 (08:33 -0400)
committerSage Weil <sage@redhat.com>
Wed, 22 Jun 2016 15:28:40 +0000 (11:28 -0400)
Add cache->onode_lru.push_back(*po->second).  Make LRU private.

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

index 5ef8ef9be02e80c907838332b89437565d631daf..f6ada30d9ace87d321f88333e26bd42cf9ced973 100644 (file)
@@ -737,7 +737,7 @@ void BlueStore::OnodeSpace::add(const ghobject_t& oid, OnodeRef o)
   dout(30) << __func__ << " " << oid << " " << o << dendl;
   assert(onode_map.count(oid) == 0);
   onode_map[oid] = o;
-  cache->onode_lru.push_front(*o);
+  cache->_add_onode(o);
 }
 
 BlueStore::OnodeRef BlueStore::OnodeSpace::lookup(const ghobject_t& oid)
@@ -759,8 +759,7 @@ void BlueStore::OnodeSpace::clear()
   std::lock_guard<std::mutex> l(cache->lock);
   dout(10) << __func__ << dendl;
   for (auto &p : onode_map) {
-    auto q = cache->onode_lru.iterator_to(*p.second);
-    cache->onode_lru.erase(q);
+    cache->_rm_onode(p.second);
 
     // clear blobs and their buffers too, while we have cache->lock
     p.second->blob_map._clear();
@@ -782,8 +781,7 @@ void BlueStore::OnodeSpace::rename(OnodeRef& oldo,
   assert(po != onode_map.end());
   if (pn != onode_map.end()) {
     dout(30) << __func__ << "  removing target " << pn->second << dendl;
-    auto p = cache->onode_lru.iterator_to(*pn->second);
-    cache->onode_lru.erase(p);
+    cache->_rm_onode(pn->second);
     onode_map.erase(pn);
   }
   OnodeRef o = po->second;
@@ -791,7 +789,7 @@ void BlueStore::OnodeSpace::rename(OnodeRef& oldo,
   // install a non-existent onode at old location
   oldo.reset(new Onode(this, old_oid, o->key));
   po->second = oldo;
-  cache->onode_lru.push_back(*po->second);
+  cache->_add_onode(po->second);
 
   // add at new position and fix oid, key
   onode_map.insert(make_pair(new_oid, o));
index 4bfe89c37d68a3894ee07e5a38af53b74363975f..ee4ab548652e4f129b0495eb6d3a044097dc8795 100644 (file)
@@ -494,24 +494,34 @@ public:
 
   /// a cache (shard) of onodes and buffers
   struct Cache {
-    typedef boost::intrusive::list<
-      Buffer,
-      boost::intrusive::member_hook<
-       Buffer,
-       boost::intrusive::list_member_hook<>,
-       &Buffer::lru_item> > buffer_lru_list_t;
+  private:
     typedef boost::intrusive::list<
       Onode,
       boost::intrusive::member_hook<
         Onode,
        boost::intrusive::list_member_hook<>,
        &Onode::lru_item> > onode_lru_list_t;
+    onode_lru_list_t onode_lru;
+
+  public:
+    typedef boost::intrusive::list<
+      Buffer,
+      boost::intrusive::member_hook<
+       Buffer,
+       boost::intrusive::list_member_hook<>,
+       &Buffer::lru_item> > buffer_lru_list_t;
 
     std::mutex lock;                ///< protect lru and other structures
     buffer_lru_list_t buffer_lru;
     uint64_t buffer_size = 0;
-    onode_lru_list_t onode_lru;
 
+    void _add_onode(OnodeRef& o) {
+        onode_lru.push_front(*o);
+    }
+    void _rm_onode(OnodeRef& o) {
+      auto q = onode_lru.iterator_to(*o);
+      onode_lru.erase(q);
+    }
     void _touch_onode(OnodeRef& o);
 
     void _touch_buffer(Buffer *b) {