From: Jason Dillaman Date: Fri, 21 Feb 2020 14:44:06 +0000 (-0500) Subject: librbd: filter implicit features and non-user snapshots from image state X-Git-Tag: v15.1.1~298^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e99f516d3d5a30f7a4e6bafc5635f9bcb51cdd7b;p=ceph-ci.git librbd: filter implicit features and non-user snapshots from image state The implicit features are not controlled by the user so they should not be mirrored. Similarly, trash snapshots are implicitly created by need and group snapshots are not supported for mirroring. Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/mirror/snapshot/SetImageStateRequest.cc b/src/librbd/mirror/snapshot/SetImageStateRequest.cc index 55c2df62981..1496e20ad4b 100644 --- a/src/librbd/mirror/snapshot/SetImageStateRequest.cc +++ b/src/librbd/mirror/snapshot/SetImageStateRequest.cc @@ -123,11 +123,14 @@ void SetImageStateRequest::handle_get_metadata(int r) { std::shared_lock image_locker{m_image_ctx->image_lock}; m_image_state.name = m_image_ctx->name; - m_image_state.features = m_image_ctx->features; + m_image_state.features = + m_image_ctx->features & ~RBD_FEATURES_IMPLICIT_ENABLE; for (auto &[snap_id, snap_info] : m_image_ctx->snap_info) { auto type = cls::rbd::get_snap_namespace_type(snap_info.snap_namespace); - if (type == cls::rbd::SNAPSHOT_NAMESPACE_TYPE_MIRROR) { + if (type != cls::rbd::SNAPSHOT_NAMESPACE_TYPE_USER) { + // only replicate user snapshots -- trash snapshots will be + // replicated by an implicit delete if required continue; } m_image_state.snapshots[snap_id] = {snap_info.snap_namespace, diff --git a/src/test/librbd/test_mirroring.cc b/src/test/librbd/test_mirroring.cc index 199b5e23b87..a3eacd75747 100644 --- a/src/test/librbd/test_mirroring.cc +++ b/src/test/librbd/test_mirroring.cc @@ -1375,7 +1375,7 @@ TEST_F(TestMirroring, SnapshotImageState) ASSERT_EQ(image_name, image_state.name); ASSERT_EQ(0, image.features(&features)); - ASSERT_EQ(features, image_state.features); + ASSERT_EQ(features & ~RBD_FEATURES_IMPLICIT_ENABLE, image_state.features); ASSERT_EQ(1U, image_state.snapshots.size()); ASSERT_EQ("snap", image_state.snapshots.begin()->second.name); ASSERT_TRUE(image_state.metadata.empty()); @@ -1413,7 +1413,7 @@ TEST_F(TestMirroring, SnapshotImageState) } ASSERT_EQ(image_name, image_state.name); - ASSERT_EQ(features, image_state.features); + ASSERT_EQ(features & ~RBD_FEATURES_IMPLICIT_ENABLE, image_state.features); ASSERT_EQ(10U, image_state.metadata.size()); for (int i = 0; i < 10; i++) { auto &bl = image_state.metadata[stringify(i)];