From: xie xingguo Date: Wed, 20 Jan 2016 03:41:50 +0000 (+0800) Subject: BlueStore: fix rename logic X-Git-Tag: v10.0.4~178^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F7283%2Fhead;p=ceph.git BlueStore: fix rename logic Avoid creating a new destination object in advance, which is unnecessary and less efficient. Signed-off-by: xie xingguo --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 5655c48ec0d..20d64800973 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);