]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: mirrored clone should be same format
authorMykola Golub <mgolub@suse.com>
Fri, 25 Oct 2019 13:01:59 +0000 (16:01 +0300)
committerMykola Golub <mgolub@suse.com>
Mon, 11 Nov 2019 09:46:36 +0000 (09:46 +0000)
Fixes: https://tracker.ceph.com/issues/42488
Signed-off-by: Mykola Golub <mgolub@suse.com>
(cherry picked from commit dea3d1b738181da9dc77418d4218eb596875847d)

qa/workunits/rbd/rbd_mirror.sh
qa/workunits/rbd/rbd_mirror_helpers.sh
src/include/rbd/librbd.h
src/tools/rbd_mirror/image_replayer/CreateImageRequest.cc

index 7cefd845750282e38a51ed0c16ac813ad764a9d2..713e34ac4903f81711bc78e93e8f5d10a2924ed3 100755 (executable)
@@ -242,6 +242,20 @@ compare_images ${POOL} ${clone_image}
 
 clone_image ${CLUSTER1} ${PARENT_POOL} ${parent_image} ${parent_snap} ${POOL} ${clone_image}1
 
+clone_image ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} ${POOL} \
+            ${clone_image}_v1 --rbd-default-clone-format 1
+test $(get_clone_format ${CLUSTER2} ${POOL} ${clone_image}_v1) = 1
+wait_for_image_replay_started ${CLUSTER1} ${POOL} ${clone_image}_v1
+test $(get_clone_format ${CLUSTER1} ${POOL} ${clone_image}_v1) = 1
+
+parent_snap=snap_v2
+create_snapshot ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap}
+clone_image ${CLUSTER2} ${PARENT_POOL} ${parent_image} ${parent_snap} ${POOL} \
+            ${clone_image}_v2 --rbd-default-clone-format 2
+test $(get_clone_format ${CLUSTER2} ${POOL} ${clone_image}_v2) = 2
+wait_for_image_replay_started ${CLUSTER1} ${POOL} ${clone_image}_v2
+test $(get_clone_format ${CLUSTER1} ${POOL} ${clone_image}_v2) = 2
+
 testlog "TEST: data pool"
 dp_image=test_data_pool
 create_image ${CLUSTER2} ${POOL} ${dp_image} 128 --data-pool ${PARENT_POOL}
index 7bbd2ade3f71c29118cd6e89b03efc4910877e82..7faad814fa56d9d2c953224081f2a4d938f873b5 100755 (executable)
@@ -803,8 +803,12 @@ clone_image()
     local clone_pool=$5
     local clone_image=$6
 
-    rbd --cluster ${cluster} clone ${parent_pool}/${parent_image}@${parent_snap} \
-       ${clone_pool}/${clone_image} --image-feature layering,exclusive-lock,journaling
+    shift 6
+
+    rbd --cluster ${cluster} clone \
+        ${parent_pool}/${parent_image}@${parent_snap} \
+        ${clone_pool}/${clone_image} \
+        --image-feature layering,exclusive-lock,journaling $@
 }
 
 disconnect_image()
@@ -1073,6 +1077,28 @@ get_image_data_pool()
         awk '$1 == "data_pool:" {print $2}'
 }
 
+get_clone_format()
+{
+    local cluster=$1
+    local pool=$2
+    local image=$3
+
+    rbd --cluster ${cluster} info ${pool}/${image} |
+        awk 'BEGIN {
+               format = 1
+             }
+             $1 == "parent:" {
+               parent = $2
+             }
+             /op_features: .*clone-child/ {
+               format = 2
+             }
+             END {
+               if (!parent) exit 1
+               print format
+             }'
+}
+
 #
 # Main
 #
index 90883b62c765398b918eb05d3e85c839e09405b3..a1cb2c6e91f7aece2b37741c840c4fa009b169e1 100644 (file)
@@ -208,6 +208,7 @@ enum {
   RBD_IMAGE_OPTION_FEATURES_CLEAR = 9,
   RBD_IMAGE_OPTION_DATA_POOL = 10,
   RBD_IMAGE_OPTION_FLATTEN = 11,
+  RBD_IMAGE_OPTION_CLONE_FORMAT = 12,
 };
 
 typedef enum {
index 556a969946c53a87f6141ed8c032fd43ee5f3108..66587b711b8c77d8722df7ea03859e09ff499bfe 100644 (file)
@@ -466,6 +466,15 @@ void CreateImageRequest<I>::populate_image_options(
   if (data_pool != "") {
     image_options->set(RBD_IMAGE_OPTION_DATA_POOL, data_pool);
   }
+
+  if (m_remote_parent_spec.pool_id != -1) {
+    uint64_t clone_format = 1;
+    if (m_remote_image_ctx->test_op_features(
+            RBD_OPERATION_FEATURE_CLONE_CHILD)) {
+      clone_format = 2;
+    }
+    image_options->set(RBD_IMAGE_OPTION_CLONE_FORMAT, clone_format);
+  }
 }
 
 } // namespace image_replayer