]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: fixed issue with deep-copy incorrectly setting parent spec
authorJason Dillaman <dillaman@redhat.com>
Thu, 27 Feb 2020 19:49:11 +0000 (14:49 -0500)
committerJason Dillaman <dillaman@redhat.com>
Mon, 2 Mar 2020 15:53:44 +0000 (10:53 -0500)
When not syncing the full image, the destination image would receive
the incorrect source parent spec instead of the expected destination
parent spec.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/cls/rbd/cls_rbd_types.cc
src/cls/rbd/cls_rbd_types.h
src/librbd/deep_copy/SnapshotCopyRequest.cc
src/librbd/image/AttachParentRequest.cc

index b6e1cd9b0ddc8d68a99f9b10fba91d2991a493b8..9071f3457fe5d8d6d1a6ad262a07624f0e3895b7 100644 (file)
@@ -524,6 +524,16 @@ void ParentImageSpec::generate_test_instances(std::list<ParentImageSpec*>& o) {
   o.push_back(new ParentImageSpec{1, "ns", "foo", 3});
 }
 
+std::ostream& operator<<(std::ostream& os, const ParentImageSpec& rhs) {
+  os << "["
+     << "pool_id=" << rhs.pool_id << ", "
+     << "pool_namespace=" << rhs.pool_namespace << ", "
+     << "image_id=" << rhs.image_id << ", "
+     << "snap_id=" << rhs.snap_id
+     << "]";
+  return os;
+}
+
 void ChildImageSpec::encode(bufferlist &bl) const {
   ENCODE_START(2, 1, bl);
   encode(pool_id, bl);
@@ -554,6 +564,15 @@ void ChildImageSpec::generate_test_instances(std::list<ChildImageSpec*> &o) {
   o.push_back(new ChildImageSpec(123, "ns", "abc"));
 }
 
+std::ostream& operator<<(std::ostream& os, const ChildImageSpec& rhs) {
+  os << "["
+     << "pool_id=" << rhs.pool_id << ", "
+     << "pool_namespace=" << rhs.pool_namespace << ", "
+     << "image_id=" << rhs.image_id
+     << "]";
+  return os;
+}
+
 void GroupImageSpec::encode(bufferlist &bl) const {
   ENCODE_START(1, 1, bl);
   encode(image_id, bl);
index 081540d8e7998c0578866ca311483698b06efd6d..b2c155eb864a2378101b2e27addd94c742efce73 100644 (file)
@@ -315,6 +315,8 @@ struct ParentImageSpec {
 
 WRITE_CLASS_ENCODER(ParentImageSpec);
 
+std::ostream& operator<<(std::ostream& os, const ParentImageSpec& rhs);
+
 struct ChildImageSpec {
   int64_t pool_id = -1;
   std::string pool_namespace;
@@ -349,6 +351,8 @@ struct ChildImageSpec {
 };
 WRITE_CLASS_ENCODER(ChildImageSpec);
 
+std::ostream& operator<<(std::ostream& os, const ChildImageSpec& rhs);
+
 typedef std::set<ChildImageSpec> ChildImageSpecs;
 
 struct GroupImageSpec {
index b7262e30dafb433e0b12d90f1f80ebc63a22927d..8ac59308873f4ba1be3f72d24743a1d759d9b5a6 100644 (file)
@@ -568,14 +568,14 @@ void SnapshotCopyRequest<I>::send_set_head() {
     if (snap_info_it != m_src_image_ctx->snap_info.end()) {
       auto& snap_info = snap_info_it->second;
       size = snap_info.size;
-      if (!m_flatten) {
-        parent_spec = snap_info.parent.spec;
+      if (!m_flatten && snap_info.parent.spec.pool_id != -1) {
+        parent_spec = m_dst_parent_spec;
         parent_overlap = snap_info.parent.overlap;
       }
     } else {
       size = m_src_image_ctx->size;
       if (!m_flatten) {
-        parent_spec = m_src_image_ctx->parent_md.spec;
+        parent_spec = m_dst_image_ctx->parent_md.spec;
         parent_overlap = m_src_image_ctx->parent_md.overlap;
       }
     }
index 19e69594749a89f85b39614f5007d8b45401349a..116ef7ffada9ab367fafc663c1d3fdf20751dbd4 100644 (file)
@@ -27,7 +27,7 @@ void AttachParentRequest<I>::send() {
 template <typename I>
 void AttachParentRequest<I>::attach_parent() {
   auto cct = m_image_ctx.cct;
-  ldout(cct, 5) << dendl;
+  ldout(cct, 5) << "parent_image_spec=" << m_parent_image_spec << dendl;
 
   librados::ObjectWriteOperation op;
   if (!m_legacy_parent) {