]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: ensure derived image removals are associated to remote peer
authorJason Dillaman <dillaman@redhat.com>
Tue, 18 Jul 2017 15:59:12 +0000 (11:59 -0400)
committerJason Dillaman <dillaman@redhat.com>
Tue, 25 Jul 2017 11:17:15 +0000 (07:17 -0400)
If the remote pool image listing is retrieved before the local pool image
listing, the derived image removals would incorrectly be associated with
the local peer.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/tools/rbd_mirror/PoolReplayer.cc

index 0a27d97692e42ef4b7976a476b9870f78cfdaff2..fd0b21b1847d84fa67b84a5e1c4b3186d09444c7 100644 (file)
@@ -615,6 +615,8 @@ void PoolReplayer::handle_update(const std::string &mirror_uuid,
       m_remote_pool_watcher->get_image_count());
   }
 
+  std::string removed_remote_peer_id;
+  ImageIds removed_remote_image_ids;
   if (m_initial_mirror_image_ids.find(mirror_uuid) ==
         m_initial_mirror_image_ids.end() &&
       m_initial_mirror_image_ids.size() < 2) {
@@ -627,9 +629,10 @@ void PoolReplayer::handle_update(const std::string &mirror_uuid,
       // removal notifications for the remote pool
       auto &local_image_ids = m_initial_mirror_image_ids.begin()->second;
       auto &remote_image_ids = m_initial_mirror_image_ids.rbegin()->second;
+      removed_remote_peer_id = m_initial_mirror_image_ids.rbegin()->first;
       for (auto &local_image_id : local_image_ids) {
         if (remote_image_ids.find(local_image_id) == remote_image_ids.end()) {
-          removed_image_ids.emplace(local_image_id.global_id, "");
+          removed_remote_image_ids.emplace(local_image_id.global_id, "");
         }
       }
       local_image_ids.clear();
@@ -667,6 +670,16 @@ void PoolReplayer::handle_update(const std::string &mirror_uuid,
                                              gather_ctx->new_sub());
   }
 
+  // derived removal events for remote after initial image listing
+  for (auto& image_id : removed_remote_image_ids) {
+    // for now always send to myself (the leader)
+    std::string &instance_id = m_instance_watcher->get_instance_id();
+    m_instance_watcher->notify_image_release(instance_id, image_id.global_id,
+                                             removed_remote_peer_id,
+                                             image_id.id, true,
+                                             gather_ctx->new_sub());
+  }
+
   gather_ctx->activate();
 }