From: xie xingguo Date: Fri, 9 Sep 2016 10:52:20 +0000 (+0800) Subject: os/bluestore: fix potential access violation during rename X-Git-Tag: v11.0.1~261^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a4f678933247fb53c3c366e11b98d0f56c33a8cb;p=ceph.git os/bluestore: fix potential access violation during rename Signed-off-by: xie xingguo --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 025d60d1bfb6..829fb3350cd7 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -1105,7 +1105,8 @@ void BlueStore::OnodeSpace::clear() void BlueStore::OnodeSpace::rename(OnodeRef& oldo, const ghobject_t& old_oid, - const ghobject_t& new_oid) + const ghobject_t& new_oid, + const string& new_okey) { std::lock_guard l(cache->lock); dout(30) << __func__ << " " << old_oid << " -> " << new_oid << dendl; @@ -1131,7 +1132,7 @@ void BlueStore::OnodeSpace::rename(OnodeRef& oldo, onode_map.insert(make_pair(new_oid, o)); cache->_touch_onode(o); o->oid = new_oid; - get_object_key(new_oid, &o->key); + o->key = new_okey; } bool BlueStore::OnodeSpace::map_any(std::function f) @@ -8053,6 +8054,7 @@ int BlueStore::_rename(TransContext *txc, << new_oid << dendl; int r; ghobject_t old_oid = oldo->oid; + string new_okey; if (newo) { if (newo->exists) { @@ -8066,9 +8068,10 @@ int BlueStore::_rename(TransContext *txc, // rewrite shards oldo->extent_map.fault_range(db, 0, oldo->onode.size); + get_object_key(new_oid, &new_okey); for (auto &s : oldo->extent_map.shards) { txc->t->rmkey(PREFIX_OBJ, s.key); - get_extent_shard_key(newo->key, s.offset, &s.key); + get_extent_shard_key(new_okey, s.offset, &s.key); s.dirty = true; } @@ -8077,7 +8080,7 @@ int BlueStore::_rename(TransContext *txc, // 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); + c->onode_map.rename(oldo, old_oid, new_oid, new_okey); r = 0; out: diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index e50f899b8198..16dad8409f88 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -840,7 +840,8 @@ public: void add(const ghobject_t& oid, OnodeRef o); OnodeRef lookup(const ghobject_t& o); void rename(OnodeRef& o, const ghobject_t& old_oid, - const ghobject_t& new_oid); + const ghobject_t& new_oid, + const string& new_okey); void clear(); /// return true if f true for any item