From: Josh Durgin Date: Mon, 31 Mar 2014 21:53:31 +0000 (-0700) Subject: librbd: skip zeroes when copying an image X-Git-Tag: v0.67.10~27 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d06137841f9911ce4dc0d9ab9be73a131ede879d;p=ceph.git librbd: skip zeroes when copying an image This is the simple coarse-grained solution, but it works well in common cases like a small base image resized with a bunch of empty space at the end. Finer-grained sparseness can be copied by using rbd {export,import}-diff. Fixes: #6257 Signed-off-by: Josh Durgin (cherry picked from commit 824da2029613a6f4b380b6b2f16a0bd0903f7e3c) --- diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index e70fe22fc56..a32ce946229 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -1948,6 +1948,13 @@ reprotect_and_return_err: return; } assert(m_bl->length() == (size_t)r); + + if (m_bl->is_zero()) { + delete m_bl; + m_throttle->end_op(r); + return; + } + Context *ctx = new C_CopyWrite(m_throttle, m_bl); AioCompletion *comp = aio_create_completion_internal(ctx, rbd_ctx_cb); r = aio_write(m_dest, m_offset, m_bl->length(), m_bl->c_str(), comp);