]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rbd-mirror: properly handle promoted/demoted snapshot-based images
authorJason Dillaman <dillaman@redhat.com>
Thu, 27 Feb 2020 13:50:18 +0000 (08:50 -0500)
committerJason Dillaman <dillaman@redhat.com>
Mon, 2 Mar 2020 15:53:43 +0000 (10:53 -0500)
We should return -EREMOTEIO if we don't have any primary images to sync to
since we want display a warning. Additionally, don't attempt to sync a
remote snapshot against a primary (demoted) local snapshot since it would
have an invalid primary snapshot id.

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

index a2f8950f0de5c4f5ea1d2cbd150f66014463c802..5b5c038df4e827de17f1e76d39d24ca5ad129dfb 100644 (file)
@@ -444,7 +444,8 @@ void Replayer<I>::scan_local_mirror_snapshots(
              << "local_snap_id_start=" << m_local_snap_id_start << ", "
              << "local_snap_id_end=" << m_local_snap_id_end << ", "
              << "local_snap_ns=" << m_local_mirror_snap_ns << dendl;
-    if (m_local_mirror_snap_ns.complete) {
+    if (!m_local_mirror_snap_ns.is_primary() &&
+        m_local_mirror_snap_ns.complete) {
       // our remote sync should start after this completed snapshot
       m_remote_snap_id_start = m_local_mirror_snap_ns.primary_snap_id;
     }
@@ -483,7 +484,7 @@ void Replayer<I>::scan_remote_mirror_snapshots(
                              "invalid remote mirror snapshot state");
       return;
     } else {
-      remote_demoted = (mirror_ns->is_primary() && mirror_ns->is_demoted());
+      remote_demoted = mirror_ns->is_demoted();
     }
 
     auto remote_snap_id = snap_info_it->first;
@@ -591,7 +592,7 @@ void Replayer<I>::scan_remote_mirror_snapshots(
     return;
   } else if (remote_demoted) {
     dout(10) << "remote image demoted" << dendl;
-    handle_replay_complete(locker, 0, "remote image demoted");
+    handle_replay_complete(locker, -EREMOTEIO, "remote image demoted");
     return;
   }