]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
BlueStore: fix rename logic 7283/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Wed, 20 Jan 2016 03:41:50 +0000 (11:41 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Wed, 20 Jan 2016 05:38:58 +0000 (13:38 +0800)
Avoid creating a new destination object in advance, which is unnecessary and less efficient.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueStore.cc

index 5655c48ec0d1de151bc1bce166718c51857e2210..20d6480097378adf2eb0367b3bae70b093e8787d 100644 (file)
@@ -6123,13 +6123,13 @@ int BlueStore::_rename(TransContext *txc,
     r = -ENOENT;
     goto out;
   }
-  newo = c->get_onode(new_oid, true);
-  assert(newo);
 
-  if (newo->exists) {
+  newo = c->get_onode(new_oid, false);
+  if (newo && newo->exists) {
+    // destination object already exists, remove it first
     r = _do_remove(txc, c, newo);
     if (r < 0)
-      return r;
+      goto out;
   }
 
   txc->t->rmkey(PREFIX_OBJ, oldo->key);