]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: fix image map notifications for groups
authorN Balachandran <nithya.balachandran@ibm.com>
Fri, 7 Mar 2025 07:26:35 +0000 (12:56 +0530)
committerPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Thu, 24 Apr 2025 15:56:32 +0000 (21:26 +0530)
The Group replayer Bootstrap now sends mirroring notifications
when creating or deleting the local group. The ImageMap will only
send the acquire_group notifications once for each group.

Signed-off-by: N Balachandran <nithya.balachandran@ibm.com>
qa/workunits/rbd/rbd_mirror_group_simple.sh
src/tools/rbd_mirror/ImageMap.cc
src/tools/rbd_mirror/group_replayer/BootstrapRequest.cc
src/tools/rbd_mirror/group_replayer/BootstrapRequest.h

index 1a05189056967a61fbcff50a6124fe0d0e610cdb..5c1f1dfba6d0ef698f5b4148ebf363c634a1a392 100755 (executable)
@@ -395,7 +395,7 @@ test_create_group_stop_daemon_then_recreate()
     wait_for_group_status_in_pool_dir "${secondary_cluster}" "${pool}"/"${group}" 'up+replaying' 0
 
     count_omap_keys_with_filter "${secondary_cluster}" "${pool}" "rbd_mirror_leader" "image_map" key_count
-    test "${key_count}" = 2 || fail "unexpected key count:${key_count}"
+    test "${key_count}" = 1 || fail "unexpected key count:${key_count}"
   elif  [ "${scenario}" = 'stop_restart_after_recreate' ]; then
     echo "stopping daemon on secondary"
     stop_mirrors "${secondary_cluster}"
@@ -413,7 +413,7 @@ test_create_group_stop_daemon_then_recreate()
     wait_for_group_status_in_pool_dir "${secondary_cluster}" "${pool}"/"${group}" 'up+replaying' 0
 
     count_omap_keys_with_filter "${secondary_cluster}" "${pool}" "rbd_mirror_leader" "image_map" key_count
-    test "${key_count}" = 2 || fail "unexpected key count:${key_count}"
+    test "${key_count}" = 1 || fail "unexpected key count:${key_count}"
   fi
 
   mirror_group_disable "${primary_cluster}" "${pool}/${group}"
index db76bceeab0f7c556f7f5e9a9d5f02b00cdb7d47..3131cbf91b786005c78b249290b33c70d4bc1e1f 100644 (file)
@@ -430,7 +430,7 @@ void ImageMap<I>::update_images_added(
   for (auto &entity : entities) {
     auto global_id = GlobalId(entity.type, entity.global_id);
     auto result = m_peer_map[global_id].insert(mirror_uuid);
-    if ((result.second && m_peer_map[global_id].size() == 1) || entity.type == MIRROR_ENTITY_TYPE_GROUP) {
+    if ((result.second && m_peer_map[global_id].size() == 1)) {
       if (m_policy->add_entity(global_id, entity.count)) {
         schedule_action(global_id);
       }
index 28b6756bab3c016a1ed650b524f510e88fb02629..23ade4c5ff0cbab8b0014d3a8afd7cef0d7ca50b 100644 (file)
@@ -10,6 +10,7 @@
 #include "librbd/internal.h"
 #include "librbd/group/ListSnapshotsRequest.h"
 #include "librbd/group/RemoveImageRequest.h"
+#include "librbd/MirroringWatcher.h"
 #include "librbd/Utils.h"
 #include "tools/rbd_mirror/ImageReplayer.h"
 #include "tools/rbd_mirror/PoolMetaCache.h"
@@ -1162,7 +1163,7 @@ void BootstrapRequest<I>::handle_remove_local_group_id(int r) {
     return;
   }
 
-  finish(0);
+  notify_mirroring_watcher();
 }
 
 template <typename I>
@@ -1309,6 +1310,31 @@ void BootstrapRequest<I>::handle_create_local_non_primary_group_snapshot(int r)
     return;
   }
 
+  notify_mirroring_watcher();
+}
+
+template <typename I>
+void BootstrapRequest<I>::notify_mirroring_watcher() {
+  dout(10) << dendl;
+
+  auto ctx = create_context_callback<
+    BootstrapRequest<I>,
+    &BootstrapRequest<I>::handle_notify_mirroring_watcher>(this);
+
+  librbd::MirroringWatcher<I>::notify_group_updated(
+    m_local_io_ctx, m_local_mirror_group.state, *m_local_group_id,
+    m_global_group_id, m_local_images.size(), ctx);
+}
+
+template <typename I>
+void BootstrapRequest<I>::handle_notify_mirroring_watcher(int r) {
+  dout(10) << "r=" << r << dendl;
+
+  if (r < 0) {
+    derr << "failed to notify mirror group update: " << cpp_strerror(r)
+         << dendl;
+  }
+
   finish(0);
 }
 
index 514ecb38084f4169aaecc612b5605a57b24ee71f..0f6fcc6f64bd90282dbc9e2bd04d4eedf145a30e 100644 (file)
@@ -272,6 +272,9 @@ private:
   void create_local_non_primary_group_snapshot();
   void handle_create_local_non_primary_group_snapshot(int r);
 
+  void notify_mirroring_watcher();
+  void handle_notify_mirroring_watcher(int r);
+
   void finish(int r);
 
   int create_replayers();