From a411f58713d3f98fec53ea48dc5805529314458a Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 6 Dec 2016 14:32:52 -0500 Subject: [PATCH] os/bluestore: clone_range of len 0 creates but does not size object This mimics, roughly, open(..., O_WRONLY|O_CREAT, ...) seek(...) if (len > 0) write(...) Signed-off-by: Sage Weil --- src/os/bluestore/BlueStore.cc | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index addc5c9bfd31..212abc4f7821 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -8751,17 +8751,19 @@ int BlueStore::_clone_range(TransContext *txc, newo->exists = true; _assign_nid(txc, newo); - if (g_conf->bluestore_clone_cow) { - _do_zero(txc, c, newo, dstoff, length); - _do_clone_range(txc, c, oldo, newo, srcoff, length, dstoff); - } else { - bufferlist bl; - r = _do_read(c.get(), oldo, srcoff, length, bl, 0); - if (r < 0) - goto out; - r = _do_write(txc, c, newo, dstoff, bl.length(), bl, 0); - if (r < 0) - goto out; + if (length > 0) { + if (g_conf->bluestore_clone_cow) { + _do_zero(txc, c, newo, dstoff, length); + _do_clone_range(txc, c, oldo, newo, srcoff, length, dstoff); + } else { + bufferlist bl; + r = _do_read(c.get(), oldo, srcoff, length, bl, 0); + if (r < 0) + goto out; + r = _do_write(txc, c, newo, dstoff, bl.length(), bl, 0); + if (r < 0) + goto out; + } } txc->write_onode(newo); -- 2.47.3