]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: mirrored clone should be same format 31161/head
authorMykola Golub <mgolub@suse.com>
Fri, 25 Oct 2019 13:01:59 +0000 (16:01 +0300)
committerMykola Golub <mgolub@suse.com>
Fri, 25 Oct 2019 14:50:54 +0000 (17:50 +0300)
Fixes: https://tracker.ceph.com/issues/42488
Signed-off-by: Mykola Golub <mgolub@suse.com>
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 8f979f581fbed338dcbecb6090793c4fe9636f97..1358e450be163e073d57c2f591526d39cb3afac3 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 c364dd7ce6b170e85a4e7e0164e203c66a0fb235..3fcb699d3c88f1333e0f89ee1e3321f61a31720b 100755 (executable)
@@ -871,8 +871,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()
@@ -1167,6 +1171,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 64af2d3d64aed1be86f5b64363a0943006403866..c3bd3826908594c2c3479ef85f558b3b80313854 100644 (file)
@@ -268,6 +268,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 034f24f77dfdf407b4c6a945cdcf331e53f849b3..84973676edc44b365c4631769fc6780d088b7933 100644 (file)
@@ -489,6 +489,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