]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: only create new mirror image state records for primary mirror snapshots 33335/head
authorJason Dillaman <dillaman@redhat.com>
Fri, 21 Feb 2020 18:45:53 +0000 (13:45 -0500)
committerJason Dillaman <dillaman@redhat.com>
Fri, 21 Feb 2020 18:45:53 +0000 (13:45 -0500)
The consolidation of primary and non-primary mirror snapshot namespaces
resulted in the creation of image state records for non-primary snapshots.
This was resulting in non-primary snapshots being prematurely marked as
complete.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/operation/SnapshotCreateRequest.cc
src/test/librbd/operation/test_mock_SnapshotCreateRequest.cc

index 457e4014352f6a6fe1148eaa2b23342bd2f462e2..e51e4389506c5a33a4e5e77cbeb76019a962260f 100644 (file)
@@ -256,9 +256,9 @@ Context *SnapshotCreateRequest<I>::handle_create_object_map(int *result) {
 template <typename I>
 Context *SnapshotCreateRequest<I>::send_create_image_state() {
   I &image_ctx = this->m_image_ctx;
-  auto type = cls::rbd::get_snap_namespace_type(m_snap_namespace);
-
-  if (type != cls::rbd::SNAPSHOT_NAMESPACE_TYPE_MIRROR) {
+  auto mirror_ns = boost::get<cls::rbd::MirrorSnapshotNamespace>(
+    &m_snap_namespace);
+  if (mirror_ns == nullptr || !mirror_ns->is_primary()) {
     update_snap_context();
     image_ctx.io_work_queue->unblock_writes();
     return this->create_context_finisher(0);
index da7c6492ef5beca92f2872a0482a57c544a7b8b9..47506a96da29ab1a2fedfc1581279dfa29a05116 100644 (file)
@@ -381,8 +381,10 @@ TEST_F(TestMockOperationSnapshotCreateRequest, SetImageState) {
 
   C_SaferCond cond_ctx;
   MockSnapshotCreateRequest *req = new MockSnapshotCreateRequest(
-    mock_image_ctx, &cond_ctx, cls::rbd::MirrorSnapshotNamespace(),
-      "snap1", 0, false);
+    mock_image_ctx, &cond_ctx,
+    cls::rbd::MirrorSnapshotNamespace{
+      cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY, {}, "", CEPH_NOSNAP},
+    "snap1", 0, false);
   {
     std::shared_lock owner_locker{mock_image_ctx.owner_lock};
     req->send();