From: Sage Weil Date: Wed, 30 Mar 2016 14:26:18 +0000 (-0400) Subject: os/bluestore: prevent rename src from getting trimmed from lru X-Git-Tag: v10.1.1~28^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dcc5cead10222e1f90cc95f98ba8fb2f6c3af250;p=ceph.git os/bluestore: prevent rename src from getting trimmed from lru 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 --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 98e9cc31ecb49..07652b247ef82 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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 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: diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index c311951cedd80..b32279c531739 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -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 *next); int trim(int max=-1);