#include "librbd/exclusive_lock/PreAcquireRequest.h"
#include "librbd/exclusive_lock/PostAcquireRequest.h"
#include "librbd/exclusive_lock/PreReleaseRequest.h"
-#include "librbd/io/ImageDispatcher.h"
+#include "librbd/io/ImageDispatcherInterface.h"
#include "librbd/io/ImageRequestWQ.h"
#include "librbd/Utils.h"
#include "common/ceph_mutex.h"
auto ctx = new LambdaContext([this, features, on_init](int r) {
handle_init_complete(r, features, on_init);
});
- m_image_ctx.io_work_queue->block_writes(ctx);
+ m_image_ctx.io_image_dispatcher->block_writes(ctx);
}
template <typename I>
void ExclusiveLock<I>::handle_init_complete(int r, uint64_t features,
Context* on_finish) {
if (r < 0) {
- m_image_ctx.io_work_queue->unblock_writes();
+ m_image_ctx.io_image_dispatcher->unblock_writes();
on_finish->complete(r);
return;
}
m_image_ctx.io_image_dispatcher->register_dispatch(m_image_dispatch);
on_finish = new LambdaContext([this, on_finish](int r) {
- m_image_ctx.io_work_queue->unblock_writes();
+ m_image_ctx.io_image_dispatcher->unblock_writes();
{
std::lock_guard locker{ML<I>::m_lock};
#include "librbd/ObjectMap.h"
#include "librbd/Utils.h"
#include "librbd/exclusive_lock/ImageDispatch.h"
-#include "librbd/io/ImageRequestWQ.h"
+#include "librbd/io/ImageDispatcherInterface.h"
#include "librbd/io/ObjectDispatcherInterface.h"
#define dout_subsys ceph_subsys_rbd
#include "librbd/image/RefreshParentRequest.h"
#include "librbd/io/AioCompletion.h"
#include "librbd/io/ImageDispatchSpec.h"
-#include "librbd/io/ImageRequestWQ.h"
+#include "librbd/io/ImageDispatcherInterface.h"
#include "librbd/journal/Policy.h"
#define dout_subsys ceph_subsys_rbd
RefreshRequest<I>, &RefreshRequest<I>::handle_v2_block_writes>(this);
std::shared_lock owner_locker{m_image_ctx.owner_lock};
- m_image_ctx.io_work_queue->block_writes(ctx);
+ m_image_ctx.io_image_dispatcher->block_writes(ctx);
}
template <typename I>
ceph_assert(m_blocked_writes);
m_blocked_writes = false;
- m_image_ctx.io_work_queue->unblock_writes();
+ m_image_ctx.io_image_dispatcher->unblock_writes();
return send_v2_close_object_map();
}
#include "librbd/ObjectMap.h"
#include "librbd/Utils.h"
#include "librbd/image/RefreshParentRequest.h"
-#include "librbd/io/ImageRequestWQ.h"
+#include "librbd/io/ImageDispatcherInterface.h"
#define dout_subsys ceph_subsys_rbd
#undef dout_prefix
klass, &klass::handle_block_writes>(this);
std::shared_lock owner_locker{m_image_ctx.owner_lock};
- m_image_ctx.io_work_queue->block_writes(ctx);
+ m_image_ctx.io_image_dispatcher->block_writes(ctx);
}
template <typename I>
template <typename I>
void SetSnapRequest<I>::finalize() {
if (m_writes_blocked) {
- m_image_ctx.io_work_queue->unblock_writes();
+ m_image_ctx.io_image_dispatcher->unblock_writes();
m_writes_blocked = false;
}
}
ceph_assert(ceph_mutex_is_locked(m_image_ctx->owner_lock));
auto cct = m_image_ctx->cct;
+ // ensure onwer lock is not held after block_writes completes
+ on_blocked = util::create_async_context_callback(
+ *m_image_ctx, on_blocked);
+
// TODO temp
auto ctx = new C_Gather(cct, on_blocked);
m_image_ctx->io_work_queue->block_writes(ctx->new_sub());
#include "librbd/Journal.h"
#include "librbd/Utils.h"
#include "librbd/image/SetFlagsRequest.h"
-#include "librbd/io/ImageRequestWQ.h"
+#include "librbd/io/ImageDispatcherInterface.h"
#include "librbd/journal/RemoveRequest.h"
#include "librbd/mirror/DisableRequest.h"
#include "librbd/object_map/RemoveRequest.h"
ldout(cct, 20) << this << " " << __func__ << dendl;
std::unique_lock locker{image_ctx.owner_lock};
- image_ctx.io_work_queue->block_writes(create_context_callback<
+ image_ctx.io_image_dispatcher->block_writes(create_context_callback<
DisableFeaturesRequest<I>,
&DisableFeaturesRequest<I>::handle_block_writes>(this));
}
image_ctx.exclusive_lock->unblock_requests();
}
- image_ctx.io_work_queue->unblock_writes();
+ image_ctx.io_image_dispatcher->unblock_writes();
}
image_ctx.state->handle_prepare_lock_complete();
#include "librbd/Journal.h"
#include "librbd/Utils.h"
#include "librbd/image/SetFlagsRequest.h"
-#include "librbd/io/ImageRequestWQ.h"
+#include "librbd/io/ImageDispatcherInterface.h"
#include "librbd/journal/CreateRequest.h"
#include "librbd/mirror/EnableRequest.h"
#include "librbd/object_map/CreateRequest.h"
ldout(cct, 20) << this << " " << __func__ << dendl;
std::unique_lock locker{image_ctx.owner_lock};
- image_ctx.io_work_queue->block_writes(create_context_callback<
+ image_ctx.io_image_dispatcher->block_writes(create_context_callback<
EnableFeaturesRequest<I>,
&EnableFeaturesRequest<I>::handle_block_writes>(this));
}
image_ctx.exclusive_lock->unblock_requests();
}
if (m_writes_blocked) {
- image_ctx.io_work_queue->unblock_writes();
+ image_ctx.io_image_dispatcher->unblock_writes();
}
}
image_ctx.state->handle_prepare_lock_complete();
#include "librbd/Utils.h"
#include "librbd/deep_copy/ObjectCopyRequest.h"
#include "librbd/io/AsyncOperation.h"
-#include "librbd/io/ImageRequestWQ.h"
+#include "librbd/io/ImageDispatcherInterface.h"
#include "librbd/io/ObjectRequest.h"
#include "osdc/Striper.h"
#include <boost/lambda/bind.hpp>
m_async_op = new io::AsyncOperation();
m_async_op->start_op(image_ctx);
- if (!image_ctx.io_work_queue->writes_blocked()) {
+ if (!image_ctx.io_image_dispatcher->writes_blocked()) {
migrate_object();
return;
}
m_async_op->finish_op();
delete m_async_op;
m_async_op = nullptr;
- image_ctx.io_work_queue->wait_on_writes_unblocked(ctx);
+ image_ctx.io_image_dispatcher->wait_on_writes_unblocked(ctx);
}
void handle_start_async_op(int r) {
#include "librbd/Utils.h"
#include "librbd/io/AioCompletion.h"
#include "librbd/io/ImageDispatchSpec.h"
-#include "librbd/io/ImageRequestWQ.h"
+#include "librbd/io/ImageDispatcherInterface.h"
#include "librbd/io/ObjectDispatcherInterface.h"
#include "librbd/operation/TrimRequest.h"
#include "common/dout.h"
CephContext *cct = image_ctx.cct;
ldout(cct, 5) << dendl;
- image_ctx.io_work_queue->block_writes(create_context_callback<
+ image_ctx.io_image_dispatcher->block_writes(create_context_callback<
ResizeRequest<I>, &ResizeRequest<I>::handle_pre_block_writes>(this));
}
if (*result < 0) {
lderr(cct) << "failed to block writes: " << cpp_strerror(*result) << dendl;
- image_ctx.io_work_queue->unblock_writes();
+ image_ctx.io_image_dispatcher->unblock_writes();
return this->create_context_finisher(*result);
}
if (m_new_size < m_original_size && !m_allow_shrink) {
ldout(cct, 1) << "shrinking the image is not permitted" << dendl;
- image_ctx.io_work_queue->unblock_writes();
+ image_ctx.io_image_dispatcher->unblock_writes();
this->async_complete(-EINVAL);
return nullptr;
}
if (*result < 0) {
lderr(cct) << "failed to commit journal entry: " << cpp_strerror(*result)
<< dendl;
- image_ctx.io_work_queue->unblock_writes();
+ image_ctx.io_image_dispatcher->unblock_writes();
return this->create_context_finisher(*result);
}
}
if (m_original_size == m_new_size) {
- image_ctx.io_work_queue->unblock_writes();
+ image_ctx.io_image_dispatcher->unblock_writes();
return this->create_context_finisher(0);
} else if (m_new_size < m_original_size) {
- image_ctx.io_work_queue->unblock_writes();
+ image_ctx.io_image_dispatcher->unblock_writes();
send_flush_cache();
return nullptr;
}
if (*result < 0) {
lderr(cct) << "failed to resize object map: "
<< cpp_strerror(*result) << dendl;
- image_ctx.io_work_queue->unblock_writes();
+ image_ctx.io_image_dispatcher->unblock_writes();
return this->create_context_finisher(*result);
}
if (*result < 0) {
lderr(cct) << "failed to resize object map: "
<< cpp_strerror(*result) << dendl;
- image_ctx.io_work_queue->unblock_writes();
+ image_ctx.io_image_dispatcher->unblock_writes();
return this->create_context_finisher(*result);
}
ldout(cct, 5) << dendl;
std::shared_lock owner_locker{image_ctx.owner_lock};
- image_ctx.io_work_queue->block_writes(create_context_callback<
+ image_ctx.io_image_dispatcher->block_writes(create_context_callback<
ResizeRequest<I>, &ResizeRequest<I>::handle_post_block_writes>(this));
}
ldout(cct, 5) << "r=" << *result << dendl;
if (*result < 0) {
- image_ctx.io_work_queue->unblock_writes();
+ image_ctx.io_image_dispatcher->unblock_writes();
lderr(cct) << "failed to block writes prior to header update: "
<< cpp_strerror(*result) << dendl;
return this->create_context_finisher(*result);
if (*result < 0) {
lderr(cct) << "failed to update image header: " << cpp_strerror(*result)
<< dendl;
- image_ctx.io_work_queue->unblock_writes();
+ image_ctx.io_image_dispatcher->unblock_writes();
return this->create_context_finisher(*result);
}
}
// blocked by PRE_BLOCK_WRITES (grow) or POST_BLOCK_WRITES (shrink) state
- image_ctx.io_work_queue->unblock_writes();
+ image_ctx.io_image_dispatcher->unblock_writes();
}
} // namespace operation
#include "librbd/ImageWatcher.h"
#include "librbd/ObjectMap.h"
#include "librbd/Utils.h"
-#include "librbd/io/ImageRequestWQ.h"
+#include "librbd/io/ImageDispatcherInterface.h"
#include "librbd/mirror/snapshot/SetImageStateRequest.h"
#define dout_subsys ceph_subsys_rbd
CephContext *cct = image_ctx.cct;
ldout(cct, 5) << this << " " << __func__ << dendl;
- image_ctx.io_work_queue->block_writes(create_context_callback<
+ image_ctx.io_image_dispatcher->block_writes(create_context_callback<
SnapshotCreateRequest<I>,
&SnapshotCreateRequest<I>::handle_suspend_aio>(this));
}
CephContext *cct = image_ctx.cct;
ldout(cct, 5) << this << " " << __func__ << dendl;
- image_ctx.io_work_queue->unblock_writes();
+ image_ctx.io_image_dispatcher->unblock_writes();
image_ctx.image_watcher->notify_unquiesce(
m_request_id, create_context_callback<
#include "librbd/ImageCtx.h"
#include "librbd/ObjectMap.h"
#include "librbd/Utils.h"
-#include "librbd/io/ImageRequestWQ.h"
+#include "librbd/io/ImageDispatcherInterface.h"
#include "librbd/io/ObjectDispatcherInterface.h"
#include "librbd/operation/ResizeRequest.h"
#include "osdc/Striper.h"
SnapshotRollbackRequest<I>::~SnapshotRollbackRequest() {
I &image_ctx = this->m_image_ctx;
if (m_blocking_writes) {
- image_ctx.io_work_queue->unblock_writes();
+ image_ctx.io_image_dispatcher->unblock_writes();
}
if (m_object_map) {
m_object_map->put();
ldout(cct, 5) << this << " " << __func__ << dendl;
m_blocking_writes = true;
- image_ctx.io_work_queue->block_writes(create_context_callback<
+ image_ctx.io_image_dispatcher->block_writes(create_context_callback<
SnapshotRollbackRequest<I>,
&SnapshotRollbackRequest<I>::handle_block_writes>(this));
}
}
void expect_block_writes(MockImageCtx &mock_image_ctx, int r) {
- EXPECT_CALL(*mock_image_ctx.io_work_queue, block_writes(_))
+ EXPECT_CALL(*mock_image_ctx.io_image_dispatcher, block_writes(_))
.WillOnce(CompleteContext(r, mock_image_ctx.image_ctx->op_work_queue));
}
void expect_unblock_writes(MockImageCtx &mock_image_ctx) {
- EXPECT_CALL(*mock_image_ctx.io_work_queue, unblock_writes())
+ EXPECT_CALL(*mock_image_ctx.io_image_dispatcher, unblock_writes())
.Times(1);
}
}
void expect_block_writes(MockOperationImageCtx &mock_image_ctx) {
- EXPECT_CALL(*mock_image_ctx.io_work_queue, block_writes(_))
+ EXPECT_CALL(*mock_image_ctx.io_image_dispatcher, block_writes(_))
.WillOnce(CompleteContext(0, mock_image_ctx.image_ctx->op_work_queue));
}
void expect_unblock_writes(MockOperationImageCtx &mock_image_ctx) {
- EXPECT_CALL(*mock_image_ctx.io_work_queue, unblock_writes()).Times(1);
+ EXPECT_CALL(*mock_image_ctx.io_image_dispatcher, unblock_writes()).Times(1);
}
void expect_verify_lock_ownership(MockOperationImageCtx &mock_image_ctx) {
}
void expect_block_writes(MockOperationImageCtx &mock_image_ctx) {
- EXPECT_CALL(*mock_image_ctx.io_work_queue, block_writes(_))
+ EXPECT_CALL(*mock_image_ctx.io_image_dispatcher, block_writes(_))
.WillOnce(CompleteContext(0, mock_image_ctx.image_ctx->op_work_queue));
}
void expect_unblock_writes(MockOperationImageCtx &mock_image_ctx) {
- EXPECT_CALL(*mock_image_ctx.io_work_queue, unblock_writes()).Times(1);
+ EXPECT_CALL(*mock_image_ctx.io_image_dispatcher, unblock_writes()).Times(1);
}
void expect_verify_lock_ownership(MockOperationImageCtx &mock_image_ctx) {
typedef io::ImageDispatchSpec<MockImageCtx> MockIoImageDispatchSpec;
void expect_block_writes(MockImageCtx &mock_image_ctx, int r) {
- EXPECT_CALL(*mock_image_ctx.io_work_queue, block_writes(_))
+ EXPECT_CALL(*mock_image_ctx.io_image_dispatcher, block_writes(_))
.WillOnce(CompleteContext(r, mock_image_ctx.image_ctx->op_work_queue));
}
void expect_unblock_writes(MockImageCtx &mock_image_ctx) {
- EXPECT_CALL(*mock_image_ctx.io_work_queue, unblock_writes())
+ EXPECT_CALL(*mock_image_ctx.io_image_dispatcher, unblock_writes())
.Times(1);
}
}
void expect_block_writes(MockImageCtx &mock_image_ctx) {
- EXPECT_CALL(*mock_image_ctx.io_work_queue, block_writes(_))
+ EXPECT_CALL(*mock_image_ctx.io_image_dispatcher, block_writes(_))
.WillOnce(CompleteContext(0, mock_image_ctx.image_ctx->op_work_queue));
}
}
void expect_unblock_writes(MockImageCtx &mock_image_ctx) {
- EXPECT_CALL(*mock_image_ctx.io_work_queue, unblock_writes())
+ EXPECT_CALL(*mock_image_ctx.io_image_dispatcher, unblock_writes())
.Times(1);
}
typedef ResizeRequest<MockOperationImageCtx> MockResizeRequest;
void expect_block_writes(MockOperationImageCtx &mock_image_ctx, int r) {
- EXPECT_CALL(*mock_image_ctx.io_work_queue, block_writes(_))
+ EXPECT_CALL(*mock_image_ctx.io_image_dispatcher, block_writes(_))
.WillOnce(CompleteContext(r, mock_image_ctx.image_ctx->op_work_queue));
}
void expect_unblock_writes(MockOperationImageCtx &mock_image_ctx) {
- EXPECT_CALL(*mock_image_ctx.io_work_queue, unblock_writes())
+ EXPECT_CALL(*mock_image_ctx.io_image_dispatcher, unblock_writes())
.Times(1);
}
void expect_block_writes(MockExclusiveLockImageCtx &mock_image_ctx,
MockImageDispatch& mock_image_dispatch) {
- EXPECT_CALL(*mock_image_ctx.io_work_queue, block_writes(_))
+ EXPECT_CALL(*mock_image_ctx.io_image_dispatcher, block_writes(_))
.WillOnce(CompleteContext(0, mock_image_ctx.image_ctx->op_work_queue));
}
void expect_unblock_writes(MockExclusiveLockImageCtx &mock_image_ctx) {
- EXPECT_CALL(*mock_image_ctx.io_work_queue, unblock_writes());
+ EXPECT_CALL(*mock_image_ctx.io_image_dispatcher, unblock_writes());
}
void expect_register_dispatch(MockExclusiveLockImageCtx &mock_image_ctx) {