]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/mirror: change naming format of member image snap
authorRamana Raja <rraja@redhat.com>
Tue, 4 Mar 2025 17:43:19 +0000 (12:43 -0500)
committerPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Thu, 24 Apr 2025 15:56:32 +0000 (21:26 +0530)
... of primary and non-primary mirror group snaps.

Set the naming format of member image snap of a mirror group snap to be,
mirror.primary.<global_image_id>.<global_group_id>.<group_pool_id>_<group_id>_<group_snap_id>,
or
mirror.non_primary.<global_image_id>.<global_group_id>.<group_pool_id>_<group_id>_<group_snap_id>

Signed-off-by: Ramana Raja <rraja@redhat.com>
src/librbd/mirror/snapshot/CreateNonPrimaryRequest.cc
src/librbd/mirror/snapshot/CreatePrimaryRequest.cc

index 70fa8e8f5da5bc7d74bb113d26a739563562ecb2..9fcb80ef7dc877d08e04b5700cde3421a2769fa9 100644 (file)
@@ -122,10 +122,18 @@ void CreateNonPrimaryRequest<I>::handle_get_mirror_image(int r) {
     return;
   }
 
-  uuid_d uuid_gen;
-  uuid_gen.generate_random();
-  m_snap_name = ".mirror.non_primary." + mirror_image.global_image_id + "." +
-    uuid_gen.to_string();
+  std::stringstream ss;
+  ss << ".mirror.non_primary." << mirror_image.global_image_id << ".";
+  if (!m_group_snap_id.empty()) {
+    ss << m_image_ctx->group_spec.pool_id << "_"
+       << m_image_ctx->group_spec.group_id << "_"
+       << m_group_snap_id;
+  } else {
+    uuid_d uuid_gen;
+    uuid_gen.generate_random();
+    ss << uuid_gen.to_string();
+  }
+  m_snap_name = ss.str();
 
   get_mirror_peers();
 }
index 255c69476d6b411e640eb834e028e5090fe0731c..519ff7f838cb75741af1428b242ccb5f0872d29d 100644 (file)
@@ -52,10 +52,18 @@ void CreatePrimaryRequest<I>::send() {
     return;
   }
 
-  uuid_d uuid_gen;
-  uuid_gen.generate_random();
-  m_snap_name = ".mirror.primary." + m_global_image_id + "." +
-    uuid_gen.to_string();
+  std::stringstream ss;
+  ss << ".mirror.primary." << m_global_image_id << ".";
+  if (!m_group_snap_id.empty()) {
+    ss << m_image_ctx->group_spec.pool_id << "_"
+       << m_image_ctx->group_spec.group_id << "_"
+       << m_group_snap_id;
+  } else {
+    uuid_d uuid_gen;
+    uuid_gen.generate_random();
+    ss << uuid_gen.to_string();
+  }
+  m_snap_name = ss.str();
 
   get_mirror_peers();
 }