From: Mykola Golub Date: Tue, 3 May 2016 09:48:06 +0000 (+0300) Subject: rbd-mirror: refactor split-brain detection code X-Git-Tag: v11.0.0~260^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=039cd2d2e3bb6a9c5042c125d2c67ec9adc02c47;p=ceph.git rbd-mirror: refactor split-brain detection code to make it more readable and extendable. Signed-off-by: Mykola Golub --- diff --git a/src/tools/rbd_mirror/image_replayer/BootstrapRequest.cc b/src/tools/rbd_mirror/image_replayer/BootstrapRequest.cc index b42894243117..4c1278401a60 100644 --- a/src/tools/rbd_mirror/image_replayer/BootstrapRequest.cc +++ b/src/tools/rbd_mirror/image_replayer/BootstrapRequest.cc @@ -509,11 +509,14 @@ void BootstrapRequest::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();