]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/librbd/internal.cc
import quincy beta 17.1.0
[ceph.git] / ceph / src / librbd / internal.cc
index db780956b561911c3f5f584a2ef139287008c97c..42542b22d28b4db9167b226ca639f5d71c98b90a 100644 (file)
@@ -68,6 +68,7 @@
 
 #define rbd_howmany(x, y)  (((x) + (y) - 1) / (y))
 
+using std::istringstream;
 using std::map;
 using std::pair;
 using std::set;
@@ -1280,12 +1281,27 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
       return -EINVAL;
     }
 
+    // ensure previous writes are visible to dest
+    C_SaferCond flush_ctx;
+    {
+      auto aio_comp = io::AioCompletion::create_and_start(&flush_ctx, src,
+         io::AIO_TYPE_FLUSH);
+      auto req = io::ImageDispatchSpec::create_flush(
+         *src, io::IMAGE_DISPATCH_LAYER_INTERNAL_START,
+         aio_comp, io::FLUSH_SOURCE_INTERNAL, {});
+      req->send();
+    }
+    int r = flush_ctx.wait();
+    if (r < 0) {
+      return r;
+    }
+
     C_SaferCond ctx;
     auto req = deep_copy::MetadataCopyRequest<>::create(
       src, dest, &ctx);
     req->send();
 
-    int r = ctx.wait();
+    r = ctx.wait();
     if (r < 0) {
       lderr(cct) << "failed to copy metadata: " << cpp_strerror(r) << dendl;
       return r;
@@ -1325,7 +1341,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
         }
       }
 
-      uint64_t len = min(period, src_size - offset);
+      uint64_t len = std::min(period, src_size - offset);
       bufferlist *bl = new bufferlist();
       auto ctx = new C_CopyRead(&throttle, dest, offset, bl, sparse_size);
       auto comp = io::AioCompletion::create_and_start<Context>(
@@ -1536,7 +1552,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
     start_time = coarse_mono_clock::now();
     while (left > 0) {
       uint64_t period_off = off - (off % period);
-      uint64_t read_len = min(period_off + period - off, left);
+      uint64_t read_len = std::min(period_off + period - off, left);
 
       bufferlist bl;