]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: fix potential access violation during rename
authorxie xingguo <xie.xingguo@zte.com.cn>
Fri, 9 Sep 2016 10:52:20 +0000 (18:52 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Sat, 10 Sep 2016 00:39:23 +0000 (08:39 +0800)
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 025d60d1bfb6ab2f327c2ff86a729e1442ec91c6..829fb3350cd7fd89dad725da2f8d7139bc786c48 100644 (file)
@@ -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<std::mutex> 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<bool(OnodeRef)> 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:
index e50f899b81988c202293d0e04aec29cc9ae5423a..16dad8409f88246476476f73ba94fc95585826d0 100644 (file)
@@ -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