Skip to content

Commit

Permalink
Merge pull request ceph#52524 from dparmar18/wip-62072
Browse files Browse the repository at this point in the history
tools/cephfs_mirror: only perform actions if init succeed

Reviewed-by: Rishabh Dave <[email protected]>
Reviewed-by: Venky Shankar <[email protected]>
  • Loading branch information
rishabh-d-dave authored Sep 22, 2023
2 parents 0aedb3c + 281c88b commit 9fedc1e
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/tools/cephfs_mirror/Mirror.cc
Original file line number Diff line number Diff line change
Expand Up @@ -318,19 +318,24 @@ void Mirror::handle_enable_mirroring(const Filesystem &filesystem,

std::scoped_lock locker(m_lock);
auto &mirror_action = m_mirror_actions.at(filesystem);
ceph_assert(mirror_action.action_in_progress);

mirror_action.action_in_progress = false;
m_cond.notify_all();
if (r < 0) {
derr << ": failed to initialize FSMirror for filesystem=" << filesystem
<< ": " << cpp_strerror(r) << dendl;
// since init failed, don't assert, just unset it directly
mirror_action.action_in_progress = false;
m_cond.notify_all();
m_service_daemon->add_or_update_fs_attribute(filesystem.fscid,
SERVICE_DAEMON_MIRROR_ENABLE_FAILED_KEY,
true);
return;
}

ceph_assert(mirror_action.action_in_progress);

mirror_action.action_in_progress = false;
m_cond.notify_all();

for (auto &peer : peers) {
mirror_action.fs_mirror->add_peer(peer);
}
Expand All @@ -343,19 +348,24 @@ void Mirror::handle_enable_mirroring(const Filesystem &filesystem, int r) {

std::scoped_lock locker(m_lock);
auto &mirror_action = m_mirror_actions.at(filesystem);
ceph_assert(mirror_action.action_in_progress);

mirror_action.action_in_progress = false;
m_cond.notify_all();

if (r < 0) {
derr << ": failed to initialize FSMirror for filesystem=" << filesystem
<< ": " << cpp_strerror(r) << dendl;
// since init failed, don't assert, just unset it directly
mirror_action.action_in_progress = false;
m_cond.notify_all();
m_service_daemon->add_or_update_fs_attribute(filesystem.fscid,
SERVICE_DAEMON_MIRROR_ENABLE_FAILED_KEY,
true);
return;
}

ceph_assert(mirror_action.action_in_progress);

mirror_action.action_in_progress = false;
m_cond.notify_all();

dout(10) << ": Initialized FSMirror for filesystem=" << filesystem << dendl;
}

Expand Down

0 comments on commit 9fedc1e

Please sign in to comment.