template <typename I>
void ImageDispatch<I>::set_require_lock(io::Direction direction,
Context* on_finish) {
- auto cct = m_image_ctx->cct;
-
// pause any matching IO from proceeding past this layer
set_require_lock(direction, true);
- auto ctx = new C_Gather(cct, on_finish);
-
- // passive wait for in-flight IO to complete
- m_flush_tracker->flush(ctx->new_sub());
-
- if (direction != io::DIRECTION_READ) {
- // push through an flush for any in-flight writes at lower levels
- auto aio_comp = io::AioCompletion::create_and_start(
- ctx->new_sub(), util::get_image_ctx(m_image_ctx), io::AIO_TYPE_FLUSH);
- auto req = io::ImageDispatchSpec<I>::create_flush(
- *m_image_ctx, io::IMAGE_DISPATCH_LAYER_EXCLUSIVE_LOCK, aio_comp,
- io::FLUSH_SOURCE_INTERNAL, {});
- req->send();
+ if (direction == io::DIRECTION_READ) {
+ on_finish->complete(0);
+ return;
}
- ctx->activate();
+ // push through a flush for any in-flight writes at lower levels
+ auto aio_comp = io::AioCompletion::create_and_start(
+ on_finish, util::get_image_ctx(m_image_ctx), io::AIO_TYPE_FLUSH);
+ auto req = io::ImageDispatchSpec<I>::create_flush(
+ *m_image_ctx, io::IMAGE_DISPATCH_LAYER_EXCLUSIVE_LOCK, aio_comp,
+ io::FLUSH_SOURCE_INTERNAL, {});
+ req->send();
}
template <typename I>