]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: prevent rename src from getting trimmed from lru
authorSage Weil <sage@redhat.com>
Wed, 30 Mar 2016 14:26:18 +0000 (10:26 -0400)
committerSage Weil <sage@redhat.com>
Wed, 30 Mar 2016 15:23:15 +0000 (11:23 -0400)
We were putting it at the end of the LRU *and* not holding a reference.

Fix by letting oldo carry a ref to the Onode.  This avoids a subsequent
lookup and also prevents it from getting trimmed.

Note that we could also put it at the front of the LRU, but given that it
is the rename source, I'm not sure that's appropriate.  For example,
temp recovery objects get renamed into place and we don't want to keep
negative onodes for those around.

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

index 98e9cc31ecb49d662db6b1505a3a0b7580022613..07652b247ef82dd278fc8ec6f33aa8206c2e7202 100644 (file)
@@ -508,8 +508,9 @@ void BlueStore::OnodeHashLRU::clear()
   onode_map.clear();
 }
 
-void BlueStore::OnodeHashLRU::rename(const ghobject_t& old_oid,
-                                   const ghobject_t& new_oid)
+void BlueStore::OnodeHashLRU::rename(OnodeRef& oldo,
+                                    const ghobject_t& old_oid,
+                                    const ghobject_t& new_oid)
 {
   std::lock_guard<std::mutex> l(lock);
   dout(30) << __func__ << " " << old_oid << " -> " << new_oid << dendl;
@@ -528,7 +529,8 @@ void BlueStore::OnodeHashLRU::rename(const ghobject_t& old_oid,
   OnodeRef o = po->second;
 
   // install a non-existent onode at old location
-  po->second.reset(new Onode(old_oid, o->key));
+  oldo.reset(new Onode(old_oid, o->key));
+  po->second = oldo;
   lru.push_back(*po->second);
 
   // add at new position and fix oid, key
@@ -6504,8 +6506,10 @@ int BlueStore::_rename(TransContext *txc,
   txc->t->rmkey(PREFIX_OBJ, oldo->key);
   txc->write_onode(oldo);
   newo = oldo;
-  oldo.reset(NULL);
-  c->onode_map.rename(old_oid, new_oid);  // this adjusts oldo->{oid,key}
+
+  // this adjusts oldo->{oid,key}, and reset oldo to a fresh empty
+  // Onode in the old slot
+  c->onode_map.rename(oldo, old_oid, new_oid);
   r = 0;
 
  out:
index c311951cedd801528fde1dc0c48690a7f1476d2c..b32279c53173959bb0006d550a71a73adc758643 100644 (file)
@@ -181,7 +181,7 @@ public:
     void add(const ghobject_t& oid, OnodeRef o);
     void _touch(OnodeRef o);
     OnodeRef lookup(const ghobject_t& o);
-    void rename(const ghobject_t& old_oid, const ghobject_t& new_oid);
+    void rename(OnodeRef& o, const ghobject_t& old_oid, const ghobject_t& new_oid);
     void clear();
     bool get_next(const ghobject_t& after, pair<ghobject_t,OnodeRef> *next);
     int trim(int max=-1);