From 0cbc76be5ae7c831a095d283576b0a76443e5818 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Wed, 20 Jan 2016 11:41:50 +0800 Subject: [PATCH] BlueStore: fix rename logic Avoid creating a new destination object in advance, which is unnecessary and less efficient. Signed-off-by: xie xingguo --- src/os/bluestore/BlueStore.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 5655c48ec0d1d..20d6480097378 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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); -- 2.39.5