]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: skip zeroes when copying an image 1575/head
authorJosh Durgin <josh.durgin@inktank.com>
Mon, 31 Mar 2014 21:53:31 +0000 (14:53 -0700)
committerJosh Durgin <josh.durgin@inktank.com>
Mon, 31 Mar 2014 22:04:28 +0000 (15:04 -0700)
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 <josh.durgin@inktank.com>
src/librbd/internal.cc

index 61e910b07ed28e464a52c7cb09de138e5fe29adc..8056fab587b62f772104dd4efe8918e72161ec40 100644 (file)
@@ -1955,6 +1955,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);