mirror of
https://github.com/ceph/ceph
synced 2025-01-11 21:50:26 +00:00
rbd-mirror: stop stale replayers before starting new replayers
If the connection details are tweaked for a remote peer, stop the existing replayer before potentially starting a new replayer against the same remote. Signed-off-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
parent
d52843190d
commit
6a2adca2a4
@ -342,6 +342,19 @@ void Mirror::update_replayers(const map<peer_t, set<int64_t> > &peer_configs)
|
|||||||
{
|
{
|
||||||
dout(20) << "enter" << dendl;
|
dout(20) << "enter" << dendl;
|
||||||
assert(m_lock.is_locked());
|
assert(m_lock.is_locked());
|
||||||
|
|
||||||
|
// remove stale replayers before creating new replayers
|
||||||
|
for (auto it = m_replayers.begin(); it != m_replayers.end();) {
|
||||||
|
peer_t peer = it->first;
|
||||||
|
if (peer_configs.find(peer) == peer_configs.end()) {
|
||||||
|
dout(20) << "removing replayer for " << peer << dendl;
|
||||||
|
// TODO: make async
|
||||||
|
m_replayers.erase(it++);
|
||||||
|
} else {
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (auto &kv : peer_configs) {
|
for (auto &kv : peer_configs) {
|
||||||
const peer_t &peer = kv.first;
|
const peer_t &peer = kv.first;
|
||||||
if (m_replayers.find(peer) == m_replayers.end()) {
|
if (m_replayers.find(peer) == m_replayers.end()) {
|
||||||
@ -356,17 +369,6 @@ void Mirror::update_replayers(const map<peer_t, set<int64_t> > &peer_configs)
|
|||||||
m_replayers.insert(std::make_pair(peer, std::move(replayer)));
|
m_replayers.insert(std::make_pair(peer, std::move(replayer)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make async
|
|
||||||
for (auto it = m_replayers.begin(); it != m_replayers.end();) {
|
|
||||||
peer_t peer = it->first;
|
|
||||||
if (peer_configs.find(peer) == peer_configs.end()) {
|
|
||||||
dout(20) << "removing replayer for " << peer << dendl;
|
|
||||||
m_replayers.erase(it++);
|
|
||||||
} else {
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mirror
|
} // namespace mirror
|
||||||
|
Loading…
Reference in New Issue
Block a user