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);
));
}
+ void expect_refresh_image(MockTestImageCtx &mock_image_ctx, int r) {
+ EXPECT_CALL(*mock_image_ctx.state, refresh(_))
+ .WillOnce(CompleteContext(r, mock_image_ctx.image_ctx->op_work_queue));
+ }
+
void expect_unlink_peer(MockTestImageCtx &mock_image_ctx,
MockUnlinkPeerRequest &mock_unlink_peer_request,
uint64_t snap_id, const std::string &peer_uuid,
{{"uuid", cls::rbd::MIRROR_PEER_DIRECTION_TX, "ceph",
"mirror", "mirror uuid"}}, 0);
expect_create_snapshot(mock_image_ctx, 0);
+ expect_refresh_image(mock_image_ctx, 0);
C_SaferCond ctx;
auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", CEPH_NOSNAP,
{{"uuid", cls::rbd::MIRROR_PEER_DIRECTION_TX, "ceph",
"mirror", "mirror uuid"}}, 0);
expect_create_snapshot(mock_image_ctx, 0);
+ expect_refresh_image(mock_image_ctx, 0);
MockUnlinkPeerRequest mock_unlink_peer_request;
auto it = mock_image_ctx.snap_info.rbegin();
auto snap_id = it->first;
{{"uuid", cls::rbd::MIRROR_PEER_DIRECTION_TX, "ceph",
"mirror", "mirror uuid"}}, 0);
expect_create_snapshot(mock_image_ctx, 0);
+ expect_refresh_image(mock_image_ctx, 0);
MockUnlinkPeerRequest mock_unlink_peer_request;
auto it = mock_image_ctx.snap_info.rbegin();
auto snap_id = it->first;
{{"uuid", cls::rbd::MIRROR_PEER_DIRECTION_TX, "ceph",
"mirror", "mirror uuid"}}, 0);
expect_create_snapshot(mock_image_ctx, 0);
+ expect_refresh_image(mock_image_ctx, 0);
MockUnlinkPeerRequest mock_unlink_peer_request;
auto it = mock_image_ctx.snap_info.rbegin();
auto snap_id = it->first;
{"uuid2", cls::rbd::MIRROR_PEER_DIRECTION_TX, "ceph",
"mirror", "mirror uuid"}}, 0);
expect_create_snapshot(mock_image_ctx, 0);
+ expect_refresh_image(mock_image_ctx, 0);
MockUnlinkPeerRequest mock_unlink_peer_request;
auto it = mock_image_ctx.snap_info.rbegin();
auto snap_id = it->first;