C_SaferCond on_finish;
auto req = mirror::snapshot::CreatePrimaryRequest<I>::create(
- ictx, mirror_image.global_image_id, 0U, snap_id, &on_finish);
+ ictx, mirror_image.global_image_id, CEPH_NOSNAP, 0U, snap_id, &on_finish);
req->send();
return on_finish.wait();
}
EnableRequest<I>,
&EnableRequest<I>::handle_create_primary_snapshot>(this);
auto req = snapshot::CreatePrimaryRequest<I>::create(
- m_image_ctx, m_mirror_image.global_image_id,
+ m_image_ctx, m_mirror_image.global_image_id, CEPH_NOSNAP,
snapshot::CREATE_PRIMARY_FLAG_IGNORE_EMPTY_PEERS, &m_snap_id, ctx);
req->send();
}
template <typename I>
CreatePrimaryRequest<I>::CreatePrimaryRequest(
- I *image_ctx, const std::string& global_image_id, uint32_t flags,
- uint64_t *snap_id, Context *on_finish)
+ I *image_ctx, const std::string& global_image_id,
+ uint64_t clean_since_snap_id, uint32_t flags, uint64_t *snap_id,
+ Context *on_finish)
: m_image_ctx(image_ctx), m_global_image_id(global_image_id),
- m_flags(flags), m_snap_id(snap_id), m_on_finish(on_finish) {
+ m_clean_since_snap_id(clean_since_snap_id), m_flags(flags),
+ m_snap_id(snap_id), m_on_finish(on_finish) {
m_default_ns_ctx.dup(m_image_ctx->md_ctx);
m_default_ns_ctx.set_namespace("");
}
((m_flags & CREATE_PRIMARY_FLAG_DEMOTED) != 0 ?
cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY_DEMOTED :
cls::rbd::MIRROR_SNAPSHOT_STATE_PRIMARY),
- m_mirror_peer_uuids, "", CEPH_NOSNAP};
+ m_mirror_peer_uuids, "", m_clean_since_snap_id};
CephContext *cct = m_image_ctx->cct;
ldout(cct, 20) << "name=" << m_snap_name << ", "
public:
static CreatePrimaryRequest *create(ImageCtxT *image_ctx,
const std::string& global_image_id,
+ uint64_t clean_since_snap_id,
uint32_t flags, uint64_t *snap_id,
Context *on_finish) {
- return new CreatePrimaryRequest(image_ctx, global_image_id, flags, snap_id,
+ return new CreatePrimaryRequest(image_ctx, global_image_id,
+ clean_since_snap_id, flags, snap_id,
on_finish);
}
CreatePrimaryRequest(ImageCtxT *image_ctx,
const std::string& global_image_id,
- uint32_t flags, uint64_t *snap_id, Context *on_finish);
+ uint64_t clean_since_snap_id, uint32_t flags,
+ uint64_t *snap_id, Context *on_finish);
void send();
ImageCtxT *m_image_ctx;
std::string m_global_image_id;
+ uint64_t m_clean_since_snap_id;
const uint32_t m_flags;
uint64_t *m_snap_id;
Context *m_on_finish;
DemoteRequest<I>, &DemoteRequest<I>::handle_create_snapshot>(this);
auto req = CreatePrimaryRequest<I>::create(
- m_image_ctx, m_global_image_id,
+ m_image_ctx, m_global_image_id, CEPH_NOSNAP,
(snapshot::CREATE_PRIMARY_FLAG_IGNORE_EMPTY_PEERS |
snapshot::CREATE_PRIMARY_FLAG_DEMOTED), nullptr, ctx);
req->send();
&PromoteRequest<I>::handle_create_promote_snapshot>(this);
auto req = CreatePrimaryRequest<I>::create(
- m_image_ctx, m_global_image_id,
+ m_image_ctx, m_global_image_id, CEPH_NOSNAP,
(snapshot::CREATE_PRIMARY_FLAG_IGNORE_EMPTY_PEERS |
snapshot::CREATE_PRIMARY_FLAG_FORCE), nullptr, ctx);
req->send();
expect_create_snapshot(mock_image_ctx, 0);
C_SaferCond ctx;
- auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", 0U, nullptr,
- &ctx);
+ auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", CEPH_NOSNAP,
+ 0U, nullptr, &ctx);
req->send();
ASSERT_EQ(0, ctx.wait());
}
expect_can_create_primary_snapshot(mock_utils, false, false, false);
C_SaferCond ctx;
- auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", 0U, nullptr,
- &ctx);
+ auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", CEPH_NOSNAP,
+ 0U, nullptr, &ctx);
req->send();
ASSERT_EQ(-EINVAL, ctx.wait());
}
"mirror", "mirror uuid"}}, -EINVAL);
C_SaferCond ctx;
- auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", 0U, nullptr,
- &ctx);
+ auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", CEPH_NOSNAP,
+ 0U, nullptr, &ctx);
req->send();
ASSERT_EQ(-EINVAL, ctx.wait());
}
expect_create_snapshot(mock_image_ctx, -EINVAL);
C_SaferCond ctx;
- auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", 0U, nullptr,
- &ctx);
+ auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", CEPH_NOSNAP,
+ 0U, nullptr, &ctx);
req->send();
ASSERT_EQ(-EINVAL, ctx.wait());
}
expect_unlink_peer(mock_image_ctx, mock_unlink_peer_request, snap_id, "uuid",
0);
C_SaferCond ctx;
- auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", 0U, nullptr,
- &ctx);
+ auto req = new MockCreatePrimaryRequest(&mock_image_ctx, "gid", CEPH_NOSNAP,
+ 0U, nullptr, &ctx);
req->send();
ASSERT_EQ(0, ctx.wait());
}
static CreatePrimaryRequest* s_instance;
static CreatePrimaryRequest *create(MockTestImageCtx *image_ctx,
const std::string& global_image_id,
+ uint64_t clean_since_snap_id,
uint32_t flags, uint64_t *snap_id,
Context *on_finish) {
ceph_assert(s_instance != nullptr);
#include "test/librbd/mock/MockOperations.h"
#include "test/librados_test_stub/MockTestMemIoCtxImpl.h"
#include "test/librados_test_stub/MockTestMemRadosClient.h"
-#include "librbd/mirror/snapshot/CreatePrimaryRequest.h"
#include "librbd/mirror/snapshot/UnlinkPeerRequest.h"
#include "librbd/mirror/snapshot/Utils.h"