Skip to content

Commit

Permalink
rbd-mirror: refactor split-brain detection code
Browse files Browse the repository at this point in the history
to make it more readable and extendable.

Signed-off-by: Mykola Golub <mgolub@mirantis.com>
  • Loading branch information
Mykola Golub committed Jun 5, 2016
1 parent 21f895f commit 039cd2d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/tools/rbd_mirror/image_replayer/BootstrapRequest.cc
Expand Up @@ -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();
Expand Down

0 comments on commit 039cd2d

Please sign in to comment.