kstore: fix dest onode process logic of clone

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
This commit is contained in:
xie xingguo 2016-01-19 18:27:00 +08:00
parent 8065b8ab34
commit 7ce6d068a1

View File

@ -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;