From f2f0e7d75d9e367cef679c0762f9f5be42d7e7e3 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 10 Mar 2016 13:44:18 -0500 Subject: [PATCH] os/bluestore: fix _rename Update the *target* object ref in ovec. Signed-off-by: Sage Weil --- src/os/bluestore/BlueStore.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 078de2998b4..f73b1cda770 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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; -- 2.47.3