]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: refactor split-brain detection code
authorMykola Golub <mgolub@mirantis.com>
Tue, 3 May 2016 09:48:06 +0000 (12:48 +0300)
committerJason Dillaman <dillaman@redhat.com>
Thu, 9 Jun 2016 18:11:55 +0000 (14:11 -0400)
to make it more readable and extendable.

Signed-off-by: Mykola Golub <mgolub@mirantis.com>
(cherry picked from commit 039cd2d2e3bb6a9c5042c125d2c67ec9adc02c47)

src/tools/rbd_mirror/image_replayer/BootstrapRequest.cc

index b42894243117d5e7a577525e42d764d353eb9ec7..4c1278401a6018b9888b623ffe3ae1c1b1590c24 100644 (file)
@@ -509,11 +509,14 @@ void BootstrapRequest<I>::handle_get_remote_tags(int r) {
       local_image_ctx->journal->get_tag_data();
     dout(20) << ": local tag data: " << tag_data << dendl;
 
-    if (!((tag_data.mirror_uuid == librbd::Journal<>::ORPHAN_MIRROR_UUID &&
-           remote_tag_data.mirror_uuid == librbd::Journal<>::ORPHAN_MIRROR_UUID &&
-           remote_tag_data.predecessor_mirror_uuid == m_local_mirror_uuid) ||
-          (tag_data.mirror_uuid == m_remote_mirror_uuid &&
-           m_client_meta->state == librbd::journal::MIRROR_PEER_STATE_REPLAYING))) {
+    if (tag_data.mirror_uuid == librbd::Journal<>::ORPHAN_MIRROR_UUID &&
+       remote_tag_data.mirror_uuid == librbd::Journal<>::ORPHAN_MIRROR_UUID &&
+       remote_tag_data.predecessor_mirror_uuid == m_local_mirror_uuid) {
+      dout(20) << ": local image was demoted" << dendl;
+    } else if (tag_data.mirror_uuid == m_remote_mirror_uuid &&
+              m_client_meta->state == librbd::journal::MIRROR_PEER_STATE_REPLAYING) {
+      dout(20) << ": local image is in clean replay state" << dendl;
+    } else {
       derr << ": split-brain detected -- skipping image replay" << dendl;
       m_ret_val = -EEXIST;
       close_local_image();