#include "librbd/exclusive_lock/StandardPolicy.h"
#include "librbd/io/AioCompletion.h"
#include "librbd/io/AsyncOperation.h"
+#include "librbd/io/ImageDispatcher.h"
#include "librbd/io/ImageRequestWQ.h"
#include "librbd/io/ObjectDispatcher.h"
#include "librbd/journal/StandardPolicy.h"
this, "librbd::io_work_queue",
cct->_conf.get_val<uint64_t>("rbd_op_thread_timeout"),
thread_pool);
+ io_image_dispatcher = new io::ImageDispatcher<ImageCtx>(this);
io_object_dispatcher = new io::ObjectDispatcher<ImageCtx>(this);
if (cct->_conf.get_val<bool>("rbd_auto_exclusive_lock_until_manual_request")) {
io_work_queue->drain();
delete io_object_dispatcher;
+ delete io_image_dispatcher;
delete journal_policy;
delete exclusive_lock_policy;
class AsyncOperation;
template <typename> class CopyupRequest;
template <typename> class ImageRequestWQ;
+ struct ImageDispatcherInterface;
struct ObjectDispatcherInterface;
}
namespace journal { struct Policy; }
xlist<operation::ResizeRequest<ImageCtx>*> resize_reqs;
io::ImageRequestWQ<ImageCtx> *io_work_queue;
+ io::ImageDispatcherInterface *io_image_dispatcher = nullptr;
io::ObjectDispatcherInterface *io_object_dispatcher = nullptr;
ContextWQ *op_work_queue;
#include "librbd/ObjectMap.h"
#include "librbd/Utils.h"
#include "librbd/io/AioCompletion.h"
+#include "librbd/io/ImageDispatcher.h"
#include "librbd/io/ImageDispatchSpec.h"
#include "librbd/io/ImageRequestWQ.h"
#include "librbd/io/ObjectDispatcherInterface.h"
lderr(cct) << "failed to shut down object dispatcher: "
<< cpp_strerror(r) << dendl;
}
+ send_shut_down_image_dispatcher();
+}
+
+template <typename I>
+void CloseRequest<I>::send_shut_down_image_dispatcher() {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << dendl;
+
+ m_image_ctx->io_image_dispatcher->shut_down(create_context_callback<
+ CloseRequest<I>,
+ &CloseRequest<I>::handle_shut_down_image_dispatcher>(this));
+}
+
+template <typename I>
+void CloseRequest<I>::handle_shut_down_image_dispatcher(int r) {
+ CephContext *cct = m_image_ctx->cct;
+ ldout(cct, 10) << this << " " << __func__ << ": r=" << r << dendl;
+
+ save_result(r);
+ if (r < 0) {
+ lderr(cct) << "failed to shut down image dispatcher: "
+ << cpp_strerror(r) << dendl;
+ }
send_flush_op_work_queue();
}
* SHUT_DOWN_OBJECT_DISPATCHER
* |
* v
+ * SHUT_DOWN_IMAGE_DISPATCHER
+ * |
+ * v
* FLUSH_OP_WORK_QUEUE
* |
* v (skip if no parent)
void send_shut_down_object_dispatcher();
void handle_shut_down_object_dispatcher(int r);
+ void send_shut_down_image_dispatcher();
+ void handle_shut_down_image_dispatcher(int r);
+
void send_flush_op_work_queue();
void handle_flush_op_work_queue(int r);
AioCompletion* aio_comp, Extents&& image_extents,
Request&& request, int op_flags,
const ZTracer::Trace& parent_trace, uint64_t tid)
- : dispatcher_ctx(this), dispatch_layer(image_dispatch_layer),
- aio_comp(aio_comp), image_extents(std::move(image_extents)),
- request(std::move(request)), op_flags(op_flags),
- parent_trace(parent_trace), tid(tid), m_image_ctx(image_ctx) {
+ : dispatcher_ctx(this), image_dispatcher(image_ctx.io_image_dispatcher),
+ dispatch_layer(image_dispatch_layer), aio_comp(aio_comp),
+ image_extents(std::move(image_extents)), request(std::move(request)),
+ op_flags(op_flags), parent_trace(parent_trace), tid(tid),
+ m_image_ctx(image_ctx) {
aio_comp->get();
}
#include "test/librbd/mock/MockObjectMap.h"
#include "test/librbd/mock/MockOperations.h"
#include "test/librbd/mock/MockReadahead.h"
+#include "test/librbd/mock/io/MockImageDispatcher.h"
#include "test/librbd/mock/io/MockImageRequestWQ.h"
#include "test/librbd/mock/io/MockObjectDispatcher.h"
#include "common/RWLock.h"
group_spec(image_ctx.group_spec),
layout(image_ctx.layout),
io_work_queue(new io::MockImageRequestWQ()),
+ io_image_dispatcher(new io::MockImageDispatcher()),
io_object_dispatcher(new io::MockObjectDispatcher()),
op_work_queue(new MockContextWQ()),
readahead_max_bytes(image_ctx.readahead_max_bytes),
delete image_watcher;
delete op_work_queue;
delete io_work_queue;
+ delete io_image_dispatcher;
delete io_object_dispatcher;
}
std::map<uint64_t, io::CopyupRequest<MockImageCtx>*> copyup_list;
io::MockImageRequestWQ *io_work_queue;
+ io::MockImageDispatcher *io_image_dispatcher;
io::MockObjectDispatcher *io_object_dispatcher;
MockContextWQ *op_work_queue;
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_TEST_LIBRBD_MOCK_IO_IMAGE_DISPATCHER_H
+#define CEPH_TEST_LIBRBD_MOCK_IO_IMAGE_DISPATCHER_H
+
+#include "gmock/gmock.h"
+#include "include/Context.h"
+#include "librbd/io/ImageDispatcher.h"
+#include "librbd/io/ImageDispatchSpec.h"
+#include "librbd/io/Types.h"
+
+class Context;
+
+namespace librbd {
+namespace io {
+
+struct ImageDispatchInterface;
+
+struct MockImageDispatcher : public ImageDispatcherInterface {
+public:
+ MOCK_METHOD1(shut_down, void(Context*));
+
+ MOCK_METHOD1(register_dispatch, void(ImageDispatchInterface*));
+ MOCK_METHOD2(shut_down_dispatch, void(ImageDispatchLayer, Context*));
+
+ MOCK_METHOD1(send, void(ImageDispatchSpec<>*));
+};
+
+} // namespace io
+} // namespace librbd
+
+#endif // CEPH_TEST_LIBRBD_MOCK_IO_IMAGE_DISPATCHER_H