]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: don't prune older mirror snapshots when pruning incomplete snapshot 39428/head
authorJason Dillaman <dillaman@redhat.com>
Mon, 8 Feb 2021 16:53:28 +0000 (11:53 -0500)
committerJason Dillaman <dillaman@redhat.com>
Thu, 11 Feb 2021 18:52:19 +0000 (13:52 -0500)
Since we normally prune in order, we need to ensure that we don't prune older
snapshots when we need to delete an incomplete mirror snapshot since the
older snapshot might be the only remaining mirror snapshot.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 7ba9214ea5b73d0436af6c2896abf4836d741de9)

src/tools/rbd_mirror/image_replayer/snapshot/Replayer.cc

index dec37ad8b3a912f88cf1e5c2e889b2b559e3947d..46be2ec8fe9740ae3b06b9dd1b03d666480e3339 100644 (file)
@@ -431,17 +431,19 @@ void Replayer<I>::scan_local_mirror_snapshots(
           prune_snap_ids.insert(local_snap_id);
         }
       } else {
-        // start snap will be last complete mirror snapshot or initial
-        // image revision
-        m_local_snap_id_end = local_snap_id;
-
         if (mirror_ns->last_copied_object_number == 0) {
           // snapshot might be missing image state, object-map, etc, so just
           // delete and re-create it if we haven't started copying data
-          // objects
+          // objects. Also only prune this snapshot since we will need the
+          // previous mirror snapshot for syncing.
+          prune_snap_ids.clear();
           prune_snap_ids.insert(local_snap_id);
           break;
         }
+
+        // start snap will be last complete mirror snapshot or initial
+        // image revision
+        m_local_snap_id_end = local_snap_id;
       }
     } else if (mirror_ns->is_primary()) {
       if (mirror_ns->complete) {