template <typename I>
void CreatePrimaryRequest<I>::refresh_image() {
- // if snapshot created via remote RPC, refresh is required to retrieve
- // the snapshot id
- if (m_snap_id == nullptr) {
- unlink_peer();
- return;
- }
-
+ // refresh is required to retrieve the snapshot id (if snapshot
+ // created via remote RPC) and complete flag (regardless)
CephContext *cct = m_image_ctx->cct;
ldout(cct, 15) << dendl;
return;
}
- {
+ if (m_snap_id != nullptr) {
std::shared_lock image_locker{m_image_ctx->image_lock};
*m_snap_id = m_image_ctx->get_snap_id(
cls::rbd::MirrorSnapshotNamespace{}, m_snap_name);
size_t count = 0;
uint64_t unlink_snap_id = 0;
for (auto &snap_it : m_image_ctx->snap_info) {
- auto info = boost::get<cls::rbd::MirrorSnapshotNamespace>(
+ auto info = std::get_if<cls::rbd::MirrorSnapshotNamespace>(
&snap_it.second.snap_namespace);
if (info == nullptr) {
continue;
// or if it's not linked with any peer (happens if mirroring is enabled
// on a pool with no peers configured or if UnlinkPeerRequest gets
// interrupted)
- if (info->mirror_peer_uuids.size() == 0) {
+ if (!info->mirror_peer_uuids.empty() &&
+ info->mirror_peer_uuids.count(peer) == 0) {
+ continue;
+ }
+ if (info->mirror_peer_uuids.empty() || !info->complete) {
peer_uuid = peer;
snap_id = snap_it.first;
break;
}
- if (info->mirror_peer_uuids.count(peer) == 0) {
- continue;
- }
count++;
if (count == max_snapshots) {
unlink_snap_id = snap_it.first;
auto ctx = create_context_callback<
CreatePrimaryRequest<I>,
&CreatePrimaryRequest<I>::handle_unlink_peer>(this);
- auto req = UnlinkPeerRequest<I>::create(m_image_ctx, snap_id, peer_uuid, ctx);
+ auto req = UnlinkPeerRequest<I>::create(m_image_ctx, snap_id, peer_uuid, true,
+ ctx);
req->send();
}