Merge pull request #52524 from dparmar18/wip-62072

tools/cephfs_mirror: only perform actions if init succeed

Reviewed-by: Rishabh Dave <ridave@redhat.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
This commit is contained in:
Rishabh Dave 2023-09-22 20:15:04 +05:30 committed by GitHub
commit 9fedc1e062
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
}
@ -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;
}