start_in_flight_io(aio_comp);
*dispatch_result = DISPATCH_RESULT_COMPLETE;
- ImageRequest<I>::aio_write(
- m_image_ctx, aio_comp, std::move(image_extents), std::move(bl),
- io_context, op_flags, parent_trace);
+ ImageRequest<I>::aio_write(m_image_ctx, aio_comp, std::move(image_extents),
+ std::move(bl), op_flags, parent_trace);
return true;
}
start_in_flight_io(aio_comp);
*dispatch_result = DISPATCH_RESULT_COMPLETE;
- ImageRequest<I>::aio_discard(
- m_image_ctx, aio_comp, std::move(image_extents), discard_granularity_bytes,
- io_context, parent_trace);
+ ImageRequest<I>::aio_discard(m_image_ctx, aio_comp, std::move(image_extents),
+ discard_granularity_bytes, parent_trace);
return true;
}
start_in_flight_io(aio_comp);
*dispatch_result = DISPATCH_RESULT_COMPLETE;
- ImageRequest<I>::aio_writesame(
- m_image_ctx, aio_comp, std::move(image_extents), std::move(bl),
- io_context, op_flags, parent_trace);
+ ImageRequest<I>::aio_writesame(m_image_ctx, aio_comp,
+ std::move(image_extents), std::move(bl),
+ op_flags, parent_trace);
return true;
}
start_in_flight_io(aio_comp);
*dispatch_result = DISPATCH_RESULT_COMPLETE;
- ImageRequest<I>::aio_compare_and_write(
- m_image_ctx, aio_comp, std::move(image_extents), std::move(cmp_bl),
- std::move(bl), mismatch_offset, io_context, op_flags, parent_trace);
+ ImageRequest<I>::aio_compare_and_write(m_image_ctx, aio_comp,
+ std::move(image_extents),
+ std::move(cmp_bl), std::move(bl),
+ mismatch_offset, op_flags,
+ parent_trace);
return true;
}
template <typename I>
void ImageRequest<I>::aio_write(I *ictx, AioCompletion *c,
- Extents &&image_extents, bufferlist &&bl,
- IOContext io_context, int op_flags,
+ Extents &&image_extents,
+ bufferlist &&bl, int op_flags,
const ZTracer::Trace &parent_trace) {
- ImageWriteRequest<I> req(*ictx, c, std::move(image_extents), std::move(bl),
- io_context, op_flags, parent_trace);
+ ImageWriteRequest<I> req(*ictx, c, std::move(image_extents),
+ std::move(bl), op_flags, parent_trace);
req.send();
}
void ImageRequest<I>::aio_discard(I *ictx, AioCompletion *c,
Extents &&image_extents,
uint32_t discard_granularity_bytes,
- IOContext io_context,
const ZTracer::Trace &parent_trace) {
ImageDiscardRequest<I> req(*ictx, c, std::move(image_extents),
- discard_granularity_bytes, io_context,
- parent_trace);
+ discard_granularity_bytes, parent_trace);
req.send();
}
template <typename I>
void ImageRequest<I>::aio_writesame(I *ictx, AioCompletion *c,
Extents &&image_extents,
- bufferlist &&bl, IOContext io_context,
- int op_flags,
+ bufferlist &&bl, int op_flags,
const ZTracer::Trace &parent_trace) {
ImageWriteSameRequest<I> req(*ictx, c, std::move(image_extents),
- std::move(bl), io_context, op_flags,
- parent_trace);
+ std::move(bl), op_flags, parent_trace);
req.send();
}
bufferlist &&cmp_bl,
bufferlist &&bl,
uint64_t *mismatch_offset,
- IOContext io_context, int op_flags,
+ int op_flags,
const ZTracer::Trace &parent_trace) {
ImageCompareAndWriteRequest<I> req(*ictx, c, std::move(image_extents),
std::move(cmp_bl), std::move(bl),
- mismatch_offset, io_context, op_flags,
- parent_trace);
+ mismatch_offset, op_flags, parent_trace);
req.send();
}
int read_flags,
const ZTracer::Trace &parent_trace)
: ImageRequest<I>(image_ctx, aio_comp, std::move(image_extents),
- io_context, "read", parent_trace),
- m_op_flags(op_flags), m_read_flags(read_flags) {
+ "read", parent_trace),
+ m_io_context(io_context), m_op_flags(op_flags), m_read_flags(read_flags) {
aio_comp->read_result = std::move(read_result);
}
auto &image_extents = this->m_image_extents;
if (image_ctx.cache && image_ctx.readahead_max_bytes > 0 &&
!(m_op_flags & LIBRADOS_OP_FLAG_FADVISE_RANDOM)) {
- readahead(get_image_ctx(&image_ctx), image_extents, this->m_io_context);
+ readahead(get_image_ctx(&image_ctx), image_extents, m_io_context);
}
// map image extents to object extents
aio_comp, {{oe.offset, oe.length, std::move(oe.buffer_extents)}});
auto req = ObjectDispatchSpec::create_read(
&image_ctx, OBJECT_DISPATCH_LAYER_NONE, oe.object_no,
- &req_comp->extents, this->m_io_context, m_op_flags, m_read_flags,
+ &req_comp->extents, m_io_context, m_op_flags, m_read_flags,
this->m_trace, nullptr, req_comp);
req->send();
}
journal_tid = append_journal_event(m_synchronous);
}
- send_object_requests(object_extents, this->m_io_context, journal_tid);
+ // it's very important that IOContext is captured here instead of
+ // e.g. at the API layer so that an up-to-date snap context is used
+ // when owning the exclusive lock
+ send_object_requests(object_extents, image_ctx.get_data_io_context(),
+ journal_tid);
}
update_stats(clip_len);
SnapIds&& snap_ids, int list_snaps_flags, SnapshotDelta* snapshot_delta,
const ZTracer::Trace& parent_trace)
: ImageRequest<I>(image_ctx, aio_comp, std::move(image_extents),
- image_ctx.get_data_io_context(), "list-snaps",
- parent_trace),
+ "list-snaps", parent_trace),
m_snap_ids(std::move(snap_ids)), m_list_snaps_flags(list_snaps_flags),
m_snapshot_delta(snapshot_delta) {
}
IOContext io_context, int op_flags, int read_flags,
const ZTracer::Trace &parent_trace);
static void aio_write(ImageCtxT *ictx, AioCompletion *c,
- Extents &&image_extents, bufferlist &&bl,
- IOContext io_context, int op_flags,
+ Extents &&image_extents,
+ bufferlist &&bl, int op_flags,
const ZTracer::Trace &parent_trace);
static void aio_discard(ImageCtxT *ictx, AioCompletion *c,
Extents &&image_extents,
uint32_t discard_granularity_bytes,
- IOContext io_context,
const ZTracer::Trace &parent_trace);
static void aio_flush(ImageCtxT *ictx, AioCompletion *c,
FlushSource flush_source,
const ZTracer::Trace &parent_trace);
static void aio_writesame(ImageCtxT *ictx, AioCompletion *c,
- Extents &&image_extents, bufferlist &&bl,
- IOContext io_context, int op_flags,
+ Extents &&image_extents,
+ bufferlist &&bl, int op_flags,
const ZTracer::Trace &parent_trace);
-
static void aio_compare_and_write(ImageCtxT *ictx, AioCompletion *c,
Extents &&image_extents,
- bufferlist &&cmp_bl,
- bufferlist &&bl, uint64_t *mismatch_offset,
- IOContext io_context, int op_flags,
+ bufferlist &&cmp_bl, bufferlist &&bl,
+ uint64_t *mismatch_offset, int op_flags,
const ZTracer::Trace &parent_trace);
void send();
ImageCtxT &m_image_ctx;
AioCompletion *m_aio_comp;
Extents m_image_extents;
- IOContext m_io_context;
ZTracer::Trace m_trace;
ImageRequest(ImageCtxT &image_ctx, AioCompletion *aio_comp,
- Extents &&image_extents, IOContext io_context,
- const char *trace_name,
- const ZTracer::Trace &parent_trace)
+ Extents &&image_extents, const char *trace_name,
+ const ZTracer::Trace &parent_trace)
: m_image_ctx(image_ctx), m_aio_comp(aio_comp),
- m_image_extents(std::move(image_extents)), m_io_context(io_context),
+ m_image_extents(std::move(image_extents)),
m_trace(librbd::util::create_trace(image_ctx, trace_name, parent_trace)) {
m_trace.event("start");
}
const char *get_request_type() const override {
return "aio_read";
}
+
private:
+ IOContext m_io_context;
int m_op_flags;
int m_read_flags;
};
using typename ImageRequest<ImageCtxT>::Extents;
AbstractImageWriteRequest(ImageCtxT &image_ctx, AioCompletion *aio_comp,
- Extents &&image_extents, IOContext io_context,
+ Extents &&image_extents,
const char *trace_name,
const ZTracer::Trace &parent_trace)
: ImageRequest<ImageCtxT>(image_ctx, aio_comp, std::move(image_extents),
- io_context, trace_name, parent_trace),
+ trace_name, parent_trace),
m_synchronous(false) {
}
ImageWriteRequest(ImageCtxT &image_ctx, AioCompletion *aio_comp,
Extents &&image_extents, bufferlist &&bl,
- IOContext io_context, int op_flags,
- const ZTracer::Trace &parent_trace)
+ int op_flags, const ZTracer::Trace &parent_trace)
: AbstractImageWriteRequest<ImageCtxT>(
- image_ctx, aio_comp, std::move(image_extents), io_context, "write",
- parent_trace),
+ image_ctx, aio_comp, std::move(image_extents),
+ "write", parent_trace),
m_bl(std::move(bl)), m_op_flags(op_flags) {
}
public:
ImageDiscardRequest(ImageCtxT &image_ctx, AioCompletion *aio_comp,
Extents&& image_extents,
- uint32_t discard_granularity_bytes, IOContext io_context,
+ uint32_t discard_granularity_bytes,
const ZTracer::Trace &parent_trace)
: AbstractImageWriteRequest<ImageCtxT>(
- image_ctx, aio_comp, std::move(image_extents), io_context, "discard",
- parent_trace),
+ image_ctx, aio_comp, std::move(image_extents),
+ "discard", parent_trace),
m_discard_granularity_bytes(discard_granularity_bytes) {
}
ImageFlushRequest(ImageCtxT &image_ctx, AioCompletion *aio_comp,
FlushSource flush_source,
const ZTracer::Trace &parent_trace)
- : ImageRequest<ImageCtxT>(image_ctx, aio_comp, {}, {}, "flush",
- parent_trace),
+ : ImageRequest<ImageCtxT>(image_ctx, aio_comp, {},
+ "flush", parent_trace),
m_flush_source(flush_source) {
}
class ImageWriteSameRequest : public AbstractImageWriteRequest<ImageCtxT> {
public:
ImageWriteSameRequest(ImageCtxT &image_ctx, AioCompletion *aio_comp,
- Extents&& image_extents, bufferlist &&bl,
- IOContext io_context, int op_flags,
+ Extents&& image_extents,
+ bufferlist &&bl, int op_flags,
const ZTracer::Trace &parent_trace)
: AbstractImageWriteRequest<ImageCtxT>(
- image_ctx, aio_comp, std::move(image_extents), io_context, "writesame",
- parent_trace),
+ image_ctx, aio_comp, std::move(image_extents),
+ "writesame", parent_trace),
m_data_bl(std::move(bl)), m_op_flags(op_flags) {
}
using typename ImageRequest<ImageCtxT>::ObjectRequests;
ImageCompareAndWriteRequest(ImageCtxT &image_ctx, AioCompletion *aio_comp,
- Extents &&image_extents, bufferlist &&cmp_bl,
- bufferlist &&bl, uint64_t *mismatch_offset,
- IOContext io_context, int op_flags,
- const ZTracer::Trace &parent_trace)
+ Extents &&image_extents,
+ bufferlist &&cmp_bl, bufferlist &&bl,
+ uint64_t *mismatch_offset, int op_flags,
+ const ZTracer::Trace &parent_trace)
: AbstractImageWriteRequest<ImageCtxT>(
- image_ctx, aio_comp, std::move(image_extents), io_context,
+ image_ctx, aio_comp, std::move(image_extents),
"compare_and_write", parent_trace),
m_cmp_bl(std::move(cmp_bl)), m_bl(std::move(bl)),
m_mismatch_offset(mismatch_offset), m_op_flags(op_flags) {
if (!clipped_io(event.offset, aio_comp)) {
io::ImageRequest<I>::aio_discard(&m_image_ctx, aio_comp,
{{event.offset, event.length}},
- event.discard_granularity_bytes,
- m_image_ctx.get_data_io_context(), {});
+ event.discard_granularity_bytes, {});
}
if (flush_required) {
io::ImageRequest<I>::aio_write(&m_image_ctx, aio_comp,
{{event.offset, event.length}},
std::move(data),
- m_image_ctx.get_data_io_context(), 0, {});
+ 0, {});
}
if (flush_required) {
io::ImageRequest<I>::aio_writesame(&m_image_ctx, aio_comp,
{{event.offset, event.length}},
std::move(data),
- m_image_ctx.get_data_io_context(), 0,
- {});
+ 0, {});
}
if (flush_required) {
{{event.offset, event.length}},
std::move(cmp_data),
std::move(write_data),
- nullptr,
- m_image_ctx.get_data_io_context(),
- 0, {});
+ nullptr, 0, {});
}
if (flush_required) {