]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: fix _rename
authorSage Weil <sage@redhat.com>
Thu, 10 Mar 2016 18:44:18 +0000 (13:44 -0500)
committerSage Weil <sage@redhat.com>
Fri, 11 Mar 2016 15:41:38 +0000 (10:41 -0500)
Update the *target* object ref in ovec.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueStore.cc

index 078de2998b4988cc87f2c4eb961db9f63e04168d..f73b1cda770b650afa12f7b597c745c210116b63 100644 (file)
@@ -4486,9 +4486,11 @@ void BlueStore::_txc_add_transaction(TransContext *txc, Transaction *t)
       {
        assert(op->cid == op->dest_cid);
        const ghobject_t& noid = i.get_oid(op->dest_oid);
-       OnodeRef no = c->get_onode(noid, false);
+       OnodeRef& no = ovec[op->dest_oid];
+       if (!no) {
+         no = c->get_onode(noid, false);
+       }
        r = _rename(txc, c, o, no, noid);
-       o.reset();
       }
       break;
 
@@ -4499,7 +4501,6 @@ void BlueStore::_txc_add_transaction(TransContext *txc, Transaction *t)
        r = _rename(txc, c, o, no, noid);
        if (r == -ENOENT)
          r = 0;
-       o.reset();
       }
       break;
 
@@ -6334,15 +6335,18 @@ int BlueStore::_rename(TransContext *txc,
   int r;
   ghobject_t old_oid = oldo->oid;
 
-  if (newo && newo->exists) {
-    // destination object already exists, remove it first
-    r = _do_remove(txc, c, newo);
-    if (r < 0)
+  if (newo) {
+    if (newo->exists) {
+      r = -EEXIST;
       goto out;
+    }
+    assert(txc->onodes.count(newo) == 0);
   }
 
   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}
   r = 0;