io::ReadResult &&read_result, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- io::DispatchResult* dispatch_result, Context* on_dispatched) {
+ io::DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "image_extents=" << image_extents << dendl;
io::AioCompletion* aio_comp, io::Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- io::DispatchResult* dispatch_result, Context* on_dispatched) {
+ io::DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents
<< dendl;
io::AioCompletion* aio_comp, io::Extents &&image_extents,
uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace,
uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
- io::DispatchResult* dispatch_result, Context* on_dispatched) {
+ io::DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents
<< dendl;
io::AioCompletion* aio_comp, io::Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- io::DispatchResult* dispatch_result, Context* on_dispatched) {
+ io::DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents
<< dendl;
bufferlist &&cmp_bl, bufferlist &&bl, uint64_t *mismatch_offset,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- io::DispatchResult* dispatch_result, Context* on_dispatched) {
+ io::DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents
<< dendl;
io::AioCompletion* aio_comp, io::FlushSource flush_source,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- io::DispatchResult* dispatch_result, Context* on_dispatched) {
+ io::DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << dendl;
io::ReadResult &&read_result, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- io::DispatchResult* dispatch_result, Context* on_dispatched) override;
+ io::DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool write(
io::AioCompletion* aio_comp, io::Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- io::DispatchResult* dispatch_result, Context* on_dispatched) override;
+ io::DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool discard(
io::AioCompletion* aio_comp, io::Extents &&image_extents,
uint32_t discard_granularity_bytes,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- io::DispatchResult* dispatch_result, Context* on_dispatched) override;
+ io::DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool write_same(
io::AioCompletion* aio_comp, io::Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- io::DispatchResult* dispatch_result, Context* on_dispatched) override;
+ io::DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool compare_and_write(
io::AioCompletion* aio_comp, io::Extents &&image_extents,
bufferlist &&cmp_bl, bufferlist &&bl, uint64_t *mismatch_offset,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- io::DispatchResult* dispatch_result, Context* on_dispatched) override;
+ io::DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool flush(
io::AioCompletion* aio_comp, io::FlushSource flush_source,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- io::DispatchResult* dispatch_result, Context* on_dispatched) override;
+ io::DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
void handle_finished(int r, uint64_t tid) override {
}
AioCompletion* aio_comp, Extents &&image_extents, ReadResult &&read_result,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "image_extents=" << image_extents << dendl;
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "image_extents=" << image_extents << dendl;
AioCompletion* aio_comp, Extents &&image_extents,
uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace,
uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "image_extents=" << image_extents << dendl;
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "image_extents=" << image_extents << dendl;
bufferlist &&bl, uint64_t *mismatch_offset, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "image_extents=" << image_extents << dendl;
AioCompletion* aio_comp, FlushSource flush_source,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << dendl;
ReadResult &&read_result, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool write(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool discard(
AioCompletion* aio_comp, Extents &&image_extents,
uint32_t discard_granularity_bytes,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool write_same(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool compare_and_write(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&cmp_bl,
bufferlist &&bl, uint64_t *mismatch_offset, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool flush(
AioCompletion* aio_comp, FlushSource flush_source,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
void handle_finished(int r, uint64_t tid) override {}
ReadResult &&read_result, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) = 0;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) = 0;
virtual bool write(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) = 0;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) = 0;
virtual bool discard(
AioCompletion* aio_comp, Extents &&image_extents,
uint32_t discard_granularity_bytes,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) = 0;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) = 0;
virtual bool write_same(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) = 0;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) = 0;
virtual bool compare_and_write(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&cmp_bl,
bufferlist &&bl, uint64_t *mismatch_offset, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) = 0;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) = 0;
virtual bool flush(
AioCompletion* aio_comp, FlushSource flush_source,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) = 0;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) = 0;
virtual void handle_finished(int r, uint64_t tid) = 0;
}
void ImageDispatchSpec::C_Dispatcher::finish(int r) {
- image_dispatch_spec->finish(r);
+ delete image_dispatch_spec;
}
void ImageDispatchSpec::send() {
image_dispatcher->send(this);
}
-void ImageDispatchSpec::finish(int r) {
- image_dispatcher->finish(r, dispatch_layer, tid);
- delete this;
-}
-
void ImageDispatchSpec::fail(int r) {
dispatch_result = DISPATCH_RESULT_COMPLETE;
aio_comp->fail(r);
aio_comp->image_dispatcher_ctx = &dispatcher_ctx;
aio_comp->get();
}
-
- void finish(int r);
};
} // namespace io
image_dispatch_spec->parent_trace, image_dispatch_spec->tid,
&image_dispatch_spec->image_dispatch_flags,
&image_dispatch_spec->dispatch_result,
+ &image_dispatch_spec->aio_comp->image_dispatcher_ctx,
&image_dispatch_spec->dispatcher_ctx);
}
image_dispatch_spec->parent_trace, image_dispatch_spec->tid,
&image_dispatch_spec->image_dispatch_flags,
&image_dispatch_spec->dispatch_result,
+ &image_dispatch_spec->aio_comp->image_dispatcher_ctx,
&image_dispatch_spec->dispatcher_ctx);
}
image_dispatch_spec->op_flags, image_dispatch_spec->parent_trace,
image_dispatch_spec->tid, &image_dispatch_spec->image_dispatch_flags,
&image_dispatch_spec->dispatch_result,
+ &image_dispatch_spec->aio_comp->image_dispatcher_ctx,
&image_dispatch_spec->dispatcher_ctx);
}
image_dispatch_spec->op_flags, image_dispatch_spec->parent_trace,
image_dispatch_spec->tid, &image_dispatch_spec->image_dispatch_flags,
&image_dispatch_spec->dispatch_result,
+ &image_dispatch_spec->aio_comp->image_dispatcher_ctx,
&image_dispatch_spec->dispatcher_ctx);
}
image_dispatch_spec->parent_trace, image_dispatch_spec->tid,
&image_dispatch_spec->image_dispatch_flags,
&image_dispatch_spec->dispatch_result,
+ &image_dispatch_spec->aio_comp->image_dispatcher_ctx,
&image_dispatch_spec->dispatcher_ctx);
}
image_dispatch_spec->parent_trace, image_dispatch_spec->tid,
&image_dispatch_spec->image_dispatch_flags,
&image_dispatch_spec->dispatch_result,
+ &image_dispatch_spec->aio_comp->image_dispatcher_ctx,
&image_dispatch_spec->dispatcher_ctx);
}
};
AioCompletion* aio_comp, Extents &&image_extents, ReadResult &&read_result,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents
<< dendl;
if (needs_throttle(true, image_extents, tid, image_dispatch_flags,
- dispatch_result, on_dispatched)) {
+ dispatch_result, on_finish, on_dispatched)) {
return true;
}
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents
<< dendl;
if (needs_throttle(false, image_extents, tid, image_dispatch_flags,
- dispatch_result, on_dispatched)) {
+ dispatch_result, on_finish, on_dispatched)) {
return true;
}
AioCompletion* aio_comp, Extents &&image_extents,
uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace,
uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents
<< dendl;
if (needs_throttle(false, image_extents, tid, image_dispatch_flags,
- dispatch_result, on_dispatched)) {
+ dispatch_result, on_finish, on_dispatched)) {
return true;
}
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents
<< dendl;
if (needs_throttle(false, image_extents, tid, image_dispatch_flags,
- dispatch_result, on_dispatched)) {
+ dispatch_result, on_finish, on_dispatched)) {
return true;
}
bufferlist &&bl, uint64_t *mismatch_offset, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents
<< dendl;
if (needs_throttle(false, image_extents, tid, image_dispatch_flags,
- dispatch_result, on_dispatched)) {
+ dispatch_result, on_finish, on_dispatched)) {
return true;
}
AioCompletion* aio_comp, FlushSource flush_source,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << dendl;
bool QosImageDispatch<I>::needs_throttle(
bool read_op, const Extents& image_extents, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
auto extent_length = get_extent_length(image_extents);
bool all_qos_flags_set = false;
if (!read_op) {
m_flush_tracker->start_io(tid);
+ *on_finish = new LambdaContext([this, tid, on_finish=*on_finish](int r) {
+ handle_finished(r, tid);
+ on_finish->complete(r);
+ });
}
*dispatch_result = DISPATCH_RESULT_CONTINUE;
ReadResult &&read_result, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool write(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool discard(
AioCompletion* aio_comp, Extents &&image_extents,
uint32_t discard_granularity_bytes,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool write_same(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool compare_and_write(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&cmp_bl,
bufferlist &&bl, uint64_t *mismatch_offset, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool flush(
AioCompletion* aio_comp, FlushSource flush_source,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
void handle_finished(int r, uint64_t tid) override;
uint32_t flag);
bool needs_throttle(bool read_op, const Extents& image_extents, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched);
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched);
void handle_throttle_ready(Tag&& tag, uint64_t flag);
};
AioCompletion* aio_comp, Extents &&image_extents, ReadResult &&read_result,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << dendl;
- return enqueue(true, tid, dispatch_result, on_dispatched);
+ return enqueue(true, tid, dispatch_result, on_finish, on_dispatched);
}
template <typename I>
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << dendl;
- return enqueue(false, tid, dispatch_result, on_dispatched);
+ return enqueue(false, tid, dispatch_result, on_finish, on_dispatched);
}
template <typename I>
AioCompletion* aio_comp, Extents &&image_extents,
uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace,
uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << dendl;
- return enqueue(false, tid, dispatch_result, on_dispatched);
+ return enqueue(false, tid, dispatch_result, on_finish, on_dispatched);
}
template <typename I>
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << dendl;
- return enqueue(false, tid, dispatch_result, on_dispatched);
+ return enqueue(false, tid, dispatch_result, on_finish, on_dispatched);
}
template <typename I>
bufferlist &&bl, uint64_t *mismatch_offset, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << dendl;
- return enqueue(false, tid, dispatch_result, on_dispatched);
+ return enqueue(false, tid, dispatch_result, on_finish, on_dispatched);
}
template <typename I>
AioCompletion* aio_comp, FlushSource flush_source,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << dendl;
template <typename I>
bool QueueImageDispatch<I>::enqueue(
bool read_op, uint64_t tid, DispatchResult* dispatch_result,
- Context* on_dispatched) {
+ Context** on_finish, Context* on_dispatched) {
if (!m_image_ctx->non_blocking_aio) {
return false;
}
if (!read_op) {
m_flush_tracker->start_io(tid);
+ *on_finish = new LambdaContext([this, tid, on_finish=*on_finish](int r) {
+ handle_finished(r, tid);
+ on_finish->complete(r);
+ });
}
*dispatch_result = DISPATCH_RESULT_CONTINUE;
ReadResult &&read_result, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool write(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool discard(
AioCompletion* aio_comp, Extents &&image_extents,
uint32_t discard_granularity_bytes,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool write_same(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool compare_and_write(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&cmp_bl,
bufferlist &&bl, uint64_t *mismatch_offset, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool flush(
AioCompletion* aio_comp, FlushSource flush_source,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
void handle_finished(int r, uint64_t tid) override;
FlushTracker<ImageCtxT>* m_flush_tracker;
bool enqueue(bool read_op, uint64_t tid, DispatchResult* dispatch_result,
- Context* on_dispatched);
+ Context** on_finish, Context* on_dispatched);
};
AioCompletion* aio_comp, Extents &&image_extents, ReadResult &&read_result,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents
<< dendl;
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents
<< dendl;
AioCompletion* aio_comp, Extents &&image_extents,
uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace,
uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents
<< dendl;
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents
<< dendl;
bufferlist &&bl, uint64_t *mismatch_offset, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << ", image_extents=" << image_extents
<< dendl;
AioCompletion* aio_comp, FlushSource flush_source,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << dendl;
ReadResult &&read_result, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool write(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool discard(
AioCompletion* aio_comp, Extents &&image_extents,
uint32_t discard_granularity_bytes,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool write_same(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool compare_and_write(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&cmp_bl,
bufferlist &&bl, uint64_t *mismatch_offset, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool flush(
AioCompletion* aio_comp, FlushSource flush_source,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
void handle_finished(int r, uint64_t tid) override {}
on_unblocked->complete(0);
}
-template <typename I>
-bool WriteBlockImageDispatch<I>::read(
- AioCompletion* aio_comp, Extents &&image_extents, ReadResult &&read_result,
- int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
- std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
- auto cct = m_image_ctx->cct;
- ldout(cct, 20) << "tid=" << tid << dendl;
-
- return process_io(true, tid, dispatch_result, on_dispatched);
-}
-
template <typename I>
bool WriteBlockImageDispatch<I>::write(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << dendl;
- return process_io(false, tid, dispatch_result, on_dispatched);
+ return process_io(tid, dispatch_result, on_finish, on_dispatched);
}
template <typename I>
AioCompletion* aio_comp, Extents &&image_extents,
uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace,
uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << dendl;
- return process_io(false, tid, dispatch_result, on_dispatched);
+ return process_io(tid, dispatch_result, on_finish, on_dispatched);
}
template <typename I>
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << dendl;
- return process_io(false, tid, dispatch_result, on_dispatched);
+ return process_io(tid, dispatch_result, on_finish, on_dispatched);
}
template <typename I>
bufferlist &&bl, uint64_t *mismatch_offset, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << dendl;
- return process_io(false, tid, dispatch_result, on_dispatched);
+ return process_io(tid, dispatch_result, on_finish, on_dispatched);
}
template <typename I>
AioCompletion* aio_comp, FlushSource flush_source,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) {
auto cct = m_image_ctx->cct;
ldout(cct, 20) << "tid=" << tid << dendl;
return false;
}
- return process_io(false, tid, dispatch_result, on_dispatched);
+ return process_io(tid, dispatch_result, on_finish, on_dispatched);
}
template <typename I>
std::unique_lock locker{m_lock};
auto it = m_in_flight_write_tids.find(tid);
- if (it == m_in_flight_write_tids.end()) {
- // assumed to be a read op
- return;
- }
+ ceph_assert(it != m_in_flight_write_tids.end());
m_in_flight_write_tids.erase(it);
bool writes_blocked = false;
template <typename I>
bool WriteBlockImageDispatch<I>::process_io(
- bool read_op, uint64_t tid, DispatchResult* dispatch_result,
+ uint64_t tid, DispatchResult* dispatch_result, Context** on_finish,
Context* on_dispatched) {
std::unique_lock locker{m_lock};
- if (!read_op) {
- if (m_write_blockers > 0 || !m_on_dispatches.empty()) {
- *dispatch_result = DISPATCH_RESULT_RESTART;
- m_on_dispatches.push_back(on_dispatched);
- return true;
- }
-
- m_in_flight_write_tids.insert(tid);
+ if (m_write_blockers > 0 || !m_on_dispatches.empty()) {
+ *dispatch_result = DISPATCH_RESULT_RESTART;
+ m_on_dispatches.push_back(on_dispatched);
+ return true;
}
+ *on_finish = new LambdaContext([this, tid, on_finish=*on_finish](int r) {
+ handle_finished(r, tid);
+ on_finish->complete(r);
+ });
+ m_in_flight_write_tids.insert(tid);
return false;
}
ReadResult &&read_result, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override {
+ return false;
+ }
bool write(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool discard(
AioCompletion* aio_comp, Extents &&image_extents,
uint32_t discard_granularity_bytes,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool write_same(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool compare_and_write(
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&cmp_bl,
bufferlist &&bl, uint64_t *mismatch_offset, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
bool flush(
AioCompletion* aio_comp, FlushSource flush_source,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override;
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override;
void handle_finished(int r, uint64_t tid) override;
Contexts m_write_blocker_contexts;
Contexts m_unblocked_write_waiter_contexts;
- bool process_io(bool read_op, uint64_t tid, DispatchResult* dispatch_result,
- Context* on_dispatched);
+ bool process_io(uint64_t tid, DispatchResult* dispatch_result,
+ Context** on_finish, Context* on_dispatched);
void flush_io(Context* on_finish);
void handle_blocked_writes(int r);
ReadResult &&read_result, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override {
return false;
}
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override {
return false;
}
uint32_t discard_granularity_bytes,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override {
return false;
}
AioCompletion* aio_comp, Extents &&image_extents, bufferlist &&bl,
int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override {
return false;
}
bufferlist &&bl, uint64_t *mismatch_offset, int op_flags,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override {
return false;
}
AioCompletion* aio_comp, FlushSource flush_source,
const ZTracer::Trace &parent_trace, uint64_t tid,
std::atomic<uint32_t>* image_dispatch_flags,
- DispatchResult* dispatch_result, Context* on_dispatched) override {
+ DispatchResult* dispatch_result, Context** on_finish,
+ Context* on_dispatched) override {
return false;
}