From dea3d1b738181da9dc77418d4218eb596875847d Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Fri, 25 Oct 2019 16:01:59 +0300 Subject: [PATCH] rbd-mirror: mirrored clone should be same format Fixes: https://tracker.ceph.com/issues/42488 Signed-off-by: Mykola Golub --- qa/workunits/rbd/rbd_mirror.sh | 14 +++++++++ qa/workunits/rbd/rbd_mirror_helpers.sh | 30 +++++++++++++++++-- src/include/rbd/librbd.h | 1 + .../image_replayer/CreateImageRequest.cc | 9 ++++++ 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/qa/workunits/rbd/rbd_mirror.sh b/qa/workunits/rbd/rbd_mirror.sh index 8f979f581fbed..1358e450be163 100755 --- a/qa/workunits/rbd/rbd_mirror.sh +++ b/qa/workunits/rbd/rbd_mirror.sh @@ -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} diff --git a/qa/workunits/rbd/rbd_mirror_helpers.sh b/qa/workunits/rbd/rbd_mirror_helpers.sh index c364dd7ce6b17..3fcb699d3c88f 100755 --- a/qa/workunits/rbd/rbd_mirror_helpers.sh +++ b/qa/workunits/rbd/rbd_mirror_helpers.sh @@ -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 # diff --git a/src/include/rbd/librbd.h b/src/include/rbd/librbd.h index 64af2d3d64aed..c3bd382690859 100644 --- a/src/include/rbd/librbd.h +++ b/src/include/rbd/librbd.h @@ -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 { diff --git a/src/tools/rbd_mirror/image_replayer/CreateImageRequest.cc b/src/tools/rbd_mirror/image_replayer/CreateImageRequest.cc index 034f24f77dfdf..84973676edc44 100644 --- a/src/tools/rbd_mirror/image_replayer/CreateImageRequest.cc +++ b/src/tools/rbd_mirror/image_replayer/CreateImageRequest.cc @@ -489,6 +489,15 @@ void CreateImageRequest::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 -- 2.39.5