diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 2d55127f55c0a..8e3e042ec666f 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -8152,15 +8152,19 @@ int BlueStore::_clone_range(TransContext *txc, newo->exists = true; _assign_nid(txc, newo); - 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 (g_conf->bluestore_clone_cow) { + _do_zero(txc, c, newo, dstoff, length); + _do_clone_range(txc, c, oldo, newo, srcoff, length, dstoff); + } else { + 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); - r = 0; out: