From: Jason Dillaman Date: Tue, 5 May 2020 20:02:58 +0000 (-0400) Subject: librbd: created new api::Io helper methods X-Git-Tag: wip-pdonnell-testing-20200918.022351~1255^2~7 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=938753f079bf752eb87d3884b3bda6b6683c98ec;p=ceph-ci.git librbd: created new api::Io helper methods These will be invoked by the user API and wrap various user API specific logic. Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/CMakeLists.txt b/src/librbd/CMakeLists.txt index fe914202f3d..746e1a6cdb2 100644 --- a/src/librbd/CMakeLists.txt +++ b/src/librbd/CMakeLists.txt @@ -27,6 +27,7 @@ set(librbd_internal_srcs api/DiffIterate.cc api/Group.cc api/Image.cc + api/Io.cc api/Migration.cc api/Mirror.cc api/Namespace.cc diff --git a/src/librbd/api/DiffIterate.cc b/src/librbd/api/DiffIterate.cc index d0dffb11dfd..a5419e05e83 100644 --- a/src/librbd/api/DiffIterate.cc +++ b/src/librbd/api/DiffIterate.cc @@ -250,7 +250,7 @@ int DiffIterate::diff_iterate(I *ictx, std::shared_lock owner_locker{ictx->owner_lock}; auto aio_comp = io::AioCompletion::create_and_start(&flush_ctx, ictx, io::AIO_TYPE_FLUSH); - auto req = io::ImageDispatchSpec::create_flush_request( + auto req = io::ImageDispatchSpec::create_flush( *ictx, io::IMAGE_DISPATCH_LAYER_INTERNAL_START, aio_comp, io::FLUSH_SOURCE_INTERNAL, {}); req->send(); diff --git a/src/librbd/api/Io.cc b/src/librbd/api/Io.cc new file mode 100644 index 00000000000..b1de3018bea --- /dev/null +++ b/src/librbd/api/Io.cc @@ -0,0 +1,372 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#include "librbd/api/Io.h" +#include "common/dout.h" +#include "common/errno.h" +#include "common/Cond.h" +#include "common/EventTrace.h" +#include "librbd/ImageCtx.h" +#include "librbd/internal.h" +#include "librbd/Utils.h" +#include "librbd/io/AioCompletion.h" +#include "librbd/io/ImageDispatchSpec.h" +#include "librbd/io/Types.h" + +#define dout_subsys ceph_subsys_rbd +#undef dout_prefix +#define dout_prefix *_dout << "librbd::api::Io " << __func__ << ": " + +namespace librbd { +namespace api { + +namespace { + +template +bool is_valid_io(I& image_ctx, io::AioCompletion* aio_comp) { + auto cct = image_ctx.cct; + + if (!image_ctx.data_ctx.is_valid()) { + lderr(cct) << "missing data pool" << dendl; + + aio_comp->fail(-ENODEV); + return false; + } + + return true; +} + +} // anonymous namespace + +template +ssize_t Io::read( + I &image_ctx, uint64_t off, uint64_t len, io::ReadResult &&read_result, + int op_flags) { + auto cct = image_ctx.cct; + + ldout(cct, 20) << "ictx=" << &image_ctx << ", off=" << off << ", " + << "len = " << len << dendl; + + C_SaferCond ctx; + auto aio_comp = io::AioCompletion::create(&ctx); + aio_read(image_ctx, aio_comp, off, len, std::move(read_result), op_flags, + false); + return ctx.wait(); +} + +template +ssize_t Io::write( + I &image_ctx, uint64_t off, uint64_t len, bufferlist &&bl, int op_flags) { + auto cct = image_ctx.cct; + ldout(cct, 20) << "ictx=" << &image_ctx << ", off=" << off << ", " + << "len = " << len << dendl; + + image_ctx.image_lock.lock_shared(); + int r = clip_io(util::get_image_ctx(&image_ctx), off, &len); + image_ctx.image_lock.unlock_shared(); + if (r < 0) { + lderr(cct) << "invalid IO request: " << cpp_strerror(r) << dendl; + return r; + } + + C_SaferCond ctx; + auto aio_comp = io::AioCompletion::create(&ctx); + aio_write(image_ctx, aio_comp, off, len, std::move(bl), op_flags, false); + + r = ctx.wait(); + if (r < 0) { + return r; + } + return len; +} + +template +ssize_t Io::discard( + I &image_ctx, uint64_t off, uint64_t len, + uint32_t discard_granularity_bytes) { + auto cct = image_ctx.cct; + ldout(cct, 20) << "ictx=" << &image_ctx << ", off=" << off << ", " + << "len = " << len << dendl; + + image_ctx.image_lock.lock_shared(); + int r = clip_io(util::get_image_ctx(&image_ctx), off, &len); + image_ctx.image_lock.unlock_shared(); + if (r < 0) { + lderr(cct) << "invalid IO request: " << cpp_strerror(r) << dendl; + return r; + } + + C_SaferCond ctx; + auto aio_comp = io::AioCompletion::create(&ctx); + aio_discard(image_ctx, aio_comp, off, len, discard_granularity_bytes, false); + + r = ctx.wait(); + if (r < 0) { + return r; + } + return len; +} + +template +ssize_t Io::write_same( + I &image_ctx, uint64_t off, uint64_t len, bufferlist &&bl, int op_flags) { + auto cct = image_ctx.cct; + ldout(cct, 20) << "ictx=" << &image_ctx << ", off=" << off << ", " + << "len = " << len << ", data_len " << bl.length() << dendl; + + image_ctx.image_lock.lock_shared(); + int r = clip_io(util::get_image_ctx(&image_ctx), off, &len); + image_ctx.image_lock.unlock_shared(); + if (r < 0) { + lderr(cct) << "invalid IO request: " << cpp_strerror(r) << dendl; + return r; + } + + C_SaferCond ctx; + auto aio_comp = io::AioCompletion::create(&ctx); + aio_write_same(image_ctx, aio_comp, off, len, std::move(bl), op_flags, false); + + r = ctx.wait(); + if (r < 0) { + return r; + } + return len; +} + +template +ssize_t Io::compare_and_write( + I &image_ctx, uint64_t off, uint64_t len, bufferlist &&cmp_bl, + bufferlist &&bl, uint64_t *mismatch_off, int op_flags) { + auto cct = image_ctx.cct; + ldout(cct, 20) << "compare_and_write ictx=" << &image_ctx << ", off=" + << off << ", " << "len = " << len << dendl; + + image_ctx.image_lock.lock_shared(); + int r = clip_io(util::get_image_ctx(&image_ctx), off, &len); + image_ctx.image_lock.unlock_shared(); + if (r < 0) { + lderr(cct) << "invalid IO request: " << cpp_strerror(r) << dendl; + return r; + } + + C_SaferCond ctx; + auto aio_comp = io::AioCompletion::create(&ctx); + aio_compare_and_write(image_ctx, aio_comp, off, len, std::move(cmp_bl), + std::move(bl), mismatch_off, op_flags, false); + + r = ctx.wait(); + if (r < 0) { + return r; + } + return len; +} + +template +int Io::flush(I &image_ctx) { + auto cct = image_ctx.cct; + ldout(cct, 20) << "ictx=" << &image_ctx << dendl; + + C_SaferCond ctx; + auto aio_comp = io::AioCompletion::create(&ctx); + aio_flush(image_ctx, aio_comp, false); + + int r = ctx.wait(); + if (r < 0) { + return r; + } + + return 0; +} + +template +void Io::aio_read(I &image_ctx, io::AioCompletion *aio_comp, uint64_t off, + uint64_t len, io::ReadResult &&read_result, int op_flags, + bool native_async) { + auto cct = image_ctx.cct; + FUNCTRACE(cct); + ZTracer::Trace trace; + if (image_ctx.blkin_trace_all) { + trace.init("wq: read", &image_ctx.trace_endpoint); + trace.event("start"); + } + + aio_comp->init_time(util::get_image_ctx(&image_ctx), io::AIO_TYPE_READ); + ldout(cct, 20) << "ictx=" << &image_ctx << ", " + << "completion=" << aio_comp << ", off=" << off << ", " + << "len=" << len << ", " << "flags=" << op_flags << dendl; + + if (native_async && image_ctx.event_socket.is_valid()) { + aio_comp->set_event_notify(true); + } + + if (!is_valid_io(image_ctx, aio_comp)) { + return; + } + + auto req = io::ImageDispatchSpec::create_read( + image_ctx, io::IMAGE_DISPATCH_LAYER_API_START, aio_comp, {{off, len}}, + std::move(read_result), op_flags, {}); + req->send(); +} + +template +void Io::aio_write(I &image_ctx, io::AioCompletion *aio_comp, uint64_t off, + uint64_t len, bufferlist &&bl, int op_flags, + bool native_async) { + auto cct = image_ctx.cct; + FUNCTRACE(cct); + ZTracer::Trace trace; + if (image_ctx.blkin_trace_all) { + trace.init("wq: write", &image_ctx.trace_endpoint); + trace.event("init"); + } + + aio_comp->init_time(util::get_image_ctx(&image_ctx), io::AIO_TYPE_WRITE); + ldout(cct, 20) << "ictx=" << &image_ctx << ", " + << "completion=" << aio_comp << ", off=" << off << ", " + << "len=" << len << ", flags=" << op_flags << dendl; + + if (native_async && image_ctx.event_socket.is_valid()) { + aio_comp->set_event_notify(true); + } + + if (!is_valid_io(image_ctx, aio_comp)) { + return; + } + + auto req = io::ImageDispatchSpec::create_write( + image_ctx, io::IMAGE_DISPATCH_LAYER_API_START, aio_comp, {{off, len}}, + std::move(bl), op_flags, {}, 0); + req->send(); +} + +template +void Io::aio_discard(I &image_ctx, io::AioCompletion *aio_comp, uint64_t off, + uint64_t len, uint32_t discard_granularity_bytes, + bool native_async) { + auto cct = image_ctx.cct; + FUNCTRACE(cct); + ZTracer::Trace trace; + if (image_ctx.blkin_trace_all) { + trace.init("wq: discard", &image_ctx.trace_endpoint); + trace.event("init"); + } + + aio_comp->init_time(util::get_image_ctx(&image_ctx), io::AIO_TYPE_DISCARD); + ldout(cct, 20) << "ictx=" << &image_ctx << ", " + << "completion=" << aio_comp << ", off=" << off << ", " + << "len=" << len << dendl; + + if (native_async && image_ctx.event_socket.is_valid()) { + aio_comp->set_event_notify(true); + } + + if (!is_valid_io(image_ctx, aio_comp)) { + return; + } + + auto req = io::ImageDispatchSpec::create_discard( + image_ctx, io::IMAGE_DISPATCH_LAYER_API_START, aio_comp, off, len, + discard_granularity_bytes, {}, 0); + req->send(); +} + +template +void Io::aio_write_same(I &image_ctx, io::AioCompletion *aio_comp, + uint64_t off, uint64_t len, bufferlist &&bl, + int op_flags, bool native_async) { + auto cct = image_ctx.cct; + FUNCTRACE(cct); + ZTracer::Trace trace; + if (image_ctx.blkin_trace_all) { + trace.init("wq: writesame", &image_ctx.trace_endpoint); + trace.event("init"); + } + + aio_comp->init_time(util::get_image_ctx(&image_ctx), io::AIO_TYPE_WRITESAME); + ldout(cct, 20) << "ictx=" << &image_ctx << ", " + << "completion=" << aio_comp << ", off=" << off << ", " + << "len=" << len << ", data_len = " << bl.length() << ", " + << "flags=" << op_flags << dendl; + + if (native_async && image_ctx.event_socket.is_valid()) { + aio_comp->set_event_notify(true); + } + + if (!is_valid_io(image_ctx, aio_comp)) { + return; + } + + auto req = io::ImageDispatchSpec::create_write_same( + image_ctx, io::IMAGE_DISPATCH_LAYER_API_START, aio_comp, off, len, + std::move(bl), op_flags, {}, 0); + req->send(); +} + +template +void Io::aio_compare_and_write(I &image_ctx, io::AioCompletion *aio_comp, + uint64_t off, uint64_t len, + bufferlist &&cmp_bl, + bufferlist &&bl, uint64_t *mismatch_off, + int op_flags, bool native_async) { + auto cct = image_ctx.cct; + FUNCTRACE(cct); + ZTracer::Trace trace; + if (image_ctx.blkin_trace_all) { + trace.init("wq: compare_and_write", &image_ctx.trace_endpoint); + trace.event("init"); + } + + aio_comp->init_time(util::get_image_ctx(&image_ctx), + io::AIO_TYPE_COMPARE_AND_WRITE); + ldout(cct, 20) << "ictx=" << &image_ctx << ", " + << "completion=" << aio_comp << ", off=" << off << ", " + << "len=" << len << dendl; + + if (native_async && image_ctx.event_socket.is_valid()) { + aio_comp->set_event_notify(true); + } + + if (!is_valid_io(image_ctx, aio_comp)) { + return; + } + + auto req = io::ImageDispatchSpec::create_compare_and_write( + image_ctx, io::IMAGE_DISPATCH_LAYER_API_START, aio_comp, {{off, len}}, + std::move(cmp_bl), std::move(bl), mismatch_off, op_flags, {}, 0); + req->send(); +} + +template +void Io::aio_flush(I &image_ctx, io::AioCompletion *aio_comp, + bool native_async) { + auto cct = image_ctx.cct; + FUNCTRACE(cct); + ZTracer::Trace trace; + if (image_ctx.blkin_trace_all) { + trace.init("wq: flush", &image_ctx.trace_endpoint); + trace.event("init"); + } + + aio_comp->init_time(util::get_image_ctx(&image_ctx), io::AIO_TYPE_FLUSH); + ldout(cct, 20) << "ictx=" << &image_ctx << ", " + << "completion=" << aio_comp << dendl; + + if (native_async && image_ctx.event_socket.is_valid()) { + aio_comp->set_event_notify(true); + } + + if (!is_valid_io(image_ctx, aio_comp)) { + return; + } + + auto req = io::ImageDispatchSpec::create_flush( + image_ctx, io::IMAGE_DISPATCH_LAYER_API_START, aio_comp, + io::FLUSH_SOURCE_USER, {}); + req->send(); +} + +} // namespace api +} // namespace librbd + +template class librbd::api::Io; diff --git a/src/librbd/api/Io.h b/src/librbd/api/Io.h new file mode 100644 index 00000000000..95120d499f1 --- /dev/null +++ b/src/librbd/api/Io.h @@ -0,0 +1,60 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef LIBRBD_API_IO_H +#define LIBRBD_API_IO_H + +#include "include/int_types.h" +#include "librbd/io/ReadResult.h" + +namespace librbd { + +struct ImageCtx; +namespace io { struct AioCompletion; } + +namespace api { + +template +struct Io { + static ssize_t read(ImageCtxT &image_ctx, uint64_t off, uint64_t len, + io::ReadResult &&read_result, int op_flags); + static ssize_t write(ImageCtxT &image_ctx, uint64_t off, uint64_t len, + bufferlist &&bl, int op_flags); + static ssize_t discard(ImageCtxT &image_ctx, uint64_t off, uint64_t len, + uint32_t discard_granularity_bytes); + static ssize_t write_same(ImageCtxT &image_ctx, uint64_t off, uint64_t len, + bufferlist &&bl, int op_flags); + static ssize_t compare_and_write(ImageCtxT &image_ctx, uint64_t off, + uint64_t len, bufferlist &&cmp_bl, + bufferlist &&bl, uint64_t *mismatch_off, + int op_flags); + static int flush(ImageCtxT &image_ctx); + + static void aio_read(ImageCtxT &image_ctx, io::AioCompletion *c, uint64_t off, + uint64_t len, io::ReadResult &&read_result, int op_flags, + bool native_async); + static void aio_write(ImageCtxT &image_ctx, io::AioCompletion *c, + uint64_t off, uint64_t len, bufferlist &&bl, + int op_flags, bool native_async); + static void aio_discard(ImageCtxT &image_ctx, io::AioCompletion *c, + uint64_t off, uint64_t len, + uint32_t discard_granularity_bytes, + bool native_async); + static void aio_write_same(ImageCtxT &image_ctx, io::AioCompletion *c, + uint64_t off, uint64_t len, bufferlist &&bl, + int op_flags, bool native_async); + static void aio_compare_and_write(ImageCtxT &image_ctx, io::AioCompletion *c, + uint64_t off, uint64_t len, + bufferlist &&cmp_bl, bufferlist &&bl, + uint64_t *mismatch_off, int op_flags, + bool native_async); + static void aio_flush(ImageCtxT &image_ctx, io::AioCompletion *c, + bool native_async); +}; + +} // namespace api +} // namespace librbd + +extern template class librbd::api::Io; + +#endif // LIBRBD_API_IO_H diff --git a/src/librbd/exclusive_lock/ImageDispatch.cc b/src/librbd/exclusive_lock/ImageDispatch.cc index 087286f84c2..70fc0777364 100644 --- a/src/librbd/exclusive_lock/ImageDispatch.cc +++ b/src/librbd/exclusive_lock/ImageDispatch.cc @@ -78,7 +78,7 @@ void ImageDispatch::set_require_lock(io::Direction direction, // 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::create_flush_request( + auto req = io::ImageDispatchSpec::create_flush( *m_image_ctx, io::IMAGE_DISPATCH_LAYER_EXCLUSIVE_LOCK, aio_comp, io::FLUSH_SOURCE_INTERNAL, {}); req->send(); diff --git a/src/librbd/image/CloseRequest.cc b/src/librbd/image/CloseRequest.cc index 9296e42da91..0ddcfb82fa2 100644 --- a/src/librbd/image/CloseRequest.cc +++ b/src/librbd/image/CloseRequest.cc @@ -168,7 +168,7 @@ void CloseRequest::send_flush() { CloseRequest, &CloseRequest::handle_flush>(this); auto aio_comp = io::AioCompletion::create_and_start(ctx, m_image_ctx, io::AIO_TYPE_FLUSH); - auto req = io::ImageDispatchSpec::create_flush_request( + auto req = io::ImageDispatchSpec::create_flush( *m_image_ctx, io::IMAGE_DISPATCH_LAYER_INTERNAL_START, aio_comp, io::FLUSH_SOURCE_INTERNAL, {}); req->send(); diff --git a/src/librbd/image/RefreshRequest.cc b/src/librbd/image/RefreshRequest.cc index 25c30816711..2ced9c8b1af 100644 --- a/src/librbd/image/RefreshRequest.cc +++ b/src/librbd/image/RefreshRequest.cc @@ -1229,7 +1229,7 @@ Context *RefreshRequest::send_flush_aio() { RefreshRequest, &RefreshRequest::handle_flush_aio>(this); auto aio_comp = io::AioCompletion::create_and_start( ctx, util::get_image_ctx(&m_image_ctx), io::AIO_TYPE_FLUSH); - auto req = io::ImageDispatchSpec::create_flush_request( + auto req = io::ImageDispatchSpec::create_flush( m_image_ctx, io::IMAGE_DISPATCH_LAYER_INTERNAL_START, aio_comp, io::FLUSH_SOURCE_INTERNAL, {}); req->send(); diff --git a/src/librbd/io/ImageDispatchSpec.h b/src/librbd/io/ImageDispatchSpec.h index e489e94b23a..1c12f3afcb4 100644 --- a/src/librbd/io/ImageDispatchSpec.h +++ b/src/librbd/io/ImageDispatchSpec.h @@ -107,7 +107,7 @@ public: ZTracer::Trace parent_trace; uint64_t tid; - static ImageDispatchSpec* create_read_request( + static ImageDispatchSpec* create_read( ImageCtxT &image_ctx, ImageDispatchLayer image_dispatch_layer, AioCompletion *aio_comp, Extents &&image_extents, ReadResult &&read_result, int op_flags, @@ -118,7 +118,7 @@ public: op_flags, parent_trace, 0); } - static ImageDispatchSpec* create_discard_request( + static ImageDispatchSpec* create_discard( ImageCtxT &image_ctx, ImageDispatchLayer image_dispatch_layer, AioCompletion *aio_comp, uint64_t off, uint64_t len, uint32_t discard_granularity_bytes, const ZTracer::Trace &parent_trace, @@ -129,7 +129,7 @@ public: 0, parent_trace, tid); } - static ImageDispatchSpec* create_write_request( + static ImageDispatchSpec* create_write( ImageCtxT &image_ctx, ImageDispatchLayer image_dispatch_layer, AioCompletion *aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, @@ -139,7 +139,7 @@ public: op_flags, parent_trace, tid); } - static ImageDispatchSpec* create_write_same_request( + static ImageDispatchSpec* create_write_same( ImageCtxT &image_ctx, ImageDispatchLayer image_dispatch_layer, AioCompletion *aio_comp, uint64_t off, uint64_t len, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, @@ -149,7 +149,7 @@ public: op_flags, parent_trace, tid); } - static ImageDispatchSpec* create_compare_and_write_request( + static ImageDispatchSpec* create_compare_and_write( ImageCtxT &image_ctx, ImageDispatchLayer image_dispatch_layer, AioCompletion *aio_comp, Extents &&image_extents, bufferlist &&cmp_bl, bufferlist &&bl, uint64_t *mismatch_offset, @@ -162,7 +162,7 @@ public: op_flags, parent_trace, tid); } - static ImageDispatchSpec* create_flush_request( + static ImageDispatchSpec* create_flush( ImageCtxT &image_ctx, ImageDispatchLayer image_dispatch_layer, AioCompletion *aio_comp, FlushSource flush_source, const ZTracer::Trace &parent_trace) { diff --git a/src/librbd/io/ImageRequestWQ.cc b/src/librbd/io/ImageRequestWQ.cc index 4172179286b..dbd558bdc40 100644 --- a/src/librbd/io/ImageRequestWQ.cc +++ b/src/librbd/io/ImageRequestWQ.cc @@ -252,7 +252,7 @@ void ImageRequestWQ::aio_read(AioCompletion *c, uint64_t off, uint64_t len, std::shared_lock owner_locker{m_image_ctx.owner_lock}; if (m_image_ctx.non_blocking_aio || writes_blocked() || !writes_empty() || require_lock_on_read()) { - queue(ImageDispatchSpec::create_read_request( + queue(ImageDispatchSpec::create_read( m_image_ctx, IMAGE_DISPATCH_LAYER_API_START, c, {{off, len}}, std::move(read_result), op_flags, trace)); } else { @@ -296,7 +296,7 @@ void ImageRequestWQ::aio_write(AioCompletion *c, uint64_t off, uint64_t len, m_queued_or_blocked_io_tids.insert(tid); } - ImageDispatchSpec *req = ImageDispatchSpec::create_write_request( + ImageDispatchSpec *req = ImageDispatchSpec::create_write( m_image_ctx, IMAGE_DISPATCH_LAYER_API_START, c, {{off, len}}, std::move(bl), op_flags, trace, tid); @@ -338,7 +338,7 @@ void ImageRequestWQ::aio_discard(AioCompletion *c, uint64_t off, m_queued_or_blocked_io_tids.insert(tid); } - ImageDispatchSpec *req = ImageDispatchSpec::create_discard_request( + ImageDispatchSpec *req = ImageDispatchSpec::create_discard( m_image_ctx, IMAGE_DISPATCH_LAYER_API_START, c, off, len, discard_granularity_bytes, trace, tid); @@ -371,7 +371,7 @@ void ImageRequestWQ::aio_flush(AioCompletion *c, bool native_async) { auto tid = ++m_last_tid; - ImageDispatchSpec *req = ImageDispatchSpec::create_flush_request( + ImageDispatchSpec *req = ImageDispatchSpec::create_flush( m_image_ctx, IMAGE_DISPATCH_LAYER_API_START, c, FLUSH_SOURCE_USER, trace); { @@ -422,7 +422,7 @@ void ImageRequestWQ::aio_writesame(AioCompletion *c, uint64_t off, m_queued_or_blocked_io_tids.insert(tid); } - ImageDispatchSpec *req = ImageDispatchSpec::create_write_same_request( + ImageDispatchSpec *req = ImageDispatchSpec::create_write_same( m_image_ctx, IMAGE_DISPATCH_LAYER_API_START, c, off, len, std::move(bl), op_flags, trace, tid); @@ -466,7 +466,7 @@ void ImageRequestWQ::aio_compare_and_write(AioCompletion *c, m_queued_or_blocked_io_tids.insert(tid); } - ImageDispatchSpec *req = ImageDispatchSpec::create_compare_and_write_request( + ImageDispatchSpec *req = ImageDispatchSpec::create_compare_and_write( m_image_ctx, IMAGE_DISPATCH_LAYER_API_START, c, {{off, len}}, std::move(cmp_bl), std::move(bl), mismatch_off, op_flags, trace, tid); diff --git a/src/librbd/io/QueueImageDispatch.cc b/src/librbd/io/QueueImageDispatch.cc index 4ca31a4b967..1b370d08b15 100644 --- a/src/librbd/io/QueueImageDispatch.cc +++ b/src/librbd/io/QueueImageDispatch.cc @@ -256,7 +256,7 @@ template void QueueImageDispatch::flush_image(Context* on_finish) { auto aio_comp = AioCompletion::create_and_start( on_finish, util::get_image_ctx(m_image_ctx), librbd::io::AIO_TYPE_FLUSH); - auto req = ImageDispatchSpec::create_flush_request( + auto req = ImageDispatchSpec::create_flush( *m_image_ctx, IMAGE_DISPATCH_LAYER_QUEUE, aio_comp, FLUSH_SOURCE_INTERNAL, {}); req->send(); diff --git a/src/librbd/operation/ResizeRequest.cc b/src/librbd/operation/ResizeRequest.cc index 4d8c51bb2a3..d90b81fe974 100644 --- a/src/librbd/operation/ResizeRequest.cc +++ b/src/librbd/operation/ResizeRequest.cc @@ -196,7 +196,7 @@ void ResizeRequest::send_flush_cache() { ResizeRequest, &ResizeRequest::handle_flush_cache>(this); auto aio_comp = io::AioCompletion::create_and_start( ctx, util::get_image_ctx(&image_ctx), io::AIO_TYPE_FLUSH); - auto req = io::ImageDispatchSpec::create_flush_request( + auto req = io::ImageDispatchSpec::create_flush( image_ctx, io::IMAGE_DISPATCH_LAYER_INTERNAL_START, aio_comp, io::FLUSH_SOURCE_INTERNAL, {}); req->send(); diff --git a/src/test/librbd/image/test_mock_RefreshRequest.cc b/src/test/librbd/image/test_mock_RefreshRequest.cc index 8bf2c56eb07..93f30186406 100644 --- a/src/test/librbd/image/test_mock_RefreshRequest.cc +++ b/src/test/librbd/image/test_mock_RefreshRequest.cc @@ -110,7 +110,7 @@ struct ImageDispatchSpec { static ImageDispatchSpec* s_instance; AioCompletion *aio_comp = nullptr; - static ImageDispatchSpec* create_flush_request( + static ImageDispatchSpec* create_flush( librbd::MockRefreshImageCtx &image_ctx, ImageDispatchLayer dispatch_layer, AioCompletion *aio_comp, FlushSource flush_source, const ZTracer::Trace &parent_trace) { diff --git a/src/test/librbd/io/test_mock_ImageRequestWQ.cc b/src/test/librbd/io/test_mock_ImageRequestWQ.cc index b3e24ff50cf..67b98432bc5 100644 --- a/src/test/librbd/io/test_mock_ImageRequestWQ.cc +++ b/src/test/librbd/io/test_mock_ImageRequestWQ.cc @@ -45,7 +45,7 @@ struct ImageDispatchSpec { std::atomic image_dispatch_flags = {0}; - static ImageDispatchSpec* create_write_request( + static ImageDispatchSpec* create_write( librbd::MockTestImageCtx &image_ctx, ImageDispatchLayer dispatch_layer, AioCompletion *aio_comp, Extents &&image_extents, bufferlist &&bl, int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid) { @@ -54,7 +54,7 @@ struct ImageDispatchSpec { return s_instance; } - static ImageDispatchSpec* create_flush_request( + static ImageDispatchSpec* create_flush( librbd::MockTestImageCtx &image_ctx, ImageDispatchLayer dispatch_layer, AioCompletion *aio_comp, FlushSource flush_source, const ZTracer::Trace &parent_trace) { diff --git a/src/test/librbd/journal/test_Replay.cc b/src/test/librbd/journal/test_Replay.cc index 1fa86eea492..e5d1c0beff5 100644 --- a/src/test/librbd/journal/test_Replay.cc +++ b/src/test/librbd/journal/test_Replay.cc @@ -861,7 +861,7 @@ TEST_F(TestJournalReplay, ObjectPosition) { C_SaferCond flush_ctx; aio_comp = librbd::io::AioCompletion::create_and_start( &flush_ctx, ictx, librbd::io::AIO_TYPE_FLUSH); - auto req = librbd::io::ImageDispatchSpec<>::create_flush_request( + auto req = librbd::io::ImageDispatchSpec<>::create_flush( *ictx, librbd::io::IMAGE_DISPATCH_LAYER_INTERNAL_START, aio_comp, librbd::io::FLUSH_SOURCE_INTERNAL, {}); req->send(); diff --git a/src/test/librbd/operation/test_mock_ResizeRequest.cc b/src/test/librbd/operation/test_mock_ResizeRequest.cc index 96dd70127a4..707bdf45813 100644 --- a/src/test/librbd/operation/test_mock_ResizeRequest.cc +++ b/src/test/librbd/operation/test_mock_ResizeRequest.cc @@ -32,7 +32,7 @@ struct ImageDispatchSpec { static ImageDispatchSpec* s_instance; AioCompletion *aio_comp = nullptr; - static ImageDispatchSpec* create_flush_request( + static ImageDispatchSpec* create_flush( MockImageCtx &image_ctx, ImageDispatchLayer dispatch_layer, AioCompletion *aio_comp, FlushSource flush_source, const ZTracer::Trace &parent_trace) { diff --git a/src/test/rbd_mirror/test_ImageSync.cc b/src/test/rbd_mirror/test_ImageSync.cc index d97804fefed..7587760c25f 100644 --- a/src/test/rbd_mirror/test_ImageSync.cc +++ b/src/test/rbd_mirror/test_ImageSync.cc @@ -35,7 +35,7 @@ int flush(librbd::ImageCtx *image_ctx) { C_SaferCond ctx; auto aio_comp = librbd::io::AioCompletion::create_and_start( &ctx, image_ctx, librbd::io::AIO_TYPE_FLUSH); - auto req = librbd::io::ImageDispatchSpec<>::create_flush_request( + auto req = librbd::io::ImageDispatchSpec<>::create_flush( *image_ctx, librbd::io::IMAGE_DISPATCH_LAYER_INTERNAL_START, aio_comp, librbd::io::FLUSH_SOURCE_INTERNAL, {}); req->send();