]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/tools/rbd/action/Import.cc
import 15.2.5
[ceph.git] / ceph / src / tools / rbd / action / Import.cc
index b4292b336ea6b5b6a499524e8f1fe74793165c78..7397d926a3612fae9207e2dbf954ea781ecd98b3 100644 (file)
@@ -80,9 +80,9 @@ struct ImportDiffContext {
 class C_ImportDiff : public Context {
 public:
   C_ImportDiff(ImportDiffContext *idiffctx, bufferlist data, uint64_t offset,
-               uint64_t length, bool discard)
+               uint64_t length, bool write_zeroes)
     : m_idiffctx(idiffctx), m_data(data), m_offset(offset), m_length(length),
-      m_discard(discard) {
+      m_write_zeroes(write_zeroes) {
     // use block offset (stdin) or import file position to report
     // progress.
     if (m_idiffctx->fd == STDIN_FILENO) {
@@ -103,11 +103,14 @@ public:
       new librbd::RBD::AioCompletion(ctx, &utils::aio_context_callback);
 
     int r;
-    if (m_discard) {
-      r = m_idiffctx->image->aio_discard(m_offset, m_length, aio_completion);
+    if (m_write_zeroes) {
+      r = m_idiffctx->image->aio_write_zeroes(m_offset, m_length,
+                                              aio_completion, 0U,
+                                              LIBRADOS_OP_FLAG_FADVISE_NOCACHE);
     } else {
       r = m_idiffctx->image->aio_write2(m_offset, m_length, m_data,
-                                        aio_completion, LIBRADOS_OP_FLAG_FADVISE_NOCACHE);
+                                        aio_completion,
+                                        LIBRADOS_OP_FLAG_FADVISE_NOCACHE);
     }
 
     if (r < 0) {
@@ -129,7 +132,7 @@ private:
   bufferlist m_data;
   uint64_t m_offset;
   uint64_t m_length;
-  bool m_discard;
+  bool m_write_zeroes;
   uint64_t m_prog_offset;
 };
 
@@ -233,7 +236,8 @@ static int do_image_resize(ImportDiffContext *idiffctx)
   return 0;
 }
 
-static int do_image_io(ImportDiffContext *idiffctx, bool discard, size_t sparse_size)
+static int do_image_io(ImportDiffContext *idiffctx, bool write_zeroes,
+                       size_t sparse_size)
 {
   int r;
   char buf[16];
@@ -251,7 +255,7 @@ static int do_image_io(ImportDiffContext *idiffctx, bool discard, size_t sparse_
   decode(image_offset, p);
   decode(buffer_length, p);
 
-  if (!discard) {
+  if (!write_zeroes) {
     bufferptr bp = buffer::create(buffer_length);
     r = safe_read_exact(idiffctx->fd, bp.c_str(), buffer_length);
     if (r < 0) {
@@ -393,14 +397,6 @@ int do_import_diff_fd(librados::Rados &rados, librbd::Image &image, int fd,
     return r;
   }
 
-  std::string skip_partial_discard;
-  r = rados.conf_get("rbd_skip_partial_discard", skip_partial_discard);
-  if (r < 0 || skip_partial_discard != "false") {
-    dout(1) << "disabling sparse import" << dendl;
-    sparse_size = 0;
-    r = 0;
-  }
-
   // begin image import
   std::string tosnap;
   bool is_protected = false;