Skip to content

Commit

Permalink
librbd: unit test cases and minor fixes for mirror::DisableRequest
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
  • Loading branch information
Jason Dillaman committed Oct 19, 2016
1 parent e368809 commit 281e007
Show file tree
Hide file tree
Showing 4 changed files with 595 additions and 21 deletions.
31 changes: 13 additions & 18 deletions src/librbd/mirror/DisableRequest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ namespace mirror {
using util::create_rados_ack_callback;

template <typename I>
DisableRequest<I>::DisableRequest(I *image_ctx, bool force,
bool remove, Context *on_finish)
DisableRequest<I>::DisableRequest(I *image_ctx, bool force, bool remove,
Context *on_finish)
: m_image_ctx(image_ctx), m_force(force), m_remove(remove),
m_on_finish(on_finish), m_lock("mirror::DisableRequest::m_lock") {
}
Expand Down Expand Up @@ -91,7 +91,7 @@ void DisableRequest<I>::send_get_tag_owner() {
Context *ctx = util::create_context_callback<
klass, &klass::handle_get_tag_owner>(this);

Journal<>::is_tag_owner(m_image_ctx, &m_is_primary, ctx);
Journal<I>::is_tag_owner(m_image_ctx, &m_is_primary, ctx);
}

template <typename I>
Expand Down Expand Up @@ -159,10 +159,9 @@ void DisableRequest<I>::send_notify_mirroring_watcher() {
Context *ctx = util::create_context_callback<
klass, &klass::handle_notify_mirroring_watcher>(this);

MirroringWatcher<>::notify_image_updated(m_image_ctx->md_ctx,
cls::rbd::MIRROR_IMAGE_STATE_DISABLING,
m_image_ctx->id,
m_mirror_image.global_image_id, ctx);
MirroringWatcher<I>::notify_image_updated(
m_image_ctx->md_ctx, cls::rbd::MIRROR_IMAGE_STATE_DISABLING,
m_image_ctx->id, m_mirror_image.global_image_id, ctx);
}

template <typename I>
Expand Down Expand Up @@ -287,7 +286,10 @@ Context *DisableRequest<I>::handle_get_clients(int *result) {
if (m_error_result < 0) {
*result = m_error_result;
return m_on_finish;
} else if (!m_remove) {
return m_on_finish;
}

// no mirror clients to unregister
send_remove_mirror_image();
}
Expand Down Expand Up @@ -395,10 +397,6 @@ Context *DisableRequest<I>::handle_unregister_client(
return m_on_finish;
}

if (!m_remove) {
return m_on_finish;
}

send_get_clients();
return nullptr;
}
Expand Down Expand Up @@ -432,17 +430,14 @@ Context *DisableRequest<I>::handle_remove_mirror_image(int *result) {
if (*result < 0) {
lderr(cct) << "failed to remove mirror image: " << cpp_strerror(*result)
<< dendl;
return m_on_finish;
}

ldout(cct, 20) << this << " " << __func__
<< ": removed image state from rbd_mirroring object" << dendl;

if (m_is_primary) {
send_notify_mirroring_watcher_removed();
return nullptr;
}

return m_on_finish;
send_notify_mirroring_watcher_removed();
return nullptr;
}

template <typename I>
Expand All @@ -454,7 +449,7 @@ void DisableRequest<I>::send_notify_mirroring_watcher_removed() {
Context *ctx = util::create_context_callback<
klass, &klass::handle_notify_mirroring_watcher_removed>(this);

MirroringWatcher<>::notify_image_updated(
MirroringWatcher<I>::notify_image_updated(
m_image_ctx->md_ctx, cls::rbd::MIRROR_IMAGE_STATE_DISABLED, m_image_ctx->id,
m_mirror_image.global_image_id, ctx);
}
Expand Down
6 changes: 3 additions & 3 deletions src/librbd/mirror/DisableRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class DisableRequest {
return new DisableRequest(image_ctx, force, remove, on_finish);
}

DisableRequest(ImageCtxT *image_ctx, bool force, bool remove,
Context *on_finish);

void send();

private:
Expand Down Expand Up @@ -77,9 +80,6 @@ class DisableRequest {
* @endverbatim
*/

DisableRequest(ImageCtxT *image_ctx, bool force, bool remove,
Context *on_finish);

ImageCtxT *m_image_ctx;
bool m_force;
bool m_remove;
Expand Down
1 change: 1 addition & 0 deletions src/test/librbd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ set(unittest_librbd_srcs
journal/test_mock_OpenRequest.cc
journal/test_mock_PromoteRequest.cc
journal/test_mock_Replay.cc
mirror/test_mock_DisableRequest.cc
object_map/test_mock_InvalidateRequest.cc
object_map/test_mock_LockRequest.cc
object_map/test_mock_RefreshRequest.cc
Expand Down

0 comments on commit 281e007

Please sign in to comment.