]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: relax snapshot mirror promotion state determination
authorJason Dillaman <dillaman@redhat.com>
Thu, 30 Jan 2020 19:49:46 +0000 (14:49 -0500)
committerJason Dillaman <dillaman@redhat.com>
Fri, 31 Jan 2020 04:14:21 +0000 (23:14 -0500)
If no mirroring-related snapshots exist on the image, it cannot
be determined if the image is primary/non-primary. In the case of
rbd-mirror, this will be the case after a new mirrored image is
created locally but before it can be synced.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/mirror/DisableRequest.cc
src/librbd/mirror/GetInfoRequest.cc
src/librbd/mirror/Types.h

index a436e7ebe46f64ceafc7b32cf25e1417cea498f8..500cebded8e6dcb483b8f8b503b612b9b712076c 100644 (file)
@@ -70,7 +70,8 @@ Context *DisableRequest<I>::handle_get_mirror_info(int *result) {
     return m_on_finish;
   }
 
-  m_is_primary = (m_promotion_state == PROMOTION_STATE_PRIMARY);
+  m_is_primary = (m_promotion_state == PROMOTION_STATE_PRIMARY ||
+                  m_promotion_state == PROMOTION_STATE_UNKNOWN);
 
   if (!m_is_primary && !m_force) {
     lderr(cct) << "mirrored image is not primary, "
index e8f2134ff907d7b43e4d604768b24d65aba54a27..6ceb56f155bfdf5c4f17e43f49f98b6f26a0c90c 100644 (file)
@@ -246,7 +246,7 @@ void GetInfoRequest<I>::finish(int r) {
 template <typename I>
 void GetInfoRequest<I>::calc_promotion_state(
     const std::map<librados::snap_t, SnapInfo> &snap_info) {
-  *m_promotion_state = PROMOTION_STATE_PRIMARY;
+  *m_promotion_state = PROMOTION_STATE_UNKNOWN;
   *m_primary_mirror_uuid = "";
 
   for (auto it = snap_info.rbegin(); it != snap_info.rend(); it++) {
@@ -255,6 +255,8 @@ void GetInfoRequest<I>::calc_promotion_state(
     if (primary != nullptr) {
       if (primary->demoted) {
         *m_promotion_state = PROMOTION_STATE_ORPHAN;
+      } else {
+        *m_promotion_state = PROMOTION_STATE_PRIMARY;
       }
       break;
     }
index 38511bdb7c155acf8f679c3b724b99192e7d8931..2388b74ef2e5a55cf1aed2e1b623802bd37b55a8 100644 (file)
@@ -8,6 +8,7 @@ namespace librbd {
 namespace mirror {
 
 enum PromotionState {
+  PROMOTION_STATE_UNKNOWN,
   PROMOTION_STATE_PRIMARY,
   PROMOTION_STATE_NON_PRIMARY,
   PROMOTION_STATE_ORPHAN