From: xie xingguo Date: Tue, 19 Jan 2016 10:27:00 +0000 (+0800) Subject: kstore: fix dest onode process logic of clone X-Git-Tag: v10.0.4~178^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7ce6d068a1fd666940068df702f29bdd5ee8faf0;p=ceph.git kstore: fix dest onode process logic of clone Signed-off-by: xie xingguo --- diff --git a/src/os/kstore/KStore.cc b/src/os/kstore/KStore.cc index 7d7960238db6..68d6e9298432 100644 --- a/src/os/kstore/KStore.cc +++ b/src/os/kstore/KStore.cc @@ -3515,20 +3515,23 @@ int KStore::_clone(TransContext *txc, r = -ENOENT; goto out; } - newo = c->get_onode(new_oid, true); - assert(newo); - newo->exists = true; - _assign_nid(txc, newo); + + newo = c->get_onode(new_oid, false); + if (newo) { + // already exist, truncate any old data + r = _do_truncate(txc, newo, 0); + if (r < 0) + goto out; + } else { + // does not exist, create it + newo = c->get_onode(new_oid, true); + _assign_nid(txc, newo); + } r = _do_read(oldo, 0, oldo->onode.size, bl, 0); if (r < 0) goto out; - // truncate any old data - r = _do_truncate(txc, newo, 0); - if (r < 0) - goto out; - r = _do_write(txc, newo, 0, oldo->onode.size, bl, 0); newo->onode.attrs = oldo->onode.attrs;