MockBaseRequest mock_base_request;
librbd::MockTestImageCtx* local_image_ctx = nullptr;
+ librbd::MockTestImageCtx* remote_image_ctx = nullptr;
std::string local_image_id;
std::string remote_mirror_uuid;
std::string remote_image_id;
MOCK_CONST_METHOD0(is_local_primary, bool());
MOCK_CONST_METHOD0(is_linked, bool());
- MOCK_METHOD6(create_local_image_request,
+ MOCK_METHOD5(create_local_image_request,
BaseRequest*(Threads<librbd::MockTestImageCtx>*,
librados::IoCtx&,
- librbd::MockTestImageCtx*,
const std::string&,
ProgressContext*,
Context*));
void expect_create_local_image(MockStateBuilder& mock_state_builder,
const std::string& local_image_id, int r) {
EXPECT_CALL(mock_state_builder,
- create_local_image_request(_, _, _, _, _, _))
- .WillOnce(WithArg<5>(
+ create_local_image_request(_, _, _, _, _))
+ .WillOnce(WithArg<4>(
Invoke([this, &mock_state_builder, local_image_id, r](Context* ctx) {
if (r >= 0) {
mock_state_builder.local_image_id = local_image_id;
dout(10) << dendl;
}
-template <typename I>
-BootstrapRequest<I>::~BootstrapRequest() {
- ceph_assert(m_remote_image_ctx == nullptr);
-}
-
template <typename I>
bool BootstrapRequest<I>::is_syncing() const {
std::lock_guard locker{m_lock};
update_progress("OPEN_REMOTE_IMAGE");
- Context *ctx = create_context_callback<
- BootstrapRequest<I>, &BootstrapRequest<I>::handle_open_remote_image>(
- this);
+ auto ctx = create_context_callback<
+ BootstrapRequest<I>,
+ &BootstrapRequest<I>::handle_open_remote_image>(this);
+ ceph_assert(*m_state_builder != nullptr);
OpenImageRequest<I> *request = OpenImageRequest<I>::create(
- m_remote_io_ctx, &m_remote_image_ctx, remote_image_id, false,
- ctx);
+ m_remote_io_ctx, &(*m_state_builder)->remote_image_ctx, remote_image_id,
+ false, ctx);
request->send();
}
void BootstrapRequest<I>::handle_open_remote_image(int r) {
dout(15) << "r=" << r << dendl;
+ ceph_assert(*m_state_builder != nullptr);
if (r < 0) {
derr << "failed to open remote image: " << cpp_strerror(r) << dendl;
- ceph_assert(m_remote_image_ctx == nullptr);
+ ceph_assert((*m_state_builder)->remote_image_ctx == nullptr);
finish(r);
return;
}
- ceph_assert(*m_state_builder != nullptr);
if ((*m_state_builder)->local_image_id.empty()) {
create_local_image();
return;
BootstrapRequest<I>,
&BootstrapRequest<I>::handle_create_local_image>(this);
auto request = (*m_state_builder)->create_local_image_request(
- m_threads, m_local_io_ctx, m_remote_image_ctx, m_global_image_id,
- m_progress_ctx, ctx);
+ m_threads, m_local_io_ctx, m_global_image_id, m_progress_ctx, ctx);
request->send();
}
Context *ctx = create_context_callback<
BootstrapRequest<I>, &BootstrapRequest<I>::handle_image_sync>(this);
m_image_sync = ImageSync<I>::create(
- m_threads, state_builder->local_image_ctx, m_remote_image_ctx,
+ m_threads, state_builder->local_image_ctx, state_builder->remote_image_ctx,
m_local_mirror_uuid, sync_point_handler, m_instance_watcher,
m_progress_ctx, ctx);
m_image_sync->get();
update_progress("CLOSE_REMOTE_IMAGE");
- Context *ctx = create_context_callback<
- BootstrapRequest<I>, &BootstrapRequest<I>::handle_close_remote_image>(
- this);
- CloseImageRequest<I> *request = CloseImageRequest<I>::create(
- &m_remote_image_ctx, ctx);
+ auto ctx = create_context_callback<
+ BootstrapRequest<I>,
+ &BootstrapRequest<I>::handle_close_remote_image>(this);
+ ceph_assert(*m_state_builder != nullptr);
+ auto request = CloseImageRequest<I>::create(
+ &(*m_state_builder)->remote_image_ctx, ctx);
request->send();
}
StateBuilder<ImageCtxT>** state_builder,
bool* do_resync,
Context* on_finish);
- ~BootstrapRequest() override;
bool is_syncing() const;
mutable ceph::mutex m_lock;
bool m_canceled = false;
- ImageCtxT *m_remote_image_ctx = nullptr;
int m_ret_val = 0;
std::string m_local_image_name;
template <typename I>
StateBuilder<I>::~StateBuilder() {
ceph_assert(local_image_ctx == nullptr);
+ ceph_assert(remote_image_ctx == nullptr);
ceph_assert(m_sync_point_handler == nullptr);
}
virtual BaseRequest* create_local_image_request(
Threads<ImageCtxT>* threads,
librados::IoCtx& local_io_ctx,
- ImageCtxT* remote_image_ctx,
const std::string& global_image_id,
ProgressContext* progress_ctx,
Context* on_finish) = 0;
std::string remote_image_id;
librbd::mirror::PromotionState remote_promotion_state =
librbd::mirror::PROMOTION_STATE_NON_PRIMARY;
+ ImageCtxT* remote_image_ctx = nullptr;
protected:
image_sync::SyncPointHandler* m_sync_point_handler = nullptr;
BaseRequest* StateBuilder<I>::create_local_image_request(
Threads<I>* threads,
librados::IoCtx& local_io_ctx,
- I* remote_image_ctx,
const std::string& global_image_id,
ProgressContext* progress_ctx,
Context* on_finish) {
return CreateLocalImageRequest<I>::create(
- threads, local_io_ctx, remote_image_ctx, this->global_image_id,
+ threads, local_io_ctx, this->remote_image_ctx, this->global_image_id,
progress_ctx, this, on_finish);
}
BaseRequest* create_local_image_request(
Threads<ImageCtxT>* threads,
librados::IoCtx& local_io_ctx,
- ImageCtxT* remote_image_ctx,
const std::string& global_image_id,
ProgressContext* progress_ctx,
Context* on_finish) override;
BaseRequest* StateBuilder<I>::create_local_image_request(
Threads<I>* threads,
librados::IoCtx& local_io_ctx,
- I* remote_image_ctx,
const std::string& global_image_id,
ProgressContext* progress_ctx,
Context* on_finish) {
BaseRequest* create_local_image_request(
Threads<ImageCtxT>* threads,
librados::IoCtx& local_io_ctx,
- ImageCtxT* remote_image_ctx,
const std::string& global_image_id,
ProgressContext* progress_ctx,
Context* on_finish) override;