]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cleanup: simplify group image snapshot validation
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Tue, 16 Dec 2025 12:53:18 +0000 (18:23 +0530)
committerPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Tue, 27 Jan 2026 06:15:21 +0000 (11:45 +0530)
validation of an image snapshot association with a group snapshot requires
checking either a valid group_spec or the presence of a group_snap_id
in cls::rbd::MirrorSnapshotNamespace.

this commit tries to remove redundant validation of checking for both and rely
on this minimal condition of checking for a valid group_spec.

Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
src/librbd/mirror/snapshot/CreatePrimaryRequest.cc
src/tools/rbd_mirror/image_replayer/snapshot/Replayer.cc

index 42940f3aaa8ea5d6a9797540322bd84f95da51e3..3af262898ef9a119c4fc3fcf97b797defe80db90 100644 (file)
@@ -209,7 +209,7 @@ void CreatePrimaryRequest<I>::unlink_peer() {
         if (info->mirror_peer_uuids.empty() ||
             (info->mirror_peer_uuids.count(peer) != 0 &&
              info->is_primary() && !info->complete)) {
-          if (info->group_spec.is_valid() || !info->group_snap_id.empty()) {
+          if (info->group_spec.is_valid()) {
             // snap is part of a group snap
             continue;
           }
@@ -239,7 +239,7 @@ void CreatePrimaryRequest<I>::unlink_peer() {
           // snapshot is not linked with this peer
           continue;
         }
-        if (info->group_spec.is_valid() || !info->group_snap_id.empty()) {
+        if (info->group_spec.is_valid()) {
           // snap is part of a group snap
           continue;
         }
index a3c4444a3ca48cca752fce7130e0b24cbf7606d2..f951f88b56e0f634f22b1b1e9ecd4fe18f324a5b 100644 (file)
@@ -504,8 +504,7 @@ void Replayer<I>::scan_local_mirror_snapshots(
         ceph_assert(m_local_snap_id_end == CEPH_NOSNAP);
 
         if (mirror_ns->mirror_peer_uuids.empty() &&
-            (!mirror_ns->group_spec.is_valid() &&
-             mirror_ns->group_snap_id.empty())) {
+            !mirror_ns->group_spec.is_valid()) {
           // no other peer will attempt to sync to this snapshot so store as
           // a candidate for removal
           m_prune_snap_ids.insert(local_snap_id);
@@ -648,8 +647,7 @@ void Replayer<I>::scan_remote_mirror_snapshots(
                       m_state_builder->remote_mirror_uuid);
 
         if (m_remote_snap_id_end == CEPH_NOSNAP &&
-            (!mirror_ns->group_spec.is_valid() &&
-             mirror_ns->group_snap_id.empty())) {
+            !mirror_ns->group_spec.is_valid()) {
           // haven't found the end snap so treat this as a candidate for unlink
           unlink_snap_ids.insert(remote_snap_id);
         }
@@ -751,8 +749,7 @@ void Replayer<I>::scan_remote_mirror_snapshots(
           get_local_image_state();
         } else {
           // Standalone image mirroring
-          if (!m_remote_mirror_snap_ns.group_spec.is_valid() &&
-              m_remote_mirror_snap_ns.group_snap_id.empty()) {
+          if (!m_remote_mirror_snap_ns.group_spec.is_valid()) {
             copy_snapshots();
             return;
           }
@@ -800,8 +797,7 @@ void Replayer<I>::scan_remote_mirror_snapshots(
     handle_replay_complete(locker, -EEXIST, "split-brain");
     return;
   } else if (remote_demoted &&
-      (!m_remote_mirror_snap_ns.group_spec.is_valid() &&
-       m_remote_mirror_snap_ns.group_snap_id.empty())) {
+             !m_remote_mirror_snap_ns.group_spec.is_valid()) {
     dout(10) << "remote image demoted" << dendl;
     handle_replay_complete(locker, -EREMOTEIO, "remote image demoted");
     return;
@@ -1343,8 +1339,7 @@ void Replayer<I>::handle_notify_image_update(int r) {
         cls::rbd::MirrorSnapshotNamespace>(&snap_ns);
       if (mirror_ns == nullptr || !mirror_ns->complete) {
         continue;
-      } else if (mirror_ns->group_spec.is_valid() ||
-          !mirror_ns->group_snap_id.empty()) {
+      } else if (mirror_ns->group_spec.is_valid()) {
         unlink = false;
       }
       break;