]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/librbd/operation/FlattenRequest.cc
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / librbd / operation / FlattenRequest.cc
index d94e8421083f45c97a685906ee26730c9de78fbf..76455221726a90e11f8db5bb52eaf7a4c73ee353 100644 (file)
@@ -9,6 +9,7 @@
 #include "librbd/image/DetachParentRequest.h"
 #include "librbd/Types.h"
 #include "librbd/io/ObjectRequest.h"
+#include "librbd/io/Utils.h"
 #include "common/dout.h"
 #include "common/errno.h"
 #include <boost/lambda/bind.hpp>
@@ -29,8 +30,8 @@ template <typename I>
 class C_FlattenObject : public C_AsyncObjectThrottle<I> {
 public:
   C_FlattenObject(AsyncObjectThrottle<I> &throttle, I *image_ctx,
-                  ::SnapContext snapc, uint64_t object_no)
-    : C_AsyncObjectThrottle<I>(throttle, *image_ctx), m_snapc(snapc),
+                  IOContext io_context, uint64_t object_no)
+    : C_AsyncObjectThrottle<I>(throttle, *image_ctx), m_io_context(io_context),
       m_object_no(object_no) {
   }
 
@@ -54,23 +55,18 @@ public:
       }
     }
 
-    bufferlist bl;
-    auto req = new io::ObjectWriteRequest<I>(&image_ctx, m_object_no, 0,
-                                             std::move(bl), m_snapc, 0, {},
-                                             this);
-    if (!req->has_parent()) {
+    if (!io::util::trigger_copyup(
+            &image_ctx, m_object_no, m_io_context, this)) {
       // stop early if the parent went away - it just means
       // another flatten finished first or the image was resized
-      delete req;
       return 1;
     }
 
-    req->send();
     return 0;
   }
 
 private:
-  ::SnapContext m_snapc;
+  IOContext m_io_context;
   uint64_t m_object_no;
 };
 
@@ -104,7 +100,8 @@ void FlattenRequest<I>::flatten_objects() {
     &FlattenRequest<I>::handle_flatten_objects>(this);
   typename AsyncObjectThrottle<I>::ContextFactory context_factory(
     boost::lambda::bind(boost::lambda::new_ptr<C_FlattenObject<I> >(),
-      boost::lambda::_1, &image_ctx, m_snapc, boost::lambda::_2));
+      boost::lambda::_1, &image_ctx, image_ctx.get_data_io_context(),
+      boost::lambda::_2));
   AsyncObjectThrottle<I> *throttle = new AsyncObjectThrottle<I>(
     this, image_ctx, context_factory, ctx, &m_prog_ctx, 0, m_overlap_objects);
   throttle->start_ops(