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

Fixes: #14433
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/kstore/KStore.cc

index 3f340c37dacbedef0fd3ca7649c4996bad197c8e..d93d5f01bb3a069874cf8aca311019c511e87e65 100644 (file)
@@ -3640,13 +3640,13 @@ int KStore::_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, newo);
     if (r < 0)
-      return r;
+      goto out;
   }
 
   txc->t->rmkey(PREFIX_OBJ, oldo->key);