From de95d862f57b56738e04d77f2351622f83f17f4a Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Wed, 15 Feb 2017 15:38:39 -0500 Subject: [PATCH] librbd: move IO-related classes to new io namespace Signed-off-by: Jason Dillaman --- src/librbd/CMakeLists.txt | 26 +-- src/librbd/ExclusiveLock.cc | 22 +-- src/librbd/Group.cc | 2 +- src/librbd/Group.h | 11 +- src/librbd/ImageCtx.cc | 22 +-- src/librbd/ImageCtx.h | 14 +- src/librbd/ImageWatcher.cc | 2 +- src/librbd/Journal.cc | 22 +-- src/librbd/Journal.h | 14 +- src/librbd/LibrbdWriteback.cc | 12 +- src/librbd/cache/ImageWriteback.cc | 36 ++-- .../exclusive_lock/PreReleaseRequest.cc | 10 +- src/librbd/image/CloseRequest.cc | 14 +- src/librbd/image/CloseRequest.h | 4 +- src/librbd/image/CreateRequest.cc | 2 +- src/librbd/image/RefreshRequest.cc | 10 +- src/librbd/image/SetSnapRequest.cc | 6 +- src/librbd/internal.cc | 50 ++--- src/librbd/internal.h | 4 +- src/librbd/{ => io}/AioCompletion.cc | 19 +- src/librbd/{ => io}/AioCompletion.h | 34 ++-- src/librbd/{ => io}/CopyupRequest.cc | 28 +-- src/librbd/{ => io}/CopyupRequest.h | 25 ++- .../ImageRequest.cc} | 157 +++++++-------- .../{AioImageRequest.h => io/ImageRequest.h} | 118 +++++------ .../ImageRequestWQ.cc} | 117 +++++------ .../ImageRequestWQ.h} | 44 +++-- .../ObjectRequest.cc} | 186 +++++++++--------- .../ObjectRequest.h} | 178 +++++++++-------- src/librbd/io/Types.h | 31 +++ src/librbd/journal/Replay.cc | 60 +++--- src/librbd/journal/Replay.h | 16 +- src/librbd/librbd.cc | 99 +++++----- .../operation/DisableFeaturesRequest.cc | 6 +- src/librbd/operation/EnableFeaturesRequest.cc | 6 +- src/librbd/operation/FlattenRequest.cc | 6 +- src/librbd/operation/ResizeRequest.cc | 18 +- src/librbd/operation/SnapshotCreateRequest.cc | 16 +- .../operation/SnapshotRollbackRequest.cc | 6 +- src/librbd/operation/TrimRequest.cc | 16 +- src/test/librbd/CMakeLists.txt | 4 +- .../test_mock_PreReleaseRequest.cc | 6 +- .../librbd/image/test_mock_RefreshRequest.cc | 8 +- .../test_mock_ImageRequest.cc} | 123 ++++++------ src/test/librbd/journal/test_Entries.cc | 16 +- src/test/librbd/journal/test_Replay.cc | 70 +++---- src/test/librbd/journal/test_mock_Replay.cc | 109 +++++----- src/test/librbd/mock/MockContextWQ.h | 2 + src/test/librbd/mock/MockImageCtx.h | 8 +- src/test/librbd/mock/MockJournal.h | 10 +- .../MockImageRequestWQ.h} | 10 +- .../test_mock_DisableFeaturesRequest.cc | 6 +- .../test_mock_EnableFeaturesRequest.cc | 6 +- .../operation/test_mock_ResizeRequest.cc | 4 +- .../test_mock_SnapshotCreateRequest.cc | 4 +- .../test_mock_SnapshotRollbackRequest.cc | 4 +- ...st_ConsistencyGroups.cc => test_Groups.cc} | 6 +- src/test/librbd/test_ImageWatcher.cc | 4 +- src/test/librbd/test_fixture.cc | 4 +- src/test/librbd/test_internal.cc | 58 +++--- src/test/librbd/test_main.cc | 4 +- src/test/librbd/test_mirroring.cc | 6 +- src/test/librbd/test_mock_ExclusiveLock.cc | 10 +- src/test/librbd/test_mock_Journal.cc | 12 +- .../image_sync/test_mock_ObjectCopyRequest.cc | 16 +- src/test/rbd_mirror/test_ImageReplayer.cc | 12 +- src/test/rbd_mirror/test_ImageSync.cc | 36 ++-- 67 files changed, 1054 insertions(+), 973 deletions(-) rename src/librbd/{ => io}/AioCompletion.cc (93%) rename src/librbd/{ => io}/AioCompletion.h (92%) rename src/librbd/{ => io}/CopyupRequest.cc (93%) rename src/librbd/{ => io}/CopyupRequest.h (82%) rename src/librbd/{AioImageRequest.cc => io/ImageRequest.cc} (81%) rename src/librbd/{AioImageRequest.h => io/ImageRequest.h} (60%) rename src/librbd/{AioImageRequestWQ.cc => io/ImageRequestWQ.cc} (76%) rename src/librbd/{AioImageRequestWQ.h => io/ImageRequestWQ.h} (70%) rename src/librbd/{AioObjectRequest.cc => io/ObjectRequest.cc} (75%) rename src/librbd/{AioObjectRequest.h => io/ObjectRequest.h} (63%) create mode 100644 src/librbd/io/Types.h rename src/test/librbd/{test_mock_AioImageRequest.cc => io/test_mock_ImageRequest.cc} (61%) rename src/test/librbd/mock/{MockAioImageRequestWQ.h => io/MockImageRequestWQ.h} (66%) rename src/test/librbd/{test_ConsistencyGroups.cc => test_Groups.cc} (95%) diff --git a/src/librbd/CMakeLists.txt b/src/librbd/CMakeLists.txt index e1739aa54af..e0fb674d013 100644 --- a/src/librbd/CMakeLists.txt +++ b/src/librbd/CMakeLists.txt @@ -4,14 +4,9 @@ add_library(rbd_types STATIC WatchNotifyTypes.cc) set(librbd_internal_srcs - AioCompletion.cc - AioImageRequest.cc - AioImageRequestWQ.cc - AioObjectRequest.cc AsyncObjectThrottle.cc AsyncOperation.cc AsyncRequest.cc - CopyupRequest.cc DiffIterate.cc ExclusiveLock.cc Group.cc @@ -30,14 +25,6 @@ set(librbd_internal_srcs cache/ImageWriteback.cc cache/PassthroughImageCache.cc Watcher.cc - watcher/Types.cc - watcher/RewatchRequest.cc - managed_lock/AcquireRequest.cc - managed_lock/BreakRequest.cc - managed_lock/GetLockerRequest.cc - managed_lock/ReleaseRequest.cc - managed_lock/ReacquireRequest.cc - managed_lock/Utils.cc exclusive_lock/AutomaticPolicy.cc exclusive_lock/PreAcquireRequest.cc exclusive_lock/PostAcquireRequest.cc @@ -51,6 +38,11 @@ set(librbd_internal_srcs image/SetFlagsRequest.cc image/SetSnapRequest.cc image_watcher/NotifyLockOwner.cc + io/AioCompletion.cc + io/CopyupRequest.cc + io/ImageRequest.cc + io/ImageRequestWQ.cc + io/ObjectRequest.cc journal/RemoveRequest.cc journal/CreateRequest.cc journal/OpenRequest.cc @@ -58,6 +50,12 @@ set(librbd_internal_srcs journal/Replay.cc journal/StandardPolicy.cc journal/Utils.cc + managed_lock/AcquireRequest.cc + managed_lock/BreakRequest.cc + managed_lock/GetLockerRequest.cc + managed_lock/ReacquireRequest.cc + managed_lock/ReleaseRequest.cc + managed_lock/Utils.cc mirror/DisableRequest.cc mirror/EnableRequest.cc object_map/CreateRequest.cc @@ -91,6 +89,8 @@ set(librbd_internal_srcs operation/SnapshotUnprotectRequest.cc operation/SnapshotLimitRequest.cc operation/TrimRequest.cc + watcher/RewatchRequest.cc + watcher/Types.cc ${CMAKE_SOURCE_DIR}/src/common/ContextCompletion.cc) add_library(rbd_api STATIC librbd.cc) diff --git a/src/librbd/ExclusiveLock.cc b/src/librbd/ExclusiveLock.cc index 1a7a76ccb34..19ca6e42e13 100644 --- a/src/librbd/ExclusiveLock.cc +++ b/src/librbd/ExclusiveLock.cc @@ -2,12 +2,12 @@ // vim: ts=8 sw=2 smarttab #include "librbd/ExclusiveLock.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/ImageWatcher.h" #include "librbd/ImageState.h" #include "librbd/exclusive_lock/PreAcquireRequest.h" #include "librbd/exclusive_lock/PostAcquireRequest.h" #include "librbd/exclusive_lock/PreReleaseRequest.h" +#include "librbd/io/ImageRequestWQ.h" #include "librbd/Utils.h" #include "common/Mutex.h" #include "common/dout.h" @@ -83,8 +83,8 @@ void ExclusiveLock::init(uint64_t features, Context *on_init) { ML::set_state_initializing(); } - m_image_ctx.aio_work_queue->block_writes(new C_InitComplete(this, features, - on_init)); + m_image_ctx.io_work_queue->block_writes(new C_InitComplete(this, features, + on_init)); } template @@ -116,7 +116,7 @@ void ExclusiveLock::handle_init_complete(uint64_t features) { ldout(m_image_ctx.cct, 10) << "features=" << features << dendl; if ((features & RBD_FEATURE_JOURNALING) != 0) { - m_image_ctx.aio_work_queue->set_require_lock_on_read(); + m_image_ctx.io_work_queue->set_require_lock_on_read(); } Mutex::Locker locker(ML::m_lock); @@ -129,11 +129,11 @@ void ExclusiveLock::shutdown_handler(int r, Context *on_finish) { { RWLock::WLocker owner_locker(m_image_ctx.owner_lock); - m_image_ctx.aio_work_queue->clear_require_lock_on_read(); + m_image_ctx.io_work_queue->clear_require_lock_on_read(); m_image_ctx.exclusive_lock = nullptr; } - m_image_ctx.aio_work_queue->unblock_writes(); + m_image_ctx.io_work_queue->unblock_writes(); m_image_ctx.image_watcher->flush(on_finish); } @@ -237,8 +237,8 @@ void ExclusiveLock::handle_post_acquired_lock(int r) { if (r >= 0) { m_image_ctx.image_watcher->notify_acquired_lock(); - m_image_ctx.aio_work_queue->clear_require_lock_on_read(); - m_image_ctx.aio_work_queue->unblock_writes(); + m_image_ctx.io_work_queue->clear_require_lock_on_read(); + m_image_ctx.io_work_queue->unblock_writes(); } on_finish->complete(r); @@ -270,7 +270,7 @@ void ExclusiveLock::post_release_lock_handler(bool shutting_down, int r, if (r >= 0) { m_image_ctx.image_watcher->notify_released_lock(); - if (m_image_ctx.aio_work_queue->is_lock_request_needed()) { + if (m_image_ctx.io_work_queue->is_lock_request_needed()) { // if we have blocked IO -- re-request the lock RWLock::RLocker owner_locker(m_image_ctx.owner_lock); ML::acquire_lock(nullptr); @@ -279,12 +279,12 @@ void ExclusiveLock::post_release_lock_handler(bool shutting_down, int r, } else { { RWLock::WLocker owner_locker(m_image_ctx.owner_lock); - m_image_ctx.aio_work_queue->clear_require_lock_on_read(); + m_image_ctx.io_work_queue->clear_require_lock_on_read(); m_image_ctx.exclusive_lock = nullptr; } if (r >= 0) { - m_image_ctx.aio_work_queue->unblock_writes(); + m_image_ctx.io_work_queue->unblock_writes(); } m_image_ctx.image_watcher->notify_released_lock(); diff --git a/src/librbd/Group.cc b/src/librbd/Group.cc index fd37e9a349a..8e3d82b2e8c 100644 --- a/src/librbd/Group.cc +++ b/src/librbd/Group.cc @@ -3,10 +3,10 @@ #include "common/errno.h" -#include "librbd/AioCompletion.h" #include "librbd/Group.h" #include "librbd/ImageState.h" #include "librbd/Utils.h" +#include "librbd/io/AioCompletion.h" #define dout_subsys ceph_subsys_rbd #undef dout_prefix diff --git a/src/librbd/Group.h b/src/librbd/Group.h index 9dcc9eb508f..87b638b9c8c 100644 --- a/src/librbd/Group.h +++ b/src/librbd/Group.h @@ -1,10 +1,18 @@ // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab + #ifndef CEPH_LIBRBD_GROUP_H #define CEPH_LIBRBD_GROUP_H +#include "include/rados/librados.hpp" +#include "include/rbd/librbd.hpp" +#include +#include + namespace librbd { +struct ImageCtx; + // Consistency groups functions int group_create(librados::IoCtx& io_ctx, const char *imgname); int group_remove(librados::IoCtx& io_ctx, const char *group_name); @@ -16,6 +24,7 @@ int group_image_remove(librados::IoCtx& group_ioctx, const char *group_name, int group_image_list(librados::IoCtx& group_ioctx, const char *group_name, std::vector *images); int image_get_group(ImageCtx *ictx, group_spec_t *group_spec); -} + +} // namespace librbd #endif // CEPH_LIBRBD_GROUP_H diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index fa6724d4b85..d16c0a57256 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -11,25 +11,25 @@ #include "common/WorkQueue.h" #include "common/Timer.h" -#include "librbd/AioImageRequestWQ.h" -#include "librbd/AioCompletion.h" #include "librbd/AsyncOperation.h" #include "librbd/AsyncRequest.h" #include "librbd/ExclusiveLock.h" -#include "librbd/exclusive_lock/AutomaticPolicy.h" -#include "librbd/exclusive_lock/StandardPolicy.h" #include "librbd/internal.h" #include "librbd/ImageCtx.h" #include "librbd/ImageState.h" #include "librbd/ImageWatcher.h" #include "librbd/Journal.h" -#include "librbd/journal/StandardPolicy.h" #include "librbd/LibrbdAdminSocketHook.h" #include "librbd/ObjectMap.h" #include "librbd/Operations.h" #include "librbd/operation/ResizeRequest.h" #include "librbd/Utils.h" #include "librbd/LibrbdWriteback.h" +#include "librbd/exclusive_lock/AutomaticPolicy.h" +#include "librbd/exclusive_lock/StandardPolicy.h" +#include "librbd/io/AioCompletion.h" +#include "librbd/io/ImageRequestWQ.h" +#include "librbd/journal/StandardPolicy.h" #include "osdc/Striper.h" #include @@ -189,7 +189,7 @@ struct C_InvalidateCache : public Context { state(new ImageState<>(this)), operations(new Operations<>(*this)), exclusive_lock(nullptr), object_map(nullptr), - aio_work_queue(nullptr), op_work_queue(nullptr), + io_work_queue(nullptr), op_work_queue(nullptr), asok_hook(nullptr) { md_ctx.dup(p); @@ -200,9 +200,9 @@ struct C_InvalidateCache : public Context { memset(&header, 0, sizeof(header)); ThreadPool *thread_pool_singleton = get_thread_pool_instance(cct); - aio_work_queue = new AioImageRequestWQ(this, "librbd::aio_work_queue", - cct->_conf->rbd_op_thread_timeout, - thread_pool_singleton); + io_work_queue = new io::ImageRequestWQ( + this, "librbd::io_work_queue", cct->_conf->rbd_op_thread_timeout, + thread_pool_singleton); op_work_queue = new ContextWQ("librbd::op_work_queue", cct->_conf->rbd_op_thread_timeout, thread_pool_singleton); @@ -242,12 +242,12 @@ struct C_InvalidateCache : public Context { md_ctx.aio_flush(); data_ctx.aio_flush(); op_work_queue->drain(); - aio_work_queue->drain(); + io_work_queue->drain(); delete journal_policy; delete exclusive_lock_policy; delete op_work_queue; - delete aio_work_queue; + delete io_work_queue; delete operations; delete state; } diff --git a/src/librbd/ImageCtx.h b/src/librbd/ImageCtx.h index f8c5b0c4288..0f089c16831 100644 --- a/src/librbd/ImageCtx.h +++ b/src/librbd/ImageCtx.h @@ -38,10 +38,7 @@ class SafeTimer; namespace librbd { - class AioCompletion; - class AioImageRequestWQ; class AsyncOperation; - class CopyupRequest; template class ExclusiveLock; template class ImageState; template class ImageWatcher; @@ -53,6 +50,11 @@ namespace librbd { namespace cache { struct ImageCache; } namespace exclusive_lock { struct Policy; } + namespace io { + class AioCompletion; + class ImageRequestWQ; + class CopyupRequest; + } namespace journal { struct Policy; } namespace operation { @@ -136,7 +138,7 @@ namespace librbd { Readahead readahead; uint64_t total_bytes_read; - std::map copyup_list; + std::map copyup_list; xlist async_ops; xlist*> async_requests; @@ -150,8 +152,8 @@ namespace librbd { xlist*> resize_reqs; - AioImageRequestWQ *aio_work_queue; - xlist completed_reqs; + io::ImageRequestWQ *io_work_queue; + xlist completed_reqs; EventSocket event_socket; ContextWQ *op_work_queue; diff --git a/src/librbd/ImageWatcher.cc b/src/librbd/ImageWatcher.cc index 27f76509519..b38d0821174 100644 --- a/src/librbd/ImageWatcher.cc +++ b/src/librbd/ImageWatcher.cc @@ -2,7 +2,6 @@ // vim: ts=8 sw=2 smarttab #include "librbd/ImageWatcher.h" -#include "librbd/AioCompletion.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageCtx.h" #include "librbd/ImageState.h" @@ -12,6 +11,7 @@ #include "librbd/Utils.h" #include "librbd/exclusive_lock/Policy.h" #include "librbd/image_watcher/NotifyLockOwner.h" +#include "librbd/io/AioCompletion.h" #include "include/encoding.h" #include "common/errno.h" #include "common/WorkQueue.h" diff --git a/src/librbd/Journal.cc b/src/librbd/Journal.cc index ec0d7cb5125..b959bbd7281 100644 --- a/src/librbd/Journal.cc +++ b/src/librbd/Journal.cc @@ -2,13 +2,8 @@ // vim: ts=8 sw=2 smarttab #include "librbd/Journal.h" -#include "librbd/AioImageRequestWQ.h" -#include "librbd/AioObjectRequest.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageCtx.h" -#include "librbd/journal/OpenRequest.h" -#include "librbd/journal/PromoteRequest.h" -#include "librbd/journal/Replay.h" #include "cls/journal/cls_journal_types.h" #include "journal/Journaler.h" #include "journal/Policy.h" @@ -19,8 +14,13 @@ #include "common/Timer.h" #include "common/WorkQueue.h" #include "include/rados/librados.hpp" -#include "librbd/journal/RemoveRequest.h" +#include "librbd/io/ImageRequestWQ.h" +#include "librbd/io/ObjectRequest.h" #include "librbd/journal/CreateRequest.h" +#include "librbd/journal/OpenRequest.h" +#include "librbd/journal/PromoteRequest.h" +#include "librbd/journal/RemoveRequest.h" +#include "librbd/journal/Replay.h" #include #include @@ -828,7 +828,7 @@ void Journal::flush_commit_position(Context *on_finish) { template uint64_t Journal::append_write_event(uint64_t offset, size_t length, const bufferlist &bl, - const AioObjectRequests &requests, + const IOObjectRequests &requests, bool flush_entry) { assert(m_max_append_size > journal::AioWriteEvent::get_fixed_size()); uint64_t max_write_data_size = @@ -861,7 +861,7 @@ uint64_t Journal::append_write_event(uint64_t offset, size_t length, template uint64_t Journal::append_io_event(journal::EventEntry &&event_entry, - const AioObjectRequests &requests, + const IOObjectRequests &requests, uint64_t offset, size_t length, bool flush_entry) { bufferlist bl; @@ -874,7 +874,7 @@ uint64_t Journal::append_io_event(journal::EventEntry &&event_entry, template uint64_t Journal::append_io_events(journal::EventType event_type, const Bufferlists &bufferlists, - const AioObjectRequests &requests, + const IOObjectRequests &requests, uint64_t offset, size_t length, bool flush_entry) { assert(!bufferlists.empty()); @@ -1547,7 +1547,7 @@ void Journal::handle_io_event_safe(int r, uint64_t tid) { << "failed to commit IO event: " << cpp_strerror(r) << dendl; } - AioObjectRequests aio_object_requests; + IOObjectRequests aio_object_requests; Contexts on_safe_contexts; { Mutex::Locker event_locker(m_event_lock); @@ -1576,7 +1576,7 @@ void Journal::handle_io_event_safe(int r, uint64_t tid) { ldout(cct, 20) << this << " " << __func__ << ": " << "completing tid=" << tid << dendl; - for (AioObjectRequests::iterator it = aio_object_requests.begin(); + for (IOObjectRequests::iterator it = aio_object_requests.begin(); it != aio_object_requests.end(); ++it) { if (r < 0) { // don't send aio requests if the journal fails -- bubble error up diff --git a/src/librbd/Journal.h b/src/librbd/Journal.h index a7fa1a5e5c4..8c5084aa152 100644 --- a/src/librbd/Journal.h +++ b/src/librbd/Journal.h @@ -34,9 +34,9 @@ namespace librados { namespace librbd { -struct AioObjectRequestHandle; class ImageCtx; +namespace io { struct ObjectRequestHandle; } namespace journal { template class Replay; } template @@ -90,7 +90,7 @@ public: static const std::string LOCAL_MIRROR_UUID; static const std::string ORPHAN_MIRROR_UUID; - typedef std::list AioObjectRequests; + typedef std::list IOObjectRequests; Journal(ImageCtxT &image_ctx); ~Journal(); @@ -139,10 +139,10 @@ public: uint64_t append_write_event(uint64_t offset, size_t length, const bufferlist &bl, - const AioObjectRequests &requests, + const IOObjectRequests &requests, bool flush_entry); uint64_t append_io_event(journal::EventEntry &&event_entry, - const AioObjectRequests &requests, + const IOObjectRequests &requests, uint64_t offset, size_t length, bool flush_entry); void commit_io_event(uint64_t tid, int r); @@ -192,7 +192,7 @@ private: struct Event { Futures futures; - AioObjectRequests aio_object_requests; + IOObjectRequests aio_object_requests; Contexts on_safe_contexts; ExtentInterval pending_extents; bool committed_io = false; @@ -201,7 +201,7 @@ private: Event() { } - Event(const Futures &_futures, const AioObjectRequests &_requests, + Event(const Futures &_futures, const IOObjectRequests &_requests, uint64_t offset, size_t length) : futures(_futures), aio_object_requests(_requests) { if (length > 0) { @@ -335,7 +335,7 @@ private: uint64_t append_io_events(journal::EventType event_type, const Bufferlists &bufferlists, - const AioObjectRequests &requests, + const IOObjectRequests &requests, uint64_t offset, size_t length, bool flush_entry); Future wait_event(Mutex &lock, uint64_t tid, Context *on_safe); diff --git a/src/librbd/LibrbdWriteback.cc b/src/librbd/LibrbdWriteback.cc index b1e3826df4d..5e53bdad057 100644 --- a/src/librbd/LibrbdWriteback.cc +++ b/src/librbd/LibrbdWriteback.cc @@ -11,15 +11,15 @@ #include "include/rados/librados.hpp" #include "include/rbd/librbd.hpp" -#include "librbd/AioObjectRequest.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageCtx.h" #include "librbd/internal.h" #include "librbd/LibrbdWriteback.h" -#include "librbd/AioCompletion.h" #include "librbd/ObjectMap.h" #include "librbd/Journal.h" #include "librbd/Utils.h" +#include "librbd/io/AioCompletion.h" +#include "librbd/io/ObjectRequest.h" #include "include/assert.h" @@ -161,8 +161,8 @@ namespace librbd { assert(image_ctx->exclusive_lock->is_lock_owner()); request_sent = true; - AioObjectWrite *req = new AioObjectWrite(image_ctx, oid, object_no, off, - bl, snapc, this, 0); + auto req = new io::ObjectWriteRequest(image_ctx, oid, object_no, off, + bl, snapc, this, 0); req->send(); } }; @@ -271,8 +271,8 @@ namespace librbd { bl, snapc, req_comp, journal_tid)); } else { - AioObjectWrite *req = new AioObjectWrite(m_ictx, oid.name, object_no, - off, bl, snapc, req_comp, 0); + auto req = new io::ObjectWriteRequest(m_ictx, oid.name, object_no, + off, bl, snapc, req_comp, 0); req->send(); } return ++m_tid; diff --git a/src/librbd/cache/ImageWriteback.cc b/src/librbd/cache/ImageWriteback.cc index a787f89472f..1fd167ce793 100644 --- a/src/librbd/cache/ImageWriteback.cc +++ b/src/librbd/cache/ImageWriteback.cc @@ -4,9 +4,9 @@ #include "ImageWriteback.h" #include "include/buffer.h" #include "common/dout.h" -#include "librbd/AioCompletion.h" -#include "librbd/AioImageRequest.h" #include "librbd/ImageCtx.h" +#include "librbd/io/AioCompletion.h" +#include "librbd/io/ImageRequest.h" #define dout_subsys ceph_subsys_rbd #undef dout_prefix @@ -26,11 +26,10 @@ void ImageWriteback::aio_read(Extents &&image_extents, bufferlist *bl, ldout(cct, 20) << "image_extents=" << image_extents << ", " << "on_finish=" << on_finish << dendl; - AioCompletion *aio_comp = AioCompletion::create_and_start(on_finish, - &m_image_ctx, - AIO_TYPE_READ); - AioImageRead req(m_image_ctx, aio_comp, std::move(image_extents), nullptr, - bl, fadvise_flags); + auto aio_comp = io::AioCompletion::create_and_start(on_finish, &m_image_ctx, + io::AIO_TYPE_READ); + io::ImageReadRequest req(m_image_ctx, aio_comp, std::move(image_extents), + nullptr, bl, fadvise_flags); req.set_bypass_image_cache(); req.send(); } @@ -43,11 +42,10 @@ void ImageWriteback::aio_write(Extents &&image_extents, ldout(cct, 20) << "image_extents=" << image_extents << ", " << "on_finish=" << on_finish << dendl; - AioCompletion *aio_comp = AioCompletion::create_and_start(on_finish, - &m_image_ctx, - AIO_TYPE_WRITE); - AioImageWrite req(m_image_ctx, aio_comp, std::move(image_extents), - std::move(bl), fadvise_flags); + auto aio_comp = io::AioCompletion::create_and_start(on_finish, &m_image_ctx, + io::AIO_TYPE_WRITE); + io::ImageWriteRequest req(m_image_ctx, aio_comp, std::move(image_extents), + std::move(bl), fadvise_flags); req.set_bypass_image_cache(); req.send(); } @@ -60,10 +58,9 @@ void ImageWriteback::aio_discard(uint64_t offset, uint64_t length, << "length=" << length << ", " << "on_finish=" << on_finish << dendl; - AioCompletion *aio_comp = AioCompletion::create_and_start(on_finish, - &m_image_ctx, - AIO_TYPE_DISCARD); - AioImageDiscard req(m_image_ctx, aio_comp, offset, length); + auto aio_comp = io::AioCompletion::create_and_start(on_finish, &m_image_ctx, + io::AIO_TYPE_DISCARD); + io::ImageDiscardRequest req(m_image_ctx, aio_comp, offset, length); req.set_bypass_image_cache(); req.send(); } @@ -73,10 +70,9 @@ void ImageWriteback::aio_flush(Context *on_finish) { CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << "on_finish=" << on_finish << dendl; - AioCompletion *aio_comp = AioCompletion::create_and_start(on_finish, - &m_image_ctx, - AIO_TYPE_FLUSH); - AioImageFlush req(m_image_ctx, aio_comp); + auto aio_comp = io::AioCompletion::create_and_start(on_finish, &m_image_ctx, + io::AIO_TYPE_FLUSH); + io::ImageFlushRequest req(m_image_ctx, aio_comp); req.set_bypass_image_cache(); req.send(); } diff --git a/src/librbd/exclusive_lock/PreReleaseRequest.cc b/src/librbd/exclusive_lock/PreReleaseRequest.cc index 6d3382dd699..ee29a98584f 100644 --- a/src/librbd/exclusive_lock/PreReleaseRequest.cc +++ b/src/librbd/exclusive_lock/PreReleaseRequest.cc @@ -4,13 +4,13 @@ #include "librbd/exclusive_lock/PreReleaseRequest.h" #include "common/dout.h" #include "common/errno.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageState.h" #include "librbd/ImageWatcher.h" #include "librbd/Journal.h" #include "librbd/ObjectMap.h" #include "librbd/Utils.h" +#include "librbd/io/ImageRequestWQ.h" #define dout_subsys ceph_subsys_rbd #undef dout_prefix @@ -108,9 +108,9 @@ void PreReleaseRequest::send_block_writes() { { RWLock::RLocker owner_locker(m_image_ctx.owner_lock); if (m_image_ctx.test_features(RBD_FEATURE_JOURNALING)) { - m_image_ctx.aio_work_queue->set_require_lock_on_read(); + m_image_ctx.io_work_queue->set_require_lock_on_read(); } - m_image_ctx.aio_work_queue->block_writes(ctx); + m_image_ctx.io_work_queue->block_writes(ctx); } } @@ -125,7 +125,7 @@ void PreReleaseRequest::handle_block_writes(int r) { << dendl; } else if (r < 0) { lderr(cct) << "failed to block writes: " << cpp_strerror(r) << dendl; - m_image_ctx.aio_work_queue->unblock_writes(); + m_image_ctx.io_work_queue->unblock_writes(); save_result(r); finish(); return; @@ -168,7 +168,7 @@ void PreReleaseRequest::handle_invalidate_cache(int r) { } else if (r < 0 && r != -EBUSY) { lderr(cct) << "failed to invalidate cache: " << cpp_strerror(r) << dendl; - m_image_ctx.aio_work_queue->unblock_writes(); + m_image_ctx.io_work_queue->unblock_writes(); save_result(r); finish(); return; diff --git a/src/librbd/image/CloseRequest.cc b/src/librbd/image/CloseRequest.cc index fe87f9a6f01..900164fccab 100644 --- a/src/librbd/image/CloseRequest.cc +++ b/src/librbd/image/CloseRequest.cc @@ -4,13 +4,13 @@ #include "librbd/image/CloseRequest.h" #include "common/dout.h" #include "common/errno.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageCtx.h" #include "librbd/ImageState.h" #include "librbd/ImageWatcher.h" #include "librbd/ObjectMap.h" #include "librbd/Utils.h" +#include "librbd/io/ImageRequestWQ.h" #define dout_subsys ceph_subsys_rbd #undef dout_prefix @@ -61,7 +61,7 @@ void CloseRequest::handle_shut_down_update_watchers(int r) { template void CloseRequest::send_unregister_image_watcher() { if (m_image_ctx->image_watcher == nullptr) { - send_shut_down_aio_queue(); + send_shut_down_io_queue(); return; } @@ -84,21 +84,21 @@ void CloseRequest::handle_unregister_image_watcher(int r) { << dendl; } - send_shut_down_aio_queue(); + send_shut_down_io_queue(); } template -void CloseRequest::send_shut_down_aio_queue() { +void CloseRequest::send_shut_down_io_queue() { CephContext *cct = m_image_ctx->cct; ldout(cct, 10) << this << " " << __func__ << dendl; RWLock::RLocker owner_locker(m_image_ctx->owner_lock); - m_image_ctx->aio_work_queue->shut_down(create_context_callback< - CloseRequest, &CloseRequest::handle_shut_down_aio_queue>(this)); + m_image_ctx->io_work_queue->shut_down(create_context_callback< + CloseRequest, &CloseRequest::handle_shut_down_io_queue>(this)); } template -void CloseRequest::handle_shut_down_aio_queue(int r) { +void CloseRequest::handle_shut_down_io_queue(int r) { CephContext *cct = m_image_ctx->cct; ldout(cct, 10) << this << " " << __func__ << ": r=" << r << dendl; diff --git a/src/librbd/image/CloseRequest.h b/src/librbd/image/CloseRequest.h index e7d21845b7a..c5cf2e1735e 100644 --- a/src/librbd/image/CloseRequest.h +++ b/src/librbd/image/CloseRequest.h @@ -80,8 +80,8 @@ private: void send_unregister_image_watcher(); void handle_unregister_image_watcher(int r); - void send_shut_down_aio_queue(); - void handle_shut_down_aio_queue(int r); + void send_shut_down_io_queue(); + void handle_shut_down_io_queue(int r); void send_shut_down_exclusive_lock(); void handle_shut_down_exclusive_lock(int r); diff --git a/src/librbd/image/CreateRequest.cc b/src/librbd/image/CreateRequest.cc index 63d9a06fa64..a453422fd5d 100644 --- a/src/librbd/image/CreateRequest.cc +++ b/src/librbd/image/CreateRequest.cc @@ -8,12 +8,12 @@ #include "include/assert.h" #include "librbd/Utils.h" #include "common/ceph_context.h" -#include "librbd/AioCompletion.h" #include "librbd/Journal.h" #include "librbd/MirroringWatcher.h" #include "librbd/journal/CreateRequest.h" #include "librbd/journal/RemoveRequest.h" #include "librbd/mirror/EnableRequest.h" +#include "librbd/io/AioCompletion.h" #include "journal/Journaler.h" #define dout_subsys ceph_subsys_rbd diff --git a/src/librbd/image/RefreshRequest.cc b/src/librbd/image/RefreshRequest.cc index dabd094c6e9..bf64f9590c9 100644 --- a/src/librbd/image/RefreshRequest.cc +++ b/src/librbd/image/RefreshRequest.cc @@ -6,13 +6,13 @@ #include "common/errno.h" #include "cls/lock/cls_lock_client.h" #include "cls/rbd/cls_rbd_client.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageCtx.h" #include "librbd/Journal.h" #include "librbd/ObjectMap.h" #include "librbd/Utils.h" #include "librbd/image/RefreshParentRequest.h" +#include "librbd/io/ImageRequestWQ.h" #include "librbd/journal/Policy.h" #define dout_subsys ceph_subsys_rbd @@ -644,7 +644,7 @@ void RefreshRequest::send_v2_open_journal() { !journal_disabled_by_policy && m_image_ctx.exclusive_lock != nullptr && m_image_ctx.journal == nullptr) { - m_image_ctx.aio_work_queue->set_require_lock_on_read(); + m_image_ctx.io_work_queue->set_require_lock_on_read(); } send_v2_block_writes(); return; @@ -704,7 +704,7 @@ void RefreshRequest::send_v2_block_writes() { RefreshRequest, &RefreshRequest::handle_v2_block_writes>(this); RWLock::RLocker owner_locker(m_image_ctx.owner_lock); - m_image_ctx.aio_work_queue->block_writes(ctx); + m_image_ctx.io_work_queue->block_writes(ctx); } template @@ -906,7 +906,7 @@ Context *RefreshRequest::handle_v2_close_journal(int *result) { assert(m_blocked_writes); m_blocked_writes = false; - m_image_ctx.aio_work_queue->unblock_writes(); + m_image_ctx.io_work_queue->unblock_writes(); return send_v2_close_object_map(); } @@ -1083,7 +1083,7 @@ void RefreshRequest::apply() { if (!m_image_ctx.test_features(RBD_FEATURE_JOURNALING, m_image_ctx.snap_lock)) { if (m_image_ctx.journal != nullptr) { - m_image_ctx.aio_work_queue->clear_require_lock_on_read(); + m_image_ctx.io_work_queue->clear_require_lock_on_read(); } std::swap(m_journal, m_image_ctx.journal); } else if (m_journal != nullptr) { diff --git a/src/librbd/image/SetSnapRequest.cc b/src/librbd/image/SetSnapRequest.cc index def86f99a5d..1b851eb7487 100644 --- a/src/librbd/image/SetSnapRequest.cc +++ b/src/librbd/image/SetSnapRequest.cc @@ -4,12 +4,12 @@ #include "librbd/image/SetSnapRequest.h" #include "common/dout.h" #include "common/errno.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageCtx.h" #include "librbd/ObjectMap.h" #include "librbd/Utils.h" #include "librbd/image/RefreshParentRequest.h" +#include "librbd/io/ImageRequestWQ.h" #define dout_subsys ceph_subsys_rbd #undef dout_prefix @@ -104,7 +104,7 @@ void SetSnapRequest::send_block_writes() { klass, &klass::handle_block_writes>(this); RWLock::RLocker owner_locker(m_image_ctx.owner_lock); - m_image_ctx.aio_work_queue->block_writes(ctx); + m_image_ctx.io_work_queue->block_writes(ctx); } template @@ -348,7 +348,7 @@ int SetSnapRequest::apply() { template void SetSnapRequest::finalize() { if (m_writes_blocked) { - m_image_ctx.aio_work_queue->unblock_writes(); + m_image_ctx.io_work_queue->unblock_writes(); m_writes_blocked = false; } } diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 67dfbea5deb..d7125b37dce 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -21,21 +21,12 @@ #include "cls/journal/cls_journal_types.h" #include "cls/journal/cls_journal_client.h" -#include "librbd/AioCompletion.h" -#include "librbd/AioImageRequest.h" -#include "librbd/AioImageRequestWQ.h" -#include "librbd/AioObjectRequest.h" -#include "librbd/image/CreateRequest.h" #include "librbd/DiffIterate.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageCtx.h" #include "librbd/ImageState.h" #include "librbd/internal.h" #include "librbd/Journal.h" -#include "librbd/journal/Types.h" -#include "librbd/managed_lock/Types.h" -#include "librbd/mirror/DisableRequest.h" -#include "librbd/mirror/EnableRequest.h" #include "librbd/MirroringWatcher.h" #include "librbd/ObjectMap.h" #include "librbd/Operations.h" @@ -43,6 +34,15 @@ #include "librbd/Utils.h" #include "librbd/exclusive_lock/AutomaticPolicy.h" #include "librbd/exclusive_lock/StandardPolicy.h" +#include "librbd/image/CreateRequest.h" +#include "librbd/managed_lock/Types.h" +#include "librbd/mirror/DisableRequest.h" +#include "librbd/mirror/EnableRequest.h" +#include "librbd/io/AioCompletion.h" +#include "librbd/io/ImageRequest.h" +#include "librbd/io/ImageRequestWQ.h" +#include "librbd/io/ObjectRequest.h" +#include "librbd/journal/Types.h" #include "librbd/operation/TrimRequest.h" #include "journal/Journaler.h" @@ -2088,12 +2088,12 @@ void filter_out_mirror_watchers(ImageCtx *ictx, } Context *ctx = new C_CopyWrite(m_throttle, m_bl); - AioCompletion *comp = AioCompletion::create(ctx); + auto comp = io::AioCompletion::create(ctx); // coordinate through AIO WQ to ensure lock is acquired if needed - m_dest->aio_work_queue->aio_write(comp, m_offset, m_bl->length(), - m_bl->c_str(), - LIBRADOS_OP_FLAG_FADVISE_DONTNEED); + m_dest->io_work_queue->aio_write(comp, m_offset, m_bl->length(), + m_bl->c_str(), + LIBRADOS_OP_FLAG_FADVISE_DONTNEED); } private: @@ -2146,10 +2146,10 @@ void filter_out_mirror_watchers(ImageCtx *ictx, uint64_t len = min(period, src_size - offset); bufferlist *bl = new bufferlist(); Context *ctx = new C_CopyRead(&throttle, dest, offset, bl); - AioCompletion *comp = AioCompletion::create_and_start(ctx, src, - AIO_TYPE_READ); - AioImageRequest<>::aio_read(src, comp, {{offset, len}}, nullptr, bl, - fadvise_flags); + auto comp = io::AioCompletion::create_and_start(ctx, src, + io::AIO_TYPE_READ); + io::ImageRequest<>::aio_read(src, comp, {{offset, len}}, nullptr, bl, + fadvise_flags); prog_ctx.update_progress(offset, src_size); } @@ -2334,7 +2334,7 @@ void filter_out_mirror_watchers(ImageCtx *ictx, void rbd_ctx_cb(completion_t cb, void *arg) { Context *ctx = reinterpret_cast(arg); - AioCompletion *comp = reinterpret_cast(cb); + auto comp = reinterpret_cast(cb); ctx->complete(comp->get_return_value()); comp->release(); } @@ -2372,9 +2372,10 @@ void filter_out_mirror_watchers(ImageCtx *ictx, bufferlist bl; C_SaferCond ctx; - AioCompletion *c = AioCompletion::create_and_start(&ctx, ictx, - AIO_TYPE_READ); - AioImageRequest<>::aio_read(ictx, c, {{off, read_len}}, nullptr, &bl, 0); + auto c = io::AioCompletion::create_and_start(&ctx, ictx, + io::AIO_TYPE_READ); + io::ImageRequest<>::aio_read(ictx, c, {{off, read_len}}, nullptr, &bl, + 0); int ret = ctx.wait(); if (ret < 0) { @@ -2493,12 +2494,13 @@ void filter_out_mirror_watchers(ImageCtx *ictx, return r; } - int poll_io_events(ImageCtx *ictx, AioCompletion **comps, int numcomp) + int poll_io_events(ImageCtx *ictx, io::AioCompletion **comps, int numcomp) { if (numcomp <= 0) return -EINVAL; CephContext *cct = ictx->cct; - ldout(cct, 20) << __func__ << " " << ictx << " numcomp = " << numcomp << dendl; + ldout(cct, 20) << __func__ << " " << ictx << " numcomp = " << numcomp + << dendl; int i = 0; Mutex::Locker l(ictx->completed_reqs_lock); while (i < numcomp) { @@ -3369,7 +3371,7 @@ void filter_out_mirror_watchers(ImageCtx *ictx, uint64_t image_size = ictx->get_image_size(ictx->snap_id); ictx->snap_lock.put_read(); ictx->md_lock.put_write(); - + pair readahead_extent = ictx->readahead.update(image_extents, image_size); uint64_t readahead_offset = readahead_extent.first; uint64_t readahead_length = readahead_extent.second; diff --git a/src/librbd/internal.h b/src/librbd/internal.h index 428c99ccd08..22cd4bad2b6 100644 --- a/src/librbd/internal.h +++ b/src/librbd/internal.h @@ -52,8 +52,8 @@ enum { namespace librbd { - struct AioCompletion; struct ImageCtx; + namespace io { struct AioCompletion; } class NoOpProgressContext : public ProgressContext { @@ -195,7 +195,7 @@ namespace librbd { int flush(ImageCtx *ictx); int invalidate_cache(ImageCtx *ictx); - int poll_io_events(ImageCtx *ictx, AioCompletion **comps, int numcomp); + int poll_io_events(ImageCtx *ictx, io::AioCompletion **comps, int numcomp); int metadata_list(ImageCtx *ictx, const string &last, uint64_t max, map *pairs); int metadata_get(ImageCtx *ictx, const std::string &key, std::string *value); diff --git a/src/librbd/AioCompletion.cc b/src/librbd/io/AioCompletion.cc similarity index 93% rename from src/librbd/AioCompletion.cc rename to src/librbd/io/AioCompletion.cc index e42754b2b9e..8d42e82fa2b 100644 --- a/src/librbd/AioCompletion.cc +++ b/src/librbd/io/AioCompletion.cc @@ -1,6 +1,7 @@ // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab +#include "librbd/io/AioCompletion.h" #include #include "common/ceph_context.h" @@ -12,7 +13,6 @@ #include "librbd/ImageCtx.h" #include "librbd/internal.h" -#include "librbd/AioCompletion.h" #include "librbd/Journal.h" #ifdef WITH_LTTNG @@ -23,14 +23,15 @@ #define dout_subsys ceph_subsys_rbd #undef dout_prefix -#define dout_prefix *_dout << "librbd::AioCompletion: " +#define dout_prefix *_dout << "librbd::io::AioCompletion: " namespace librbd { +namespace io { int AioCompletion::wait_for_complete() { tracepoint(librbd, aio_wait_for_complete_enter, this); lock.Lock(); - while (state != STATE_COMPLETE) + while (state != AIO_STATE_COMPLETE) cond.Wait(lock); lock.Unlock(); tracepoint(librbd, aio_wait_for_complete_exit, 0); @@ -101,7 +102,7 @@ void AioCompletion::complete() { ictx->journal->commit_io_event(journal_tid, rval); } - state = STATE_CALLBACK; + state = AIO_STATE_CALLBACK; if (complete_cb) { lock.Unlock(); complete_cb(rbd_comp, complete_arg); @@ -115,7 +116,7 @@ void AioCompletion::complete() { ictx->event_socket.notify(); } - state = STATE_COMPLETE; + state = AIO_STATE_COMPLETE; cond.Signal(); // note: possible for image to be closed after op marked finished @@ -138,7 +139,8 @@ void AioCompletion::start_op(bool ignore_type) { Mutex::Locker locker(lock); assert(ictx != nullptr); assert(!async_op.started()); - if (state == STATE_PENDING && (ignore_type || aio_type != AIO_TYPE_FLUSH)) { + if (state == AIO_STATE_PENDING && + (ignore_type || aio_type != AIO_TYPE_FLUSH)) { async_op.start_op(*ictx); } } @@ -197,7 +199,7 @@ void AioCompletion::complete_request(ssize_t r) void AioCompletion::associate_journal_event(uint64_t tid) { Mutex::Locker l(lock); - assert(state == STATE_PENDING); + assert(state == AIO_STATE_PENDING); journal_tid = tid; } @@ -206,7 +208,7 @@ bool AioCompletion::is_complete() { bool done; { Mutex::Locker l(lock); - done = this->state == STATE_COMPLETE; + done = this->state == AIO_STATE_COMPLETE; } tracepoint(librbd, aio_is_complete_exit, done); return done; @@ -221,4 +223,5 @@ ssize_t AioCompletion::get_return_value() { return r; } +} // namespace io } // namespace librbd diff --git a/src/librbd/AioCompletion.h b/src/librbd/io/AioCompletion.h similarity index 92% rename from src/librbd/AioCompletion.h rename to src/librbd/io/AioCompletion.h index 6a83677cd96..cce065f9fd8 100644 --- a/src/librbd/AioCompletion.h +++ b/src/librbd/io/AioCompletion.h @@ -1,8 +1,8 @@ // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab -#ifndef CEPH_LIBRBD_AIO_COMPLETION_H -#define CEPH_LIBRBD_AIO_COMPLETION_H +#ifndef CEPH_LIBRBD_IO_AIO_COMPLETION_H +#define CEPH_LIBRBD_IO_AIO_COMPLETION_H #include "common/Cond.h" #include "common/Mutex.h" @@ -12,28 +12,13 @@ #include "librbd/AsyncOperation.h" #include "librbd/ImageCtx.h" - +#include "librbd/io/Types.h" #include "osdc/Striper.h" class CephContext; namespace librbd { - -typedef enum { - AIO_TYPE_NONE = 0, - AIO_TYPE_OPEN, - AIO_TYPE_CLOSE, - AIO_TYPE_READ, - AIO_TYPE_WRITE, - AIO_TYPE_DISCARD, - AIO_TYPE_FLUSH, -} aio_type_t; - -typedef enum { - STATE_PENDING = 0, - STATE_CALLBACK, - STATE_COMPLETE, -} aio_state_t; +namespace io { /** * AioCompletion is the overall completion for a single @@ -49,6 +34,12 @@ typedef enum { * context or via a thread pool context for cache read hits). */ struct AioCompletion { + typedef enum { + AIO_STATE_PENDING = 0, + AIO_STATE_CALLBACK, + AIO_STATE_COMPLETE, + } aio_state_t; + mutable Mutex lock; Cond cond; aio_state_t state; @@ -109,7 +100,7 @@ struct AioCompletion { } AioCompletion() : lock("AioCompletion::lock", true, false), - state(STATE_PENDING), rval(0), complete_cb(NULL), + state(AIO_STATE_PENDING), rval(0), complete_cb(NULL), complete_arg(NULL), rbd_comp(NULL), pending_count(0), blockers(1), ref(1), released(false), ictx(NULL), @@ -233,6 +224,7 @@ protected: AioCompletion *m_completion; }; +} // namespace io } // namespace librbd -#endif // CEPH_LIBRBD_AIO_COMPLETION_H +#endif // CEPH_LIBRBD_IO_AIO_COMPLETION_H diff --git a/src/librbd/CopyupRequest.cc b/src/librbd/io/CopyupRequest.cc similarity index 93% rename from src/librbd/CopyupRequest.cc rename to src/librbd/io/CopyupRequest.cc index ae3f1770c2b..b025a1712a1 100644 --- a/src/librbd/CopyupRequest.cc +++ b/src/librbd/io/CopyupRequest.cc @@ -1,20 +1,20 @@ // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab +#include "librbd/io/CopyupRequest.h" #include "common/ceph_context.h" #include "common/dout.h" #include "common/errno.h" #include "common/Mutex.h" -#include "librbd/AioCompletion.h" -#include "librbd/AioImageRequest.h" -#include "librbd/AioObjectRequest.h" #include "librbd/AsyncObjectThrottle.h" -#include "librbd/CopyupRequest.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageCtx.h" #include "librbd/ObjectMap.h" #include "librbd/Utils.h" +#include "librbd/io/AioCompletion.h" +#include "librbd/io/ImageRequest.h" +#include "librbd/io/ObjectRequest.h" #include #include @@ -22,9 +22,10 @@ #define dout_subsys ceph_subsys_rbd #undef dout_prefix -#define dout_prefix *_dout << "librbd::CopyupRequest: " +#define dout_prefix *_dout << "librbd::io::CopyupRequest: " namespace librbd { +namespace io { namespace { @@ -90,15 +91,15 @@ CopyupRequest::~CopyupRequest() { m_async_op.finish_op(); } -void CopyupRequest::append_request(AioObjectRequest<> *req) { +void CopyupRequest::append_request(ObjectRequest<> *req) { ldout(m_ictx->cct, 20) << __func__ << " " << this << ": " << req << dendl; m_pending_requests.push_back(req); } void CopyupRequest::complete_requests(int r) { while (!m_pending_requests.empty()) { - vector *>::iterator it = m_pending_requests.begin(); - AioObjectRequest<> *req = *it; + vector *>::iterator it = m_pending_requests.begin(); + ObjectRequest<> *req = *it; ldout(m_ictx->cct, 20) << __func__ << " completing request " << req << dendl; req->complete(r); @@ -165,7 +166,7 @@ bool CopyupRequest::send_copyup() { // merge all pending write ops into this single RADOS op for (size_t i=0; i *req = m_pending_requests[i]; + ObjectRequest<> *req = m_pending_requests[i]; ldout(m_ictx->cct, 20) << __func__ << " add_copyup_ops " << req << dendl; req->add_copyup_ops(&write_op); @@ -183,7 +184,7 @@ bool CopyupRequest::send_copyup() { bool CopyupRequest::is_copyup_required() { bool noop = true; - for (const AioObjectRequest<> *req : m_pending_requests) { + for (const ObjectRequest<> *req : m_pending_requests) { if (!req->is_op_payload_empty()) { noop = false; break; @@ -204,7 +205,7 @@ void CopyupRequest::send() << ", oid " << m_oid << ", extents " << m_image_extents << dendl; - AioImageRequest<>::aio_read(m_ictx->parent, comp, std::move(m_image_extents), + ImageRequest<>::aio_read(m_ictx->parent, comp, std::move(m_image_extents), nullptr, &m_copyup_data, 0); } @@ -311,9 +312,9 @@ bool CopyupRequest::send_object_map_head() { bool may_update = false; uint8_t new_state, current_state; - vector *>::reverse_iterator r_it = m_pending_requests.rbegin(); + vector *>::reverse_iterator r_it = m_pending_requests.rbegin(); for (; r_it != m_pending_requests.rend(); ++r_it) { - AioObjectRequest<> *req = *r_it; + ObjectRequest<> *req = *r_it; if (!req->pre_object_map_update(&new_state)) { continue; } @@ -363,4 +364,5 @@ bool CopyupRequest::send_object_map() { return false; } +} // namespace io } // namespace librbd diff --git a/src/librbd/CopyupRequest.h b/src/librbd/io/CopyupRequest.h similarity index 82% rename from src/librbd/CopyupRequest.h rename to src/librbd/io/CopyupRequest.h index d661aafb9da..d0183705c5f 100644 --- a/src/librbd/CopyupRequest.h +++ b/src/librbd/io/CopyupRequest.h @@ -1,28 +1,34 @@ // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab -#ifndef CEPH_LIBRBD_COPYUP_REQUEST_H -#define CEPH_LIBRBD_COPYUP_REQUEST_H +#ifndef CEPH_LIBRBD_IO_COPYUP_REQUEST_H +#define CEPH_LIBRBD_IO_COPYUP_REQUEST_H #include "librbd/AsyncOperation.h" +#include "include/atomic.h" #include "include/int_types.h" +#include "include/rados/librados.hpp" #include "include/buffer.h" +#include "librbd/io/Types.h" +#include +#include namespace librbd { -struct AioCompletion; -template class AioObjectRequest; struct ImageCtx; +namespace io { + +struct AioCompletion; +template class ObjectRequest; + class CopyupRequest { public: - typedef std::vector > Extents; - CopyupRequest(ImageCtx *ictx, const std::string &oid, uint64_t objectno, Extents &&image_extents); ~CopyupRequest(); - void append_request(AioObjectRequest *req); + void append_request(ObjectRequest *req); void send(); @@ -72,7 +78,7 @@ private: Extents m_image_extents; State m_state; ceph::bufferlist m_copyup_data; - vector *> m_pending_requests; + std::vector *> m_pending_requests; atomic_t m_pending_copyups; AsyncOperation m_async_op; @@ -92,6 +98,7 @@ private: bool is_copyup_required(); }; +} // namespace io } // namespace librbd -#endif // CEPH_LIBRBD_COPYUP_REQUEST_H +#endif // CEPH_LIBRBD_IO_COPYUP_REQUEST_H diff --git a/src/librbd/AioImageRequest.cc b/src/librbd/io/ImageRequest.cc similarity index 81% rename from src/librbd/AioImageRequest.cc rename to src/librbd/io/ImageRequest.cc index a262d8c5550..e11d1949c0f 100644 --- a/src/librbd/AioImageRequest.cc +++ b/src/librbd/io/ImageRequest.cc @@ -1,14 +1,14 @@ // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab -#include "librbd/AioImageRequest.h" -#include "librbd/AioCompletion.h" -#include "librbd/AioObjectRequest.h" +#include "librbd/io/ImageRequest.h" #include "librbd/ImageCtx.h" #include "librbd/internal.h" #include "librbd/Journal.h" #include "librbd/Utils.h" #include "librbd/cache/ImageCache.h" +#include "librbd/io/AioCompletion.h" +#include "librbd/io/ObjectRequest.h" #include "librbd/journal/Types.h" #include "include/rados/librados.hpp" #include "common/WorkQueue.h" @@ -16,9 +16,10 @@ #define dout_subsys ceph_subsys_rbd #undef dout_prefix -#define dout_prefix *_dout << "librbd::AioImageRequest: " +#define dout_prefix *_dout << "librbd::io::ImageRequest: " namespace librbd { +namespace io { using util::get_image_ctx; @@ -112,11 +113,11 @@ public: C_AioRequest::finish(r); } - void set_req(AioObjectRead *req) { + void set_req(ObjectReadRequest *req) { m_req = req; } private: - AioObjectRead *m_req; + ObjectReadRequest *m_req; }; template @@ -160,7 +161,7 @@ private: template class C_ObjectCacheRead : public Context { public: - explicit C_ObjectCacheRead(ImageCtxT &ictx, AioObjectRead *req) + explicit C_ObjectCacheRead(ImageCtxT &ictx, ObjectReadRequest *req) : m_image_ctx(ictx), m_req(req), m_enqueued(false) {} void complete(int r) override { @@ -181,51 +182,52 @@ protected: private: ImageCtxT &m_image_ctx; - AioObjectRead *m_req; + ObjectReadRequest *m_req; bool m_enqueued; }; } // anonymous namespace template -void AioImageRequest::aio_read(I *ictx, AioCompletion *c, - Extents &&image_extents, char *buf, - bufferlist *pbl, int op_flags) { - AioImageRead req(*ictx, c, std::move(image_extents), buf, pbl, op_flags); +void ImageRequest::aio_read(I *ictx, AioCompletion *c, + Extents &&image_extents, char *buf, + bufferlist *pbl, int op_flags) { + ImageReadRequest req(*ictx, c, std::move(image_extents), buf, pbl, + op_flags); req.send(); } template -void AioImageRequest::aio_write(I *ictx, AioCompletion *c, uint64_t off, - size_t len, const char *buf, int op_flags) { - AioImageWrite req(*ictx, c, off, len, buf, op_flags); +void ImageRequest::aio_write(I *ictx, AioCompletion *c, uint64_t off, + size_t len, const char *buf, int op_flags) { + ImageWriteRequest req(*ictx, c, off, len, buf, op_flags); req.send(); } template -void AioImageRequest::aio_write(I *ictx, AioCompletion *c, - Extents &&image_extents, bufferlist &&bl, - int op_flags) { - AioImageWrite req(*ictx, c, std::move(image_extents), std::move(bl), - op_flags); +void ImageRequest::aio_write(I *ictx, AioCompletion *c, + Extents &&image_extents, bufferlist &&bl, + int op_flags) { + ImageWriteRequest req(*ictx, c, std::move(image_extents), std::move(bl), + op_flags); req.send(); } template -void AioImageRequest::aio_discard(I *ictx, AioCompletion *c, - uint64_t off, uint64_t len) { - AioImageDiscard req(*ictx, c, off, len); +void ImageRequest::aio_discard(I *ictx, AioCompletion *c, + uint64_t off, uint64_t len) { + ImageDiscardRequest req(*ictx, c, off, len); req.send(); } template -void AioImageRequest::aio_flush(I *ictx, AioCompletion *c) { - AioImageFlush req(*ictx, c); +void ImageRequest::aio_flush(I *ictx, AioCompletion *c) { + ImageFlushRequest req(*ictx, c); req.send(); } template -void AioImageRequest::send() { +void ImageRequest::send() { I &image_ctx = this->m_image_ctx; assert(m_aio_comp->is_initialized(get_aio_type())); assert(m_aio_comp->is_started() ^ (get_aio_type() == AIO_TYPE_FLUSH)); @@ -250,7 +252,7 @@ void AioImageRequest::send() { } template -int AioImageRequest::clip_request() { +int ImageRequest::clip_request() { RWLock::RLocker snap_locker(m_image_ctx.snap_lock); for (auto &image_extent : m_image_extents) { size_t clip_len = image_extent.second; @@ -265,14 +267,14 @@ int AioImageRequest::clip_request() { } template -void AioImageRequest::fail(int r) { +void ImageRequest::fail(int r) { AioCompletion *aio_comp = this->m_aio_comp; aio_comp->get(); aio_comp->fail(r); } template -void AioImageRead::send_request() { +void ImageReadRequest::send_request() { I &image_ctx = this->m_image_ctx; CephContext *cct = image_ctx.cct; @@ -324,7 +326,7 @@ void AioImageRead::send_request() { << dendl; C_AioRead *req_comp = new C_AioRead(aio_comp); - AioObjectRead *req = AioObjectRead::create( + ObjectReadRequest *req = ObjectReadRequest::create( &image_ctx, extent.oid.name, extent.objectno, extent.offset, extent.length, extent.buffer_extents, snap_id, true, req_comp, m_op_flags); @@ -349,7 +351,7 @@ void AioImageRead::send_request() { } template -void AioImageRead::send_image_cache_request() { +void ImageReadRequest::send_image_cache_request() { I &image_ctx = this->m_image_ctx; assert(image_ctx.image_cache != nullptr); @@ -363,7 +365,7 @@ void AioImageRead::send_image_cache_request() { } template -void AbstractAioImageWrite::send_request() { +void AbstractImageWriteRequest::send_request() { I &image_ctx = this->m_image_ctx; CephContext *cct = image_ctx.cct; @@ -407,7 +409,7 @@ void AbstractAioImageWrite::send_request() { aio_comp->set_request_count( object_extents.size() + get_object_cache_request_count(journaling)); - AioObjectRequests requests; + ObjectRequests requests; send_object_requests(object_extents, snapc, (journaling ? &requests : nullptr)); @@ -430,9 +432,9 @@ void AbstractAioImageWrite::send_request() { } template -void AbstractAioImageWrite::send_object_requests( +void AbstractImageWriteRequest::send_object_requests( const ObjectExtents &object_extents, const ::SnapContext &snapc, - AioObjectRequests *aio_object_requests) { + ObjectRequests *object_requests) { I &image_ctx = this->m_image_ctx; CephContext *cct = image_ctx.cct; @@ -442,13 +444,13 @@ void AbstractAioImageWrite::send_object_requests( ldout(cct, 20) << " oid " << p->oid << " " << p->offset << "~" << p->length << " from " << p->buffer_extents << dendl; C_AioRequest *req_comp = new C_AioRequest(aio_comp); - AioObjectRequestHandle *request = create_object_request(*p, snapc, + ObjectRequestHandle *request = create_object_request(*p, snapc, req_comp); // if journaling, stash the request for later; otherwise send if (request != NULL) { - if (aio_object_requests != NULL) { - aio_object_requests->push_back(request); + if (object_requests != NULL) { + object_requests->push_back(request); } else { request->send(); } @@ -457,8 +459,8 @@ void AbstractAioImageWrite::send_object_requests( } template -void AioImageWrite::assemble_extent(const ObjectExtent &object_extent, - bufferlist *bl) { +void ImageWriteRequest::assemble_extent(const ObjectExtent &object_extent, + bufferlist *bl) { for (auto q = object_extent.buffer_extents.begin(); q != object_extent.buffer_extents.end(); ++q) { bufferlist sub_bl; @@ -468,8 +470,8 @@ void AioImageWrite::assemble_extent(const ObjectExtent &object_extent, } template -uint64_t AioImageWrite::append_journal_event( - const AioObjectRequests &requests, bool synchronous) { +uint64_t ImageWriteRequest::append_journal_event( + const ObjectRequests &requests, bool synchronous) { I &image_ctx = this->m_image_ctx; uint64_t tid = 0; @@ -492,7 +494,7 @@ uint64_t AioImageWrite::append_journal_event( } template -void AioImageWrite::send_image_cache_request() { +void ImageWriteRequest::send_image_cache_request() { I &image_ctx = this->m_image_ctx; assert(image_ctx.image_cache != nullptr); @@ -504,8 +506,8 @@ void AioImageWrite::send_image_cache_request() { } template -void AioImageWrite::send_object_cache_requests(const ObjectExtents &object_extents, - uint64_t journal_tid) { +void ImageWriteRequest::send_object_cache_requests( + const ObjectExtents &object_extents, uint64_t journal_tid) { I &image_ctx = this->m_image_ctx; for (auto p = object_extents.begin(); p != object_extents.end(); ++p) { const ObjectExtent &object_extent = *p; @@ -517,25 +519,25 @@ void AioImageWrite::send_object_cache_requests(const ObjectExtents &object_ex C_AioRequest *req_comp = new C_AioRequest(aio_comp); image_ctx.write_to_cache(object_extent.oid, bl, object_extent.length, object_extent.offset, req_comp, m_op_flags, - journal_tid); + journal_tid); } } template -void AioImageWrite::send_object_requests( +void ImageWriteRequest::send_object_requests( const ObjectExtents &object_extents, const ::SnapContext &snapc, - AioObjectRequests *aio_object_requests) { + ObjectRequests *object_requests) { I &image_ctx = this->m_image_ctx; // cache handles creating object requests during writeback if (image_ctx.object_cacher == NULL) { - AbstractAioImageWrite::send_object_requests(object_extents, snapc, - aio_object_requests); + AbstractImageWriteRequest::send_object_requests(object_extents, snapc, + object_requests); } } template -AioObjectRequestHandle *AioImageWrite::create_object_request( +ObjectRequestHandle *ImageWriteRequest::create_object_request( const ObjectExtent &object_extent, const ::SnapContext &snapc, Context *on_finish) { I &image_ctx = this->m_image_ctx; @@ -543,22 +545,22 @@ AioObjectRequestHandle *AioImageWrite::create_object_request( bufferlist bl; assemble_extent(object_extent, &bl); - AioObjectRequest *req = AioObjectRequest::create_write( + ObjectRequest *req = ObjectRequest::create_write( &image_ctx, object_extent.oid.name, object_extent.objectno, object_extent.offset, bl, snapc, on_finish, m_op_flags); return req; } template -void AioImageWrite::update_stats(size_t length) { +void ImageWriteRequest::update_stats(size_t length) { I &image_ctx = this->m_image_ctx; image_ctx.perfcounter->inc(l_librbd_wr); image_ctx.perfcounter->inc(l_librbd_wr_bytes, length); } template -uint64_t AioImageDiscard::append_journal_event( - const AioObjectRequests &requests, bool synchronous) { +uint64_t ImageDiscardRequest::append_journal_event( + const ObjectRequests &requests, bool synchronous) { I &image_ctx = this->m_image_ctx; uint64_t tid = 0; @@ -577,7 +579,7 @@ uint64_t AioImageDiscard::append_journal_event( } template -void AioImageDiscard::prune_object_extents(ObjectExtents &object_extents) { +void ImageDiscardRequest::prune_object_extents(ObjectExtents &object_extents) { I &image_ctx = this->m_image_ctx; CephContext *cct = image_ctx.cct; if (!cct->_conf->rbd_skip_partial_discard) { @@ -597,14 +599,14 @@ void AioImageDiscard::prune_object_extents(ObjectExtents &object_extents) { } template -uint32_t AioImageDiscard::get_object_cache_request_count(bool journaling) const { +uint32_t ImageDiscardRequest::get_object_cache_request_count(bool journaling) const { // extra completion request is required for tracking journal commit I &image_ctx = this->m_image_ctx; return (image_ctx.object_cacher != nullptr && journaling ? 1 : 0); } template -void AioImageDiscard::send_image_cache_request() { +void ImageDiscardRequest::send_image_cache_request() { I &image_ctx = this->m_image_ctx; assert(image_ctx.image_cache != nullptr); @@ -617,8 +619,8 @@ void AioImageDiscard::send_image_cache_request() { } template -void AioImageDiscard::send_object_cache_requests(const ObjectExtents &object_extents, - uint64_t journal_tid) { +void ImageDiscardRequest::send_object_cache_requests( + const ObjectExtents &object_extents, uint64_t journal_tid) { I &image_ctx = this->m_image_ctx; if (journal_tid == 0) { Mutex::Locker cache_locker(image_ctx.cache_lock); @@ -635,23 +637,23 @@ void AioImageDiscard::send_object_cache_requests(const ObjectExtents &object_ } template -AioObjectRequestHandle *AioImageDiscard::create_object_request( +ObjectRequestHandle *ImageDiscardRequest::create_object_request( const ObjectExtent &object_extent, const ::SnapContext &snapc, Context *on_finish) { I &image_ctx = this->m_image_ctx; - AioObjectRequest *req; + ObjectRequest *req; if (object_extent.length == image_ctx.layout.object_size) { - req = AioObjectRequest::create_remove( + req = ObjectRequest::create_remove( &image_ctx, object_extent.oid.name, object_extent.objectno, snapc, on_finish); } else if (object_extent.offset + object_extent.length == image_ctx.layout.object_size) { - req = AioObjectRequest::create_truncate( + req = ObjectRequest::create_truncate( &image_ctx, object_extent.oid.name, object_extent.objectno, object_extent.offset, snapc, on_finish); } else { - req = AioObjectRequest::create_zero( + req = ObjectRequest::create_zero( &image_ctx, object_extent.oid.name, object_extent.objectno, object_extent.offset, object_extent.length, snapc, on_finish); } @@ -659,14 +661,14 @@ AioObjectRequestHandle *AioImageDiscard::create_object_request( } template -void AioImageDiscard::update_stats(size_t length) { +void ImageDiscardRequest::update_stats(size_t length) { I &image_ctx = this->m_image_ctx; image_ctx.perfcounter->inc(l_librbd_discard); image_ctx.perfcounter->inc(l_librbd_discard_bytes, length); } template -void AioImageFlush::send_request() { +void ImageFlushRequest::send_request() { I &image_ctx = this->m_image_ctx; image_ctx.user_flushed(); @@ -682,16 +684,15 @@ void AioImageFlush::send_request() { // in-flight ops are flushed prior to closing the journal uint64_t journal_tid = image_ctx.journal->append_io_event( journal::EventEntry(journal::AioFlushEvent()), - AioObjectRequests(), 0, 0, false); + ObjectRequests(), 0, 0, false); aio_comp->set_request_count(1); aio_comp->associate_journal_event(journal_tid); FunctionContext *flush_ctx = new FunctionContext( [aio_comp, &image_ctx, journal_tid] (int r) { - C_FlushJournalCommit *ctx = new C_FlushJournalCommit(image_ctx, - aio_comp, - journal_tid); + auto ctx = new C_FlushJournalCommit(image_ctx, aio_comp, + journal_tid); image_ctx.journal->flush_event(journal_tid, ctx); // track flush op for block writes @@ -714,7 +715,7 @@ void AioImageFlush::send_request() { } template -void AioImageFlush::send_image_cache_request() { +void ImageFlushRequest::send_image_cache_request() { I &image_ctx = this->m_image_ctx; assert(image_ctx.image_cache != nullptr); @@ -724,10 +725,12 @@ void AioImageFlush::send_image_cache_request() { image_ctx.image_cache->aio_flush(req_comp); } +} // namespace io } // namespace librbd -template class librbd::AioImageRequest; -template class librbd::AbstractAioImageWrite; -template class librbd::AioImageWrite; -template class librbd::AioImageDiscard; -template class librbd::AioImageFlush; +template class librbd::io::ImageRequest; +template class librbd::io::ImageReadRequest; +template class librbd::io::AbstractImageWriteRequest; +template class librbd::io::ImageWriteRequest; +template class librbd::io::ImageDiscardRequest; +template class librbd::io::ImageFlushRequest; diff --git a/src/librbd/AioImageRequest.h b/src/librbd/io/ImageRequest.h similarity index 60% rename from src/librbd/AioImageRequest.h rename to src/librbd/io/ImageRequest.h index 18a2c9f7144..713425b4c67 100644 --- a/src/librbd/AioImageRequest.h +++ b/src/librbd/io/ImageRequest.h @@ -1,30 +1,32 @@ // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab -#ifndef CEPH_LIBRBD_AIO_IMAGE_REQUEST_H -#define CEPH_LIBRBD_AIO_IMAGE_REQUEST_H +#ifndef CEPH_LIBRBD_IO_IMAGE_REQUEST_H +#define CEPH_LIBRBD_IO_IMAGE_REQUEST_H #include "include/int_types.h" #include "include/buffer_fwd.h" #include "common/snap_types.h" #include "osd/osd_types.h" -#include "librbd/AioCompletion.h" +#include "librbd/io/AioCompletion.h" #include #include #include namespace librbd { +class ImageCtx; + +namespace io { class AioCompletion; -class AioObjectRequestHandle; -class ImageCtx; +class ObjectRequestHandle; template -class AioImageRequest { +class ImageRequest { public: typedef std::vector > Extents; - virtual ~AioImageRequest() {} + virtual ~ImageRequest() {} static void aio_read(ImageCtxT *ictx, AioCompletion *c, Extents &&image_extents, char *buf, bufferlist *pbl, @@ -53,15 +55,15 @@ public: } protected: - typedef std::list AioObjectRequests; + typedef std::list ObjectRequests; ImageCtxT &m_image_ctx; AioCompletion *m_aio_comp; Extents m_image_extents; bool m_bypass_image_cache = false; - AioImageRequest(ImageCtxT &image_ctx, AioCompletion *aio_comp, - Extents &&image_extents) + ImageRequest(ImageCtxT &image_ctx, AioCompletion *aio_comp, + Extents &&image_extents) : m_image_ctx(image_ctx), m_aio_comp(aio_comp), m_image_extents(image_extents) { } @@ -75,14 +77,14 @@ protected: }; template -class AioImageRead : public AioImageRequest { +class ImageReadRequest : public ImageRequest { public: - using typename AioImageRequest::Extents; + using typename ImageRequest::Extents; - AioImageRead(ImageCtxT &image_ctx, AioCompletion *aio_comp, - Extents &&image_extents, char *buf, bufferlist *pbl, - int op_flags) - : AioImageRequest(image_ctx, aio_comp, std::move(image_extents)), + ImageReadRequest(ImageCtxT &image_ctx, AioCompletion *aio_comp, + Extents &&image_extents, char *buf, bufferlist *pbl, + int op_flags) + : ImageRequest(image_ctx, aio_comp, std::move(image_extents)), m_buf(buf), m_pbl(pbl), m_op_flags(op_flags) { } @@ -103,7 +105,7 @@ private: }; template -class AbstractAioImageWrite : public AioImageRequest { +class AbstractImageWriteRequest : public ImageRequest { public: virtual bool is_write_op() const { return true; @@ -114,14 +116,14 @@ public: } protected: - using typename AioImageRequest::AioObjectRequests; - using typename AioImageRequest::Extents; + using typename ImageRequest::ObjectRequests; + using typename ImageRequest::Extents; typedef std::vector ObjectExtents; - AbstractAioImageWrite(ImageCtxT &image_ctx, AioCompletion *aio_comp, - Extents &&image_extents) - : AioImageRequest(image_ctx, aio_comp, std::move(image_extents)), + AbstractImageWriteRequest(ImageCtxT &image_ctx, AioCompletion *aio_comp, + Extents &&image_extents) + : ImageRequest(image_ctx, aio_comp, std::move(image_extents)), m_synchronous(false) { } @@ -137,12 +139,12 @@ protected: virtual void send_object_requests(const ObjectExtents &object_extents, const ::SnapContext &snapc, - AioObjectRequests *aio_object_requests); - virtual AioObjectRequestHandle *create_object_request( + ObjectRequests *object_requests); + virtual ObjectRequestHandle *create_object_request( const ObjectExtent &object_extent, const ::SnapContext &snapc, Context *on_finish) = 0; - virtual uint64_t append_journal_event(const AioObjectRequests &requests, + virtual uint64_t append_journal_event(const ObjectRequests &requests, bool synchronous) = 0; virtual void update_stats(size_t length) = 0; @@ -151,26 +153,26 @@ private: }; template -class AioImageWrite : public AbstractAioImageWrite { +class ImageWriteRequest : public AbstractImageWriteRequest { public: - using typename AioImageRequest::Extents; + using typename ImageRequest::Extents; - AioImageWrite(ImageCtxT &image_ctx, AioCompletion *aio_comp, uint64_t off, - size_t len, const char *buf, int op_flags) - : AbstractAioImageWrite(image_ctx, aio_comp, {{off, len}}), + ImageWriteRequest(ImageCtxT &image_ctx, AioCompletion *aio_comp, uint64_t off, + size_t len, const char *buf, int op_flags) + : AbstractImageWriteRequest(image_ctx, aio_comp, {{off, len}}), m_op_flags(op_flags) { m_bl.append(buf, len); } - AioImageWrite(ImageCtxT &image_ctx, AioCompletion *aio_comp, - Extents &&image_extents, bufferlist &&bl, int op_flags) - : AbstractAioImageWrite(image_ctx, aio_comp, - std::move(image_extents)), + ImageWriteRequest(ImageCtxT &image_ctx, AioCompletion *aio_comp, + Extents &&image_extents, bufferlist &&bl, int op_flags) + : AbstractImageWriteRequest(image_ctx, aio_comp, + std::move(image_extents)), m_bl(std::move(bl)), m_op_flags(op_flags) { } protected: - using typename AioImageRequest::AioObjectRequests; - using typename AbstractAioImageWrite::ObjectExtents; + using typename ImageRequest::ObjectRequests; + using typename AbstractImageWriteRequest::ObjectExtents; virtual aio_type_t get_aio_type() const { return AIO_TYPE_WRITE; @@ -188,12 +190,12 @@ protected: virtual void send_object_requests(const ObjectExtents &object_extents, const ::SnapContext &snapc, - AioObjectRequests *aio_object_requests); - virtual AioObjectRequestHandle *create_object_request( + ObjectRequests *object_requests); + virtual ObjectRequestHandle *create_object_request( const ObjectExtent &object_extent, const ::SnapContext &snapc, Context *on_finish); - virtual uint64_t append_journal_event(const AioObjectRequests &requests, + virtual uint64_t append_journal_event(const ObjectRequests &requests, bool synchronous); virtual void update_stats(size_t length); private: @@ -202,16 +204,16 @@ private: }; template -class AioImageDiscard : public AbstractAioImageWrite { +class ImageDiscardRequest : public AbstractImageWriteRequest { public: - AioImageDiscard(ImageCtxT &image_ctx, AioCompletion *aio_comp, uint64_t off, - uint64_t len) - : AbstractAioImageWrite(image_ctx, aio_comp, {{off, len}}) { + ImageDiscardRequest(ImageCtxT &image_ctx, AioCompletion *aio_comp, + uint64_t off, uint64_t len) + : AbstractImageWriteRequest(image_ctx, aio_comp, {{off, len}}) { } protected: - using typename AioImageRequest::AioObjectRequests; - using typename AbstractAioImageWrite::ObjectExtents; + using typename ImageRequest::ObjectRequests; + using typename AbstractImageWriteRequest::ObjectExtents; virtual aio_type_t get_aio_type() const { return AIO_TYPE_DISCARD; @@ -228,20 +230,20 @@ protected: virtual void send_object_cache_requests(const ObjectExtents &object_extents, uint64_t journal_tid); - virtual AioObjectRequestHandle *create_object_request( + virtual ObjectRequestHandle *create_object_request( const ObjectExtent &object_extent, const ::SnapContext &snapc, Context *on_finish); - virtual uint64_t append_journal_event(const AioObjectRequests &requests, + virtual uint64_t append_journal_event(const ObjectRequests &requests, bool synchronous); virtual void update_stats(size_t length); }; template -class AioImageFlush : public AioImageRequest { +class ImageFlushRequest : public ImageRequest { public: - AioImageFlush(ImageCtxT &image_ctx, AioCompletion *aio_comp) - : AioImageRequest(image_ctx, aio_comp, {}) { + ImageFlushRequest(ImageCtxT &image_ctx, AioCompletion *aio_comp) + : ImageRequest(image_ctx, aio_comp, {}) { } virtual bool is_write_op() const { @@ -249,7 +251,7 @@ public: } protected: - using typename AioImageRequest::AioObjectRequests; + using typename ImageRequest::ObjectRequests; virtual int clip_request() { return 0; @@ -265,12 +267,14 @@ protected: } }; +} // namespace io } // namespace librbd -extern template class librbd::AioImageRequest; -extern template class librbd::AbstractAioImageWrite; -extern template class librbd::AioImageWrite; -extern template class librbd::AioImageDiscard; -extern template class librbd::AioImageFlush; +extern template class librbd::io::ImageRequest; +extern template class librbd::io::ImageReadRequest; +extern template class librbd::io::AbstractImageWriteRequest; +extern template class librbd::io::ImageWriteRequest; +extern template class librbd::io::ImageDiscardRequest; +extern template class librbd::io::ImageFlushRequest; -#endif // CEPH_LIBRBD_AIO_IMAGE_REQUEST_H +#endif // CEPH_LIBRBD_IO_IMAGE_REQUEST_H diff --git a/src/librbd/AioImageRequestWQ.cc b/src/librbd/io/ImageRequestWQ.cc similarity index 76% rename from src/librbd/AioImageRequestWQ.cc rename to src/librbd/io/ImageRequestWQ.cc index 91b3dc784c8..fcc98347aa8 100644 --- a/src/librbd/AioImageRequestWQ.cc +++ b/src/librbd/io/ImageRequestWQ.cc @@ -1,28 +1,29 @@ // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab -#include "librbd/AioImageRequestWQ.h" +#include "librbd/io/ImageRequestWQ.h" #include "common/errno.h" -#include "librbd/AioCompletion.h" -#include "librbd/AioImageRequest.h" #include "librbd/ExclusiveLock.h" -#include "librbd/exclusive_lock/Policy.h" #include "librbd/ImageCtx.h" #include "librbd/ImageState.h" #include "librbd/internal.h" #include "librbd/Utils.h" +#include "librbd/exclusive_lock/Policy.h" +#include "librbd/io/AioCompletion.h" +#include "librbd/io/ImageRequest.h" #define dout_subsys ceph_subsys_rbd #undef dout_prefix -#define dout_prefix *_dout << "librbd::AioImageRequestWQ: " +#define dout_prefix *_dout << "librbd::io::ImageRequestWQ: " namespace librbd { +namespace io { -AioImageRequestWQ::AioImageRequestWQ(ImageCtx *image_ctx, const string &name, - time_t ti, ThreadPool *tp) - : ThreadPool::PointerWQ >(name, ti, 0, tp), +ImageRequestWQ::ImageRequestWQ(ImageCtx *image_ctx, const string &name, + time_t ti, ThreadPool *tp) + : ThreadPool::PointerWQ >(name, ti, 0, tp), m_image_ctx(*image_ctx), - m_lock(util::unique_lock_name("AioImageRequestWQ::m_lock", this)), + m_lock(util::unique_lock_name("ImageRequestWQ::m_lock", this)), m_write_blockers(0), m_in_progress_writes(0), m_queued_reads(0), m_queued_writes(0), m_in_flight_ops(0), m_refresh_in_progress(false), m_shutdown(false), m_on_shutdown(nullptr) { @@ -31,8 +32,8 @@ AioImageRequestWQ::AioImageRequestWQ(ImageCtx *image_ctx, const string &name, tp->add_work_queue(this); } -ssize_t AioImageRequestWQ::read(uint64_t off, uint64_t len, char *buf, - int op_flags) { +ssize_t ImageRequestWQ::read(uint64_t off, uint64_t len, char *buf, + int op_flags) { CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << "read: ictx=" << &m_image_ctx << ", off=" << off << ", " << "len = " << len << dendl; @@ -43,8 +44,8 @@ ssize_t AioImageRequestWQ::read(uint64_t off, uint64_t len, char *buf, return cond.wait(); } -ssize_t AioImageRequestWQ::write(uint64_t off, uint64_t len, const char *buf, - int op_flags) { +ssize_t ImageRequestWQ::write(uint64_t off, uint64_t len, const char *buf, + int op_flags) { CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << "write: ictx=" << &m_image_ctx << ", off=" << off << ", " << "len = " << len << dendl; @@ -68,7 +69,7 @@ ssize_t AioImageRequestWQ::write(uint64_t off, uint64_t len, const char *buf, return len; } -int AioImageRequestWQ::discard(uint64_t off, uint64_t len) { +int ImageRequestWQ::discard(uint64_t off, uint64_t len) { CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << "discard: ictx=" << &m_image_ctx << ", off=" << off << ", " << "len = " << len << dendl; @@ -92,10 +93,10 @@ int AioImageRequestWQ::discard(uint64_t off, uint64_t len) { return len; } -void AioImageRequestWQ::aio_read(AioCompletion *c, uint64_t off, uint64_t len, - char *buf, bufferlist *pbl, int op_flags, - bool native_async) { - c->init_time(&m_image_ctx, librbd::AIO_TYPE_READ); +void ImageRequestWQ::aio_read(AioCompletion *c, uint64_t off, uint64_t len, + char *buf, bufferlist *pbl, int op_flags, + bool native_async) { + c->init_time(&m_image_ctx, AIO_TYPE_READ); CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << "aio_read: ictx=" << &m_image_ctx << ", " << "completion=" << c << ", off=" << off << ", " @@ -121,19 +122,20 @@ void AioImageRequestWQ::aio_read(AioCompletion *c, uint64_t off, uint64_t len, if (m_image_ctx.non_blocking_aio || writes_blocked() || !writes_empty() || lock_required) { - queue(new AioImageRead<>(m_image_ctx, c, {{off, len}}, buf, pbl, op_flags)); + queue(new ImageReadRequest<>(m_image_ctx, c, {{off, len}}, buf, pbl, + op_flags)); } else { c->start_op(); - AioImageRequest<>::aio_read(&m_image_ctx, c, {{off, len}}, buf, pbl, - op_flags); + ImageRequest<>::aio_read(&m_image_ctx, c, {{off, len}}, buf, pbl, + op_flags); finish_in_flight_op(); } } -void AioImageRequestWQ::aio_write(AioCompletion *c, uint64_t off, uint64_t len, - const char *buf, int op_flags, - bool native_async) { - c->init_time(&m_image_ctx, librbd::AIO_TYPE_WRITE); +void ImageRequestWQ::aio_write(AioCompletion *c, uint64_t off, uint64_t len, + const char *buf, int op_flags, + bool native_async) { + c->init_time(&m_image_ctx, AIO_TYPE_WRITE); CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << "aio_write: ictx=" << &m_image_ctx << ", " << "completion=" << c << ", off=" << off << ", " @@ -149,17 +151,17 @@ void AioImageRequestWQ::aio_write(AioCompletion *c, uint64_t off, uint64_t len, RWLock::RLocker owner_locker(m_image_ctx.owner_lock); if (m_image_ctx.non_blocking_aio || writes_blocked()) { - queue(new AioImageWrite<>(m_image_ctx, c, off, len, buf, op_flags)); + queue(new ImageWriteRequest<>(m_image_ctx, c, off, len, buf, op_flags)); } else { c->start_op(); - AioImageRequest<>::aio_write(&m_image_ctx, c, off, len, buf, op_flags); + ImageRequest<>::aio_write(&m_image_ctx, c, off, len, buf, op_flags); finish_in_flight_op(); } } -void AioImageRequestWQ::aio_discard(AioCompletion *c, uint64_t off, - uint64_t len, bool native_async) { - c->init_time(&m_image_ctx, librbd::AIO_TYPE_DISCARD); +void ImageRequestWQ::aio_discard(AioCompletion *c, uint64_t off, + uint64_t len, bool native_async) { + c->init_time(&m_image_ctx, AIO_TYPE_DISCARD); CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << "aio_discard: ictx=" << &m_image_ctx << ", " << "completion=" << c << ", off=" << off << ", len=" << len @@ -175,16 +177,16 @@ void AioImageRequestWQ::aio_discard(AioCompletion *c, uint64_t off, RWLock::RLocker owner_locker(m_image_ctx.owner_lock); if (m_image_ctx.non_blocking_aio || writes_blocked()) { - queue(new AioImageDiscard<>(m_image_ctx, c, off, len)); + queue(new ImageDiscardRequest<>(m_image_ctx, c, off, len)); } else { c->start_op(); - AioImageRequest<>::aio_discard(&m_image_ctx, c, off, len); + ImageRequest<>::aio_discard(&m_image_ctx, c, off, len); finish_in_flight_op(); } } -void AioImageRequestWQ::aio_flush(AioCompletion *c, bool native_async) { - c->init_time(&m_image_ctx, librbd::AIO_TYPE_FLUSH); +void ImageRequestWQ::aio_flush(AioCompletion *c, bool native_async) { + c->init_time(&m_image_ctx, AIO_TYPE_FLUSH); CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << "aio_flush: ictx=" << &m_image_ctx << ", " << "completion=" << c << dendl; @@ -199,14 +201,14 @@ void AioImageRequestWQ::aio_flush(AioCompletion *c, bool native_async) { RWLock::RLocker owner_locker(m_image_ctx.owner_lock); if (m_image_ctx.non_blocking_aio || writes_blocked() || !writes_empty()) { - queue(new AioImageFlush<>(m_image_ctx, c)); + queue(new ImageFlushRequest<>(m_image_ctx, c)); } else { - AioImageRequest<>::aio_flush(&m_image_ctx, c); + ImageRequest<>::aio_flush(&m_image_ctx, c); finish_in_flight_op(); } } -void AioImageRequestWQ::shut_down(Context *on_shutdown) { +void ImageRequestWQ::shut_down(Context *on_shutdown) { assert(m_image_ctx.owner_lock.is_locked()); { @@ -227,19 +229,19 @@ void AioImageRequestWQ::shut_down(Context *on_shutdown) { m_image_ctx.flush(on_shutdown); } -bool AioImageRequestWQ::is_lock_request_needed() const { +bool ImageRequestWQ::is_lock_request_needed() const { RWLock::RLocker locker(m_lock); return (m_queued_writes.read() > 0 || (m_require_lock_on_read && m_queued_reads.read() > 0)); } -int AioImageRequestWQ::block_writes() { +int ImageRequestWQ::block_writes() { C_SaferCond cond_ctx; block_writes(&cond_ctx); return cond_ctx.wait(); } -void AioImageRequestWQ::block_writes(Context *on_blocked) { +void ImageRequestWQ::block_writes(Context *on_blocked) { assert(m_image_ctx.owner_lock.is_locked()); CephContext *cct = m_image_ctx.cct; @@ -258,7 +260,7 @@ void AioImageRequestWQ::block_writes(Context *on_blocked) { m_image_ctx.flush(on_blocked); } -void AioImageRequestWQ::unblock_writes() { +void ImageRequestWQ::unblock_writes() { CephContext *cct = m_image_ctx.cct; bool wake_up = false; @@ -279,7 +281,7 @@ void AioImageRequestWQ::unblock_writes() { } } -void AioImageRequestWQ::set_require_lock_on_read() { +void ImageRequestWQ::set_require_lock_on_read() { CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << __func__ << dendl; @@ -287,7 +289,7 @@ void AioImageRequestWQ::set_require_lock_on_read() { m_require_lock_on_read = true; } -void AioImageRequestWQ::clear_require_lock_on_read() { +void ImageRequestWQ::clear_require_lock_on_read() { CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << __func__ << dendl; @@ -302,8 +304,8 @@ void AioImageRequestWQ::clear_require_lock_on_read() { signal(); } -void *AioImageRequestWQ::_void_dequeue() { - AioImageRequest<> *peek_item = front(); +void *ImageRequestWQ::_void_dequeue() { + ImageRequest<> *peek_item = front(); // no IO ops available or refresh in-progress (IO stalled) if (peek_item == nullptr || m_refresh_in_progress) { @@ -327,8 +329,8 @@ void *AioImageRequestWQ::_void_dequeue() { } } - AioImageRequest<> *item = reinterpret_cast *>( - ThreadPool::PointerWQ >::_void_dequeue()); + ImageRequest<> *item = reinterpret_cast *>( + ThreadPool::PointerWQ >::_void_dequeue()); assert(peek_item == item); if (refresh_required) { @@ -348,7 +350,7 @@ void *AioImageRequestWQ::_void_dequeue() { return item; } -void AioImageRequestWQ::process(AioImageRequest<> *req) { +void ImageRequestWQ::process(ImageRequest<> *req) { CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << __func__ << ": ictx=" << &m_image_ctx << ", " << "req=" << req << dendl; @@ -364,7 +366,7 @@ void AioImageRequestWQ::process(AioImageRequest<> *req) { finish_in_flight_op(); } -void AioImageRequestWQ::finish_queued_op(AioImageRequest<> *req) { +void ImageRequestWQ::finish_queued_op(ImageRequest<> *req) { RWLock::RLocker locker(m_lock); if (req->is_write_op()) { assert(m_queued_writes.read() > 0); @@ -375,7 +377,7 @@ void AioImageRequestWQ::finish_queued_op(AioImageRequest<> *req) { } } -void AioImageRequestWQ::finish_in_progress_write() { +void ImageRequestWQ::finish_in_progress_write() { bool writes_blocked = false; { RWLock::RLocker locker(m_lock); @@ -391,7 +393,7 @@ void AioImageRequestWQ::finish_in_progress_write() { } } -int AioImageRequestWQ::start_in_flight_op(AioCompletion *c) { +int ImageRequestWQ::start_in_flight_op(AioCompletion *c) { RWLock::RLocker locker(m_lock); if (m_shutdown) { @@ -406,7 +408,7 @@ int AioImageRequestWQ::start_in_flight_op(AioCompletion *c) { return true; } -void AioImageRequestWQ::finish_in_flight_op() { +void ImageRequestWQ::finish_in_flight_op() { Context *on_shutdown; { RWLock::RLocker locker(m_lock); @@ -423,7 +425,7 @@ void AioImageRequestWQ::finish_in_flight_op() { m_image_ctx.flush(on_shutdown); } -bool AioImageRequestWQ::is_lock_required() const { +bool ImageRequestWQ::is_lock_required() const { assert(m_image_ctx.owner_lock.is_locked()); if (m_image_ctx.exclusive_lock == NULL) { return false; @@ -432,7 +434,7 @@ bool AioImageRequestWQ::is_lock_required() const { return (!m_image_ctx.exclusive_lock->is_lock_owner()); } -void AioImageRequestWQ::queue(AioImageRequest<> *req) { +void ImageRequestWQ::queue(ImageRequest<> *req) { CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << __func__ << ": ictx=" << &m_image_ctx << ", " << "req=" << req << dendl; @@ -457,14 +459,14 @@ void AioImageRequestWQ::queue(AioImageRequest<> *req) { m_queued_reads.inc(); } - ThreadPool::PointerWQ >::queue(req); + ThreadPool::PointerWQ >::queue(req); if (lock_required) { m_image_ctx.exclusive_lock->acquire_lock(nullptr); } } -void AioImageRequestWQ::handle_refreshed(int r, AioImageRequest<> *req) { +void ImageRequestWQ::handle_refreshed(int r, ImageRequest<> *req) { CephContext *cct = m_image_ctx.cct; ldout(cct, 15) << "resuming IO after image refresh: r=" << r << ", " << "req=" << req << dendl; @@ -491,7 +493,7 @@ void AioImageRequestWQ::handle_refreshed(int r, AioImageRequest<> *req) { } } -void AioImageRequestWQ::handle_blocked_writes(int r) { +void ImageRequestWQ::handle_blocked_writes(int r) { Contexts contexts; { RWLock::WLocker locker(m_lock); @@ -503,4 +505,5 @@ void AioImageRequestWQ::handle_blocked_writes(int r) { } } +} // namespace io } // namespace librbd diff --git a/src/librbd/AioImageRequestWQ.h b/src/librbd/io/ImageRequestWQ.h similarity index 70% rename from src/librbd/AioImageRequestWQ.h rename to src/librbd/io/ImageRequestWQ.h index 65a70e15cad..6e93ed178dd 100644 --- a/src/librbd/AioImageRequestWQ.h +++ b/src/librbd/io/ImageRequestWQ.h @@ -1,8 +1,8 @@ // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab -#ifndef CEPH_LIBRBD_AIO_IMAGE_REQUEST_WQ_H -#define CEPH_LIBRBD_AIO_IMAGE_REQUEST_WQ_H +#ifndef CEPH_LIBRBD_IO_IMAGE_REQUEST_WQ_H +#define CEPH_LIBRBD_IO_IMAGE_REQUEST_WQ_H #include "include/Context.h" #include "include/atomic.h" @@ -12,14 +12,17 @@ namespace librbd { -class AioCompletion; -template class AioImageRequest; class ImageCtx; -class AioImageRequestWQ : protected ThreadPool::PointerWQ > { +namespace io { + +class AioCompletion; +template class ImageRequest; + +class ImageRequestWQ : protected ThreadPool::PointerWQ > { public: - AioImageRequestWQ(ImageCtx *image_ctx, const string &name, time_t ti, - ThreadPool *tp); + ImageRequestWQ(ImageCtx *image_ctx, const string &name, time_t ti, + ThreadPool *tp); ssize_t read(uint64_t off, uint64_t len, char *buf, int op_flags); ssize_t write(uint64_t off, uint64_t len, const char *buf, int op_flags); @@ -33,8 +36,8 @@ public: bool native_async=true); void aio_flush(AioCompletion *c, bool native_async=true); - using ThreadPool::PointerWQ >::drain; - using ThreadPool::PointerWQ >::empty; + using ThreadPool::PointerWQ >::drain; + using ThreadPool::PointerWQ >::empty; void shut_down(Context *on_shutdown); @@ -54,17 +57,17 @@ public: protected: virtual void *_void_dequeue(); - virtual void process(AioImageRequest *req); + virtual void process(ImageRequest *req); private: typedef std::list Contexts; struct C_RefreshFinish : public Context { - AioImageRequestWQ *aio_work_queue; - AioImageRequest *aio_image_request; + ImageRequestWQ *aio_work_queue; + ImageRequest *aio_image_request; - C_RefreshFinish(AioImageRequestWQ *aio_work_queue, - AioImageRequest *aio_image_request) + C_RefreshFinish(ImageRequestWQ *aio_work_queue, + ImageRequest *aio_image_request) : aio_work_queue(aio_work_queue), aio_image_request(aio_image_request) { } virtual void finish(int r) override { @@ -73,8 +76,8 @@ private: }; struct C_BlockedWrites : public Context { - AioImageRequestWQ *aio_work_queue; - C_BlockedWrites(AioImageRequestWQ *_aio_work_queue) + ImageRequestWQ *aio_work_queue; + C_BlockedWrites(ImageRequestWQ *_aio_work_queue) : aio_work_queue(_aio_work_queue) { } @@ -103,19 +106,20 @@ private: return (m_queued_writes.read() == 0); } - void finish_queued_op(AioImageRequest *req); + void finish_queued_op(ImageRequest *req); void finish_in_progress_write(); int start_in_flight_op(AioCompletion *c); void finish_in_flight_op(); bool is_lock_required() const; - void queue(AioImageRequest *req); + void queue(ImageRequest *req); - void handle_refreshed(int r, AioImageRequest *req); + void handle_refreshed(int r, ImageRequest *req); void handle_blocked_writes(int r); }; +} // namespace io } // namespace librbd -#endif // CEPH_LIBRBD_AIO_IMAGE_REQUEST_WQ_H +#endif // CEPH_LIBRBD_IO_IMAGE_REQUEST_WQ_H diff --git a/src/librbd/AioObjectRequest.cc b/src/librbd/io/ObjectRequest.cc similarity index 75% rename from src/librbd/AioObjectRequest.cc rename to src/librbd/io/ObjectRequest.cc index 3417eda8633..8002c843ed5 100644 --- a/src/librbd/AioObjectRequest.cc +++ b/src/librbd/io/ObjectRequest.cc @@ -1,6 +1,7 @@ // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab +#include "librbd/io/ObjectRequest.h" #include "common/ceph_context.h" #include "common/dout.h" #include "common/errno.h" @@ -9,71 +10,71 @@ #include "common/WorkQueue.h" #include "include/Context.h" -#include "librbd/AioObjectRequest.h" -#include "librbd/AioCompletion.h" -#include "librbd/AioImageRequest.h" -#include "librbd/CopyupRequest.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageCtx.h" #include "librbd/ObjectMap.h" #include "librbd/Utils.h" +#include "librbd/io/AioCompletion.h" +#include "librbd/io/CopyupRequest.h" +#include "librbd/io/ImageRequest.h" #include #include #define dout_subsys ceph_subsys_rbd #undef dout_prefix -#define dout_prefix *_dout << "librbd::AioObjectRequest: " +#define dout_prefix *_dout << "librbd::io::ObjectRequest: " namespace librbd { +namespace io { template -AioObjectRequest* -AioObjectRequest::create_remove(I *ictx, const std::string &oid, - uint64_t object_no, - const ::SnapContext &snapc, - Context *completion) { - return new AioObjectRemove(util::get_image_ctx(ictx), oid, object_no, snapc, - completion); +ObjectRequest* +ObjectRequest::create_remove(I *ictx, const std::string &oid, + uint64_t object_no, + const ::SnapContext &snapc, + Context *completion) { + return new ObjectRemoveRequest(util::get_image_ctx(ictx), oid, object_no, + snapc, completion); } template -AioObjectRequest* -AioObjectRequest::create_truncate(I *ictx, const std::string &oid, - uint64_t object_no, uint64_t object_off, - const ::SnapContext &snapc, - Context *completion) { - return new AioObjectTruncate(util::get_image_ctx(ictx), oid, object_no, - object_off, snapc, completion); +ObjectRequest* +ObjectRequest::create_truncate(I *ictx, const std::string &oid, + uint64_t object_no, uint64_t object_off, + const ::SnapContext &snapc, + Context *completion) { + return new ObjectTruncateRequest(util::get_image_ctx(ictx), oid, object_no, + object_off, snapc, completion); } template -AioObjectRequest* -AioObjectRequest::create_write(I *ictx, const std::string &oid, - uint64_t object_no, uint64_t object_off, - const ceph::bufferlist &data, - const ::SnapContext &snapc, - Context *completion, int op_flags) { - return new AioObjectWrite(util::get_image_ctx(ictx), oid, object_no, - object_off, data, snapc, completion, op_flags); +ObjectRequest* +ObjectRequest::create_write(I *ictx, const std::string &oid, + uint64_t object_no, uint64_t object_off, + const ceph::bufferlist &data, + const ::SnapContext &snapc, + Context *completion, int op_flags) { + return new ObjectWriteRequest(util::get_image_ctx(ictx), oid, object_no, + object_off, data, snapc, completion, op_flags); } template -AioObjectRequest* -AioObjectRequest::create_zero(I *ictx, const std::string &oid, - uint64_t object_no, uint64_t object_off, - uint64_t object_len, - const ::SnapContext &snapc, - Context *completion) { - return new AioObjectZero(util::get_image_ctx(ictx), oid, object_no, - object_off, object_len, snapc, completion); +ObjectRequest* +ObjectRequest::create_zero(I *ictx, const std::string &oid, + uint64_t object_no, uint64_t object_off, + uint64_t object_len, + const ::SnapContext &snapc, + Context *completion) { + return new ObjectZeroRequest(util::get_image_ctx(ictx), oid, object_no, + object_off, object_len, snapc, completion); } template -AioObjectRequest::AioObjectRequest(ImageCtx *ictx, const std::string &oid, - uint64_t objectno, uint64_t off, - uint64_t len, librados::snap_t snap_id, - Context *completion, bool hide_enoent) +ObjectRequest::ObjectRequest(ImageCtx *ictx, const std::string &oid, + uint64_t objectno, uint64_t off, + uint64_t len, librados::snap_t snap_id, + Context *completion, bool hide_enoent) : m_ictx(ictx), m_oid(oid), m_object_no(objectno), m_object_off(off), m_object_len(len), m_snap_id(snap_id), m_completion(completion), m_hide_enoent(hide_enoent) { @@ -87,7 +88,7 @@ AioObjectRequest::AioObjectRequest(ImageCtx *ictx, const std::string &oid, } template -void AioObjectRequest::complete(int r) +void ObjectRequest::complete(int r) { if (should_complete(r)) { ldout(m_ictx->cct, 20) << "complete " << this << dendl; @@ -100,7 +101,7 @@ void AioObjectRequest::complete(int r) } template -bool AioObjectRequest::compute_parent_extents() { +bool ObjectRequest::compute_parent_extents() { assert(m_ictx->snap_lock.is_locked()); assert(m_ictx->parent_lock.is_locked()); @@ -117,8 +118,8 @@ bool AioObjectRequest::compute_parent_extents() { return false; } - uint64_t object_overlap = - m_ictx->prune_parent_extents(m_parent_extents, parent_overlap); + uint64_t object_overlap = m_ictx->prune_parent_extents( + m_parent_extents, parent_overlap); if (object_overlap > 0) { ldout(m_ictx->cct, 20) << this << " compute_parent_extents: " << "overlap " << parent_overlap << " " @@ -140,21 +141,20 @@ static inline bool is_copy_on_read(ImageCtx *ictx, librados::snap_t snap_id) { /** read **/ template -AioObjectRead::AioObjectRead(I *ictx, const std::string &oid, - uint64_t objectno, uint64_t offset, - uint64_t len, - vector >& be, - librados::snap_t snap_id, bool sparse, - Context *completion, int op_flags) - : AioObjectRequest(util::get_image_ctx(ictx), oid, objectno, offset, len, - snap_id, completion, false), +ObjectReadRequest::ObjectReadRequest(I *ictx, const std::string &oid, + uint64_t objectno, uint64_t offset, + uint64_t len, Extents& be, + librados::snap_t snap_id, bool sparse, + Context *completion, int op_flags) + : ObjectRequest(util::get_image_ctx(ictx), oid, objectno, offset, len, + snap_id, completion, false), m_buffer_extents(be), m_tried_parent(false), m_sparse(sparse), m_op_flags(op_flags), m_state(LIBRBD_AIO_READ_FLAT) { guard_read(); } template -void AioObjectRead::guard_read() +void ObjectReadRequest::guard_read() { ImageCtx *image_ctx = this->m_ictx; RWLock::RLocker snap_locker(image_ctx->snap_lock); @@ -167,7 +167,7 @@ void AioObjectRead::guard_read() } template -bool AioObjectRead::should_complete(int r) +bool ObjectReadRequest::should_complete(int r) { ImageCtx *image_ctx = this->m_ictx; ldout(image_ctx->cct, 20) << "should_complete " << this << " " @@ -249,7 +249,7 @@ bool AioObjectRead::should_complete(int r) } template -void AioObjectRead::send() { +void ObjectReadRequest::send() { ImageCtx *image_ctx = this->m_ictx; ldout(image_ctx->cct, 20) << "send " << this << " " << this->m_oid << " " << this->m_object_off << "~" << this->m_object_len @@ -262,7 +262,7 @@ void AioObjectRead::send() { if (image_ctx->object_map != nullptr && !image_ctx->object_map->object_may_exist(this->m_object_no)) { image_ctx->op_work_queue->queue(util::create_context_callback< - AioObjectRequest >(this), -ENOENT); + ObjectRequest >(this), -ENOENT); return; } } @@ -287,7 +287,7 @@ void AioObjectRead::send() { } template -void AioObjectRead::send_copyup() +void ObjectReadRequest::send_copyup() { ImageCtx *image_ctx = this->m_ictx; { @@ -316,39 +316,38 @@ void AioObjectRead::send_copyup() } template -void AioObjectRead::read_from_parent(Extents&& parent_extents) +void ObjectReadRequest::read_from_parent(Extents&& parent_extents) { ImageCtx *image_ctx = this->m_ictx; AioCompletion *parent_completion = AioCompletion::create_and_start< - AioObjectRequest >(this, image_ctx, AIO_TYPE_READ); + ObjectRequest >(this, image_ctx, AIO_TYPE_READ); ldout(image_ctx->cct, 20) << "read_from_parent this = " << this << " parent completion " << parent_completion << " extents " << parent_extents << dendl; - AioImageRequest<>::aio_read(image_ctx->parent, parent_completion, - std::move(parent_extents), nullptr, &m_read_data, - 0); + ImageRequest<>::aio_read(image_ctx->parent, parent_completion, + std::move(parent_extents), nullptr, &m_read_data, 0); } /** write **/ -AbstractAioObjectWrite::AbstractAioObjectWrite(ImageCtx *ictx, - const std::string &oid, - uint64_t object_no, - uint64_t object_off, - uint64_t len, - const ::SnapContext &snapc, - Context *completion, - bool hide_enoent) - : AioObjectRequest(ictx, oid, object_no, object_off, len, CEPH_NOSNAP, - completion, hide_enoent), +AbstractObjectWriteRequest::AbstractObjectWriteRequest(ImageCtx *ictx, + const std::string &oid, + uint64_t object_no, + uint64_t object_off, + uint64_t len, + const ::SnapContext &snapc, + Context *completion, + bool hide_enoent) + : ObjectRequest(ictx, oid, object_no, object_off, len, CEPH_NOSNAP, + completion, hide_enoent), m_state(LIBRBD_AIO_WRITE_FLAT), m_snap_seq(snapc.seq.val) { m_snaps.insert(m_snaps.end(), snapc.snaps.begin(), snapc.snaps.end()); } -void AbstractAioObjectWrite::guard_write() +void AbstractObjectWriteRequest::guard_write() { if (has_parent()) { m_state = LIBRBD_AIO_WRITE_GUARD; @@ -357,7 +356,7 @@ void AbstractAioObjectWrite::guard_write() } } -bool AbstractAioObjectWrite::should_complete(int r) +bool AbstractObjectWriteRequest::should_complete(int r) { ldout(m_ictx->cct, 20) << get_op_type() << " " << this << " " << m_oid << " " << m_object_off << "~" << m_object_len @@ -428,7 +427,7 @@ bool AbstractAioObjectWrite::should_complete(int r) return finished; } -void AbstractAioObjectWrite::send() { +void AbstractObjectWriteRequest::send() { ldout(m_ictx->cct, 20) << "send " << get_op_type() << " " << this <<" " << m_oid << " " << m_object_off << "~" << m_object_len << dendl; @@ -446,7 +445,7 @@ void AbstractAioObjectWrite::send() { send_write(); } -void AbstractAioObjectWrite::send_pre_object_map_update() { +void AbstractObjectWriteRequest::send_pre_object_map_update() { ldout(m_ictx->cct, 20) << __func__ << dendl; { @@ -460,7 +459,7 @@ void AbstractAioObjectWrite::send_pre_object_map_update() { << dendl; m_state = LIBRBD_AIO_WRITE_PRE; - if (m_ictx->object_map->aio_update( + if (m_ictx->object_map->aio_update( CEPH_NOSNAP, m_object_no, new_state, {}, this)) { return; } @@ -470,7 +469,7 @@ void AbstractAioObjectWrite::send_pre_object_map_update() { send_write_op(); } -bool AbstractAioObjectWrite::send_post_object_map_update() { +bool AbstractObjectWriteRequest::send_post_object_map_update() { RWLock::RLocker snap_locker(m_ictx->snap_lock); if (m_ictx->object_map == nullptr || !post_object_map_update()) { return true; @@ -484,7 +483,7 @@ bool AbstractAioObjectWrite::send_post_object_map_update() { << m_object_off << "~" << m_object_len << dendl; m_state = LIBRBD_AIO_WRITE_POST; - if (m_ictx->object_map->aio_update( + if (m_ictx->object_map->aio_update( CEPH_NOSNAP, m_object_no, OBJECT_NONEXISTENT, OBJECT_PENDING, this)) { return false; } @@ -492,7 +491,7 @@ bool AbstractAioObjectWrite::send_post_object_map_update() { return true; } -void AbstractAioObjectWrite::send_write() { +void AbstractObjectWriteRequest::send_write() { ldout(m_ictx->cct, 20) << "send_write " << this << " " << m_oid << " " << m_object_off << "~" << m_object_len << " object exist " << m_object_exist << dendl; @@ -505,7 +504,7 @@ void AbstractAioObjectWrite::send_write() { } } -void AbstractAioObjectWrite::send_copyup() +void AbstractObjectWriteRequest::send_copyup() { ldout(m_ictx->cct, 20) << "send_copyup " << this << " " << m_oid << " " << m_object_off << "~" << m_object_len << dendl; @@ -531,7 +530,7 @@ void AbstractAioObjectWrite::send_copyup() m_ictx->copyup_list_lock.Unlock(); } } -void AbstractAioObjectWrite::send_write_op() +void AbstractObjectWriteRequest::send_write_op() { m_state = LIBRBD_AIO_WRITE_FLAT; if (m_guard) { @@ -548,7 +547,7 @@ void AbstractAioObjectWrite::send_write_op() assert(r == 0); rados_completion->release(); } -void AbstractAioObjectWrite::handle_write_guard() +void AbstractObjectWriteRequest::handle_write_guard() { bool has_parent; { @@ -567,7 +566,7 @@ void AbstractAioObjectWrite::handle_write_guard() } } -void AioObjectWrite::add_write_ops(librados::ObjectWriteOperation *wr) { +void ObjectWriteRequest::add_write_ops(librados::ObjectWriteOperation *wr) { RWLock::RLocker snap_locker(m_ictx->snap_lock); if (m_ictx->enable_alloc_hint && (m_ictx->object_map == nullptr || !m_object_exist)) { @@ -582,7 +581,7 @@ void AioObjectWrite::add_write_ops(librados::ObjectWriteOperation *wr) { wr->set_op_flags2(m_op_flags); } -void AioObjectWrite::send_write() { +void ObjectWriteRequest::send_write() { bool write_full = (m_object_off == 0 && m_object_len == m_ictx->get_object_size()); ldout(m_ictx->cct, 20) << "send_write " << this << " " << m_oid << " " << m_object_off << "~" << m_object_len @@ -592,35 +591,36 @@ void AioObjectWrite::send_write() { m_guard = false; } - AbstractAioObjectWrite::send_write(); + AbstractObjectWriteRequest::send_write(); } -void AioObjectRemove::guard_write() { +void ObjectRemoveRequest::guard_write() { // do nothing to disable write guard only if deep-copyup not required RWLock::RLocker snap_locker(m_ictx->snap_lock); if (!m_ictx->snaps.empty()) { - AbstractAioObjectWrite::guard_write(); + AbstractObjectWriteRequest::guard_write(); } } -void AioObjectRemove::send_write() { +void ObjectRemoveRequest::send_write() { ldout(m_ictx->cct, 20) << "send_write " << this << " " << m_oid << " " << m_object_off << "~" << m_object_len << dendl; send_pre_object_map_update(); } -void AioObjectTruncate::send_write() { +void ObjectTruncateRequest::send_write() { ldout(m_ictx->cct, 20) << "send_write " << this << " " << m_oid << " truncate " << m_object_off << dendl; if (!m_object_exist && ! has_parent()) { m_state = LIBRBD_AIO_WRITE_FLAT; - Context *ctx = util::create_context_callback(this); + Context *ctx = util::create_context_callback(this); m_ictx->op_work_queue->queue(ctx, 0); } else { - AbstractAioObjectWrite::send_write(); + AbstractObjectWriteRequest::send_write(); } } +} // namespace io } // namespace librbd -template class librbd::AioObjectRequest; -template class librbd::AioObjectRead; +template class librbd::io::ObjectRequest; +template class librbd::io::ObjectReadRequest; diff --git a/src/librbd/AioObjectRequest.h b/src/librbd/io/ObjectRequest.h similarity index 63% rename from src/librbd/AioObjectRequest.h rename to src/librbd/io/ObjectRequest.h index 08fa8706200..102e4763212 100644 --- a/src/librbd/AioObjectRequest.h +++ b/src/librbd/io/ObjectRequest.h @@ -1,8 +1,8 @@ // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab -#ifndef CEPH_LIBRBD_AIO_OBJECT_REQUEST_H -#define CEPH_LIBRBD_AIO_OBJECT_REQUEST_H +#ifndef CEPH_LIBRBD_IO_OBJECT_REQUEST_H +#define CEPH_LIBRBD_IO_OBJECT_REQUEST_H #include "include/int_types.h" @@ -17,16 +17,19 @@ class Context; namespace librbd { -struct AioCompletion; -class AioObjectRemove; -class AioObjectTruncate; -class AioObjectWrite; -class AioObjectZero; struct ImageCtx; + +namespace io { + +struct AioCompletion; class CopyupRequest; +class ObjectRemoveRequest; +class ObjectTruncateRequest; +class ObjectWriteRequest; +class ObjectZeroRequest; -struct AioObjectRequestHandle { - virtual ~AioObjectRequestHandle() { +struct ObjectRequestHandle { + virtual ~ObjectRequestHandle() { } virtual void complete(int r) = 0; @@ -39,38 +42,38 @@ struct AioObjectRequestHandle { * for I/O due to layering. */ template -class AioObjectRequest : public AioObjectRequestHandle { +class ObjectRequest : public ObjectRequestHandle { public: typedef std::vector > Extents; - static AioObjectRequest* create_remove(ImageCtxT *ictx, - const std::string &oid, - uint64_t object_no, - const ::SnapContext &snapc, - Context *completion); - static AioObjectRequest* create_truncate(ImageCtxT *ictx, - const std::string &oid, - uint64_t object_no, - uint64_t object_off, - const ::SnapContext &snapc, - Context *completion); - static AioObjectRequest* create_write(ImageCtxT *ictx, const std::string &oid, + static ObjectRequest* create_remove(ImageCtxT *ictx, + const std::string &oid, + uint64_t object_no, + const ::SnapContext &snapc, + Context *completion); + static ObjectRequest* create_truncate(ImageCtxT *ictx, + const std::string &oid, uint64_t object_no, uint64_t object_off, - const ceph::bufferlist &data, const ::SnapContext &snapc, - Context *completion, int op_flags); - static AioObjectRequest* create_zero(ImageCtxT *ictx, const std::string &oid, - uint64_t object_no, uint64_t object_off, - uint64_t object_len, - const ::SnapContext &snapc, - Context *completion); - - AioObjectRequest(ImageCtx *ictx, const std::string &oid, - uint64_t objectno, uint64_t off, uint64_t len, - librados::snap_t snap_id, - Context *completion, bool hide_enoent); - virtual ~AioObjectRequest() {} + Context *completion); + static ObjectRequest* create_write(ImageCtxT *ictx, const std::string &oid, + uint64_t object_no, + uint64_t object_off, + const ceph::bufferlist &data, + const ::SnapContext &snapc, + Context *completion, int op_flags); + static ObjectRequest* create_zero(ImageCtxT *ictx, const std::string &oid, + uint64_t object_no, uint64_t object_off, + uint64_t object_len, + const ::SnapContext &snapc, + Context *completion); + + ObjectRequest(ImageCtx *ictx, const std::string &oid, + uint64_t objectno, uint64_t off, uint64_t len, + librados::snap_t snap_id, + Context *completion, bool hide_enoent); + virtual ~ObjectRequest() {} virtual void add_copyup_ops(librados::ObjectWriteOperation *wr) {}; @@ -106,24 +109,25 @@ private: }; template -class AioObjectRead : public AioObjectRequest { +class ObjectReadRequest : public ObjectRequest { public: typedef std::vector > Extents; typedef std::map ExtentMap; - static AioObjectRead* create(ImageCtxT *ictx, const std::string &oid, - uint64_t objectno, uint64_t offset, - uint64_t len, Extents &buffer_extents, - librados::snap_t snap_id, bool sparse, - Context *completion, int op_flags) { - return new AioObjectRead(ictx, oid, objectno, offset, len, buffer_extents, - snap_id, sparse, completion, op_flags); + static ObjectReadRequest* create(ImageCtxT *ictx, const std::string &oid, + uint64_t objectno, uint64_t offset, + uint64_t len, Extents &buffer_extents, + librados::snap_t snap_id, bool sparse, + Context *completion, int op_flags) { + return new ObjectReadRequest(ictx, oid, objectno, offset, len, + buffer_extents, snap_id, sparse, completion, + op_flags); } - AioObjectRead(ImageCtxT *ictx, const std::string &oid, - uint64_t objectno, uint64_t offset, uint64_t len, - Extents& buffer_extents, librados::snap_t snap_id, bool sparse, - Context *completion, int op_flags); + ObjectReadRequest(ImageCtxT *ictx, const std::string &oid, + uint64_t objectno, uint64_t offset, uint64_t len, + Extents& buffer_extents, librados::snap_t snap_id, + bool sparse, Context *completion, int op_flags); virtual bool should_complete(int r); virtual void send(); @@ -190,12 +194,12 @@ private: void read_from_parent(Extents&& image_extents); }; -class AbstractAioObjectWrite : public AioObjectRequest<> { +class AbstractObjectWriteRequest : public ObjectRequest<> { public: - AbstractAioObjectWrite(ImageCtx *ictx, const std::string &oid, - uint64_t object_no, uint64_t object_off, - uint64_t len, const ::SnapContext &snapc, - Context *completion, bool hide_enoent); + AbstractObjectWriteRequest(ImageCtx *ictx, const std::string &oid, + uint64_t object_no, uint64_t object_off, + uint64_t len, const ::SnapContext &snapc, + Context *completion, bool hide_enoent); virtual void add_copyup_ops(librados::ObjectWriteOperation *wr) { @@ -274,14 +278,14 @@ private: void send_copyup(); }; -class AioObjectWrite : public AbstractAioObjectWrite { +class ObjectWriteRequest : public AbstractObjectWriteRequest { public: - AioObjectWrite(ImageCtx *ictx, const std::string &oid, uint64_t object_no, - uint64_t object_off, const ceph::bufferlist &data, - const ::SnapContext &snapc, Context *completion, - int op_flags) - : AbstractAioObjectWrite(ictx, oid, object_no, object_off, data.length(), - snapc, completion, false), + ObjectWriteRequest(ImageCtx *ictx, const std::string &oid, uint64_t object_no, + uint64_t object_off, const ceph::bufferlist &data, + const ::SnapContext &snapc, Context *completion, + int op_flags) + : AbstractObjectWriteRequest(ictx, oid, object_no, object_off, + data.length(), snapc, completion, false), m_write_data(data), m_op_flags(op_flags) { } @@ -308,12 +312,13 @@ private: int m_op_flags; }; -class AioObjectRemove : public AbstractAioObjectWrite { +class ObjectRemoveRequest : public AbstractObjectWriteRequest { public: - AioObjectRemove(ImageCtx *ictx, const std::string &oid, uint64_t object_no, - const ::SnapContext &snapc, Context *completion) - : AbstractAioObjectWrite(ictx, oid, object_no, 0, 0, snapc, completion, - true), + ObjectRemoveRequest(ImageCtx *ictx, const std::string &oid, + uint64_t object_no, const ::SnapContext &snapc, + Context *completion) + : AbstractObjectWriteRequest(ictx, oid, object_no, 0, 0, snapc, completion, + true), m_object_state(OBJECT_NONEXISTENT) { } @@ -357,16 +362,18 @@ private: uint8_t m_object_state; }; -class AioObjectTrim : public AbstractAioObjectWrite { +class ObjectTrimRequest : public AbstractObjectWriteRequest { public: // we'd need to only conditionally specify if a post object map // update is needed. pre update is decided as usual (by checking // the state of the object in the map). - AioObjectTrim(ImageCtx *ictx, const std::string &oid, uint64_t object_no, - const ::SnapContext &snapc, Context *completion, - bool post_object_map_update) - : AbstractAioObjectWrite(ictx, oid, object_no, 0, 0, snapc, completion, - true), m_post_object_map_update(post_object_map_update) { } + ObjectTrimRequest(ImageCtx *ictx, const std::string &oid, uint64_t object_no, + const ::SnapContext &snapc, Context *completion, + bool post_object_map_update) + : AbstractObjectWriteRequest(ictx, oid, object_no, 0, 0, snapc, completion, + true), + m_post_object_map_update(post_object_map_update) { + } virtual const char* get_op_type() const { return "remove (trim)"; @@ -390,13 +397,13 @@ private: bool m_post_object_map_update; }; -class AioObjectTruncate : public AbstractAioObjectWrite { +class ObjectTruncateRequest : public AbstractObjectWriteRequest { public: - AioObjectTruncate(ImageCtx *ictx, const std::string &oid, - uint64_t object_no, uint64_t object_off, - const ::SnapContext &snapc, Context *completion) - : AbstractAioObjectWrite(ictx, oid, object_no, object_off, 0, snapc, - completion, true) { + ObjectTruncateRequest(ImageCtx *ictx, const std::string &oid, + uint64_t object_no, uint64_t object_off, + const ::SnapContext &snapc, Context *completion) + : AbstractObjectWriteRequest(ictx, oid, object_no, object_off, 0, snapc, + completion, true) { } virtual const char* get_op_type() const { @@ -419,13 +426,13 @@ protected: } }; -class AioObjectZero : public AbstractAioObjectWrite { +class ObjectZeroRequest : public AbstractObjectWriteRequest { public: - AioObjectZero(ImageCtx *ictx, const std::string &oid, uint64_t object_no, - uint64_t object_off, uint64_t object_len, - const ::SnapContext &snapc, Context *completion) - : AbstractAioObjectWrite(ictx, oid, object_no, object_off, object_len, - snapc, completion, true) { + ObjectZeroRequest(ImageCtx *ictx, const std::string &oid, uint64_t object_no, + uint64_t object_off, uint64_t object_len, + const ::SnapContext &snapc, Context *completion) + : AbstractObjectWriteRequest(ictx, oid, object_no, object_off, object_len, + snapc, completion, true) { } virtual const char* get_op_type() const { @@ -443,9 +450,10 @@ protected: } }; +} // namespace io } // namespace librbd -extern template class librbd::AioObjectRequest; -extern template class librbd::AioObjectRead; +extern template class librbd::io::ObjectRequest; +extern template class librbd::io::ObjectReadRequest; -#endif // CEPH_LIBRBD_AIO_OBJECT_REQUEST_H +#endif // CEPH_LIBRBD_IO_OBJECT_REQUEST_H diff --git a/src/librbd/io/Types.h b/src/librbd/io/Types.h new file mode 100644 index 00000000000..f80df9f3eff --- /dev/null +++ b/src/librbd/io/Types.h @@ -0,0 +1,31 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_LIBRBD_IO_TYPES_H +#define CEPH_LIBRBD_IO_TYPES_H + +#include "include/int_types.h" +#include +#include + +namespace librbd { +namespace io { + +typedef enum { + AIO_TYPE_NONE = 0, + AIO_TYPE_OPEN, + AIO_TYPE_CLOSE, + AIO_TYPE_READ, + AIO_TYPE_WRITE, + AIO_TYPE_DISCARD, + AIO_TYPE_FLUSH, +} aio_type_t; + +typedef std::vector > Extents; +typedef std::map ExtentMap; + +} // namespace io +} // namespace librbd + +#endif // CEPH_LIBRBD_IO_TYPES_H + diff --git a/src/librbd/journal/Replay.cc b/src/librbd/journal/Replay.cc index 413465b2382..3049bb86388 100644 --- a/src/librbd/journal/Replay.cc +++ b/src/librbd/journal/Replay.cc @@ -5,13 +5,13 @@ #include "common/dout.h" #include "common/errno.h" #include "common/WorkQueue.h" -#include "librbd/AioCompletion.h" -#include "librbd/AioImageRequest.h" #include "librbd/ImageCtx.h" #include "librbd/ImageState.h" #include "librbd/internal.h" #include "librbd/Operations.h" #include "librbd/Utils.h" +#include "librbd/io/AioCompletion.h" +#include "librbd/io/ImageRequest.h" #define dout_subsys ceph_subsys_rbd #undef dout_prefix @@ -202,7 +202,7 @@ void Replay::shut_down(bool cancel_ops, Context *on_finish) { CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << dendl; - AioCompletion *flush_comp = nullptr; + io::AioCompletion *flush_comp = nullptr; on_finish = util::create_async_context_callback( m_image_ctx, on_finish); @@ -245,7 +245,7 @@ void Replay::shut_down(bool cancel_ops, Context *on_finish) { // execute the following outside of lock scope if (flush_comp != nullptr) { RWLock::RLocker owner_locker(m_image_ctx.owner_lock); - AioImageRequest::aio_flush(&m_image_ctx, flush_comp); + io::ImageRequest::aio_flush(&m_image_ctx, flush_comp); } if (on_finish != nullptr) { on_finish->complete(0); @@ -254,7 +254,7 @@ void Replay::shut_down(bool cancel_ops, Context *on_finish) { template void Replay::flush(Context *on_finish) { - AioCompletion *aio_comp; + io::AioCompletion *aio_comp; { Mutex::Locker locker(m_lock); aio_comp = create_aio_flush_completion( @@ -262,7 +262,7 @@ void Replay::flush(Context *on_finish) { } RWLock::RLocker owner_locker(m_image_ctx.owner_lock); - AioImageRequest::aio_flush(&m_image_ctx, aio_comp); + io::ImageRequest::aio_flush(&m_image_ctx, aio_comp); } template @@ -311,17 +311,17 @@ void Replay::handle_event(const journal::AioDiscardEvent &event, ldout(cct, 20) << ": AIO discard event" << dendl; bool flush_required; - AioCompletion *aio_comp = create_aio_modify_completion(on_ready, on_safe, - AIO_TYPE_DISCARD, - &flush_required); - AioImageRequest::aio_discard(&m_image_ctx, aio_comp, event.offset, - event.length); + auto aio_comp = create_aio_modify_completion(on_ready, on_safe, + io::AIO_TYPE_DISCARD, + &flush_required); + io::ImageRequest::aio_discard(&m_image_ctx, aio_comp, event.offset, + event.length); if (flush_required) { m_lock.Lock(); - AioCompletion *flush_comp = create_aio_flush_completion(nullptr); + auto flush_comp = create_aio_flush_completion(nullptr); m_lock.Unlock(); - AioImageRequest::aio_flush(&m_image_ctx, flush_comp); + io::ImageRequest::aio_flush(&m_image_ctx, flush_comp); } } @@ -333,17 +333,17 @@ void Replay::handle_event(const journal::AioWriteEvent &event, bufferlist data = event.data; bool flush_required; - AioCompletion *aio_comp = create_aio_modify_completion(on_ready, on_safe, - AIO_TYPE_WRITE, - &flush_required); - AioImageRequest::aio_write(&m_image_ctx, aio_comp, event.offset, - event.length, data.c_str(), 0); + auto aio_comp = create_aio_modify_completion(on_ready, on_safe, + io::AIO_TYPE_WRITE, + &flush_required); + io::ImageRequest::aio_write(&m_image_ctx, aio_comp, event.offset, + event.length, data.c_str(), 0); if (flush_required) { m_lock.Lock(); - AioCompletion *flush_comp = create_aio_flush_completion(nullptr); + auto flush_comp = create_aio_flush_completion(nullptr); m_lock.Unlock(); - AioImageRequest::aio_flush(&m_image_ctx, flush_comp); + io::ImageRequest::aio_flush(&m_image_ctx, flush_comp); } } @@ -353,12 +353,12 @@ void Replay::handle_event(const journal::AioFlushEvent &event, CephContext *cct = m_image_ctx.cct; ldout(cct, 20) << ": AIO flush event" << dendl; - AioCompletion *aio_comp; + io::AioCompletion *aio_comp; { Mutex::Locker locker(m_lock); aio_comp = create_aio_flush_completion(on_safe); } - AioImageRequest::aio_flush(&m_image_ctx, aio_comp); + io::ImageRequest::aio_flush(&m_image_ctx, aio_comp); on_ready->complete(0); } @@ -922,10 +922,10 @@ void Replay::handle_op_complete(uint64_t op_tid, int r) { } template -AioCompletion *Replay::create_aio_modify_completion(Context *on_ready, - Context *on_safe, - aio_type_t aio_type, - bool *flush_required) { +io::AioCompletion * +Replay::create_aio_modify_completion(Context *on_ready, Context *on_safe, + io::aio_type_t aio_type, + bool *flush_required) { Mutex::Locker locker(m_lock); CephContext *cct = m_image_ctx.cct; assert(m_on_aio_ready == nullptr); @@ -959,23 +959,23 @@ AioCompletion *Replay::create_aio_modify_completion(Context *on_ready, // when the modification is ACKed by librbd, we can process the next // event. when flushed, the completion of the next flush will fire the // on_safe callback - AioCompletion *aio_comp = AioCompletion::create_and_start( + auto aio_comp = io::AioCompletion::create_and_start( new C_AioModifyComplete(this, on_ready, on_safe), util::get_image_ctx(&m_image_ctx), aio_type); return aio_comp; } template -AioCompletion *Replay::create_aio_flush_completion(Context *on_safe) { +io::AioCompletion *Replay::create_aio_flush_completion(Context *on_safe) { assert(m_lock.is_locked()); ++m_in_flight_aio_flush; // associate all prior write/discard ops to this flush request - AioCompletion *aio_comp = AioCompletion::create_and_start( + auto aio_comp = io::AioCompletion::create_and_start( new C_AioFlushComplete(this, on_safe, std::move(m_aio_modify_unsafe_contexts)), - util::get_image_ctx(&m_image_ctx), AIO_TYPE_FLUSH); + util::get_image_ctx(&m_image_ctx), io::AIO_TYPE_FLUSH); m_aio_modify_unsafe_contexts.clear(); return aio_comp; } diff --git a/src/librbd/journal/Replay.h b/src/librbd/journal/Replay.h index 5b7b7e07925..6b7fdd67b74 100644 --- a/src/librbd/journal/Replay.h +++ b/src/librbd/journal/Replay.h @@ -8,7 +8,7 @@ #include "include/buffer_fwd.h" #include "include/Context.h" #include "common/Mutex.h" -#include "librbd/AioCompletion.h" +#include "librbd/io/Types.h" #include "librbd/journal/Types.h" #include #include @@ -17,8 +17,8 @@ namespace librbd { -class AioCompletion; class ImageCtx; +namespace io { struct AioCompletion; } namespace journal { @@ -176,12 +176,12 @@ private: Context *on_safe, OpEvent **op_event); void handle_op_complete(uint64_t op_tid, int r); - AioCompletion *create_aio_modify_completion(Context *on_ready, - Context *on_safe, - aio_type_t aio_type, - bool *flush_required); - AioCompletion *create_aio_flush_completion(Context *on_safe); - void handle_aio_completion(AioCompletion *aio_comp); + io::AioCompletion *create_aio_modify_completion(Context *on_ready, + Context *on_safe, + io::aio_type_t aio_type, + bool *flush_required); + io::AioCompletion *create_aio_flush_completion(Context *on_safe); + void handle_aio_completion(io::AioCompletion *aio_comp); }; diff --git a/src/librbd/librbd.cc b/src/librbd/librbd.cc index f9ac0030068..b8936f9af02 100644 --- a/src/librbd/librbd.cc +++ b/src/librbd/librbd.cc @@ -21,8 +21,6 @@ #include "common/TracepointProvider.h" #include "include/Context.h" -#include "librbd/AioCompletion.h" -#include "librbd/AioImageRequestWQ.h" #include "cls/rbd/cls_rbd_client.h" #include "cls/rbd/cls_rbd_types.h" #include "librbd/Group.h" @@ -30,6 +28,8 @@ #include "librbd/ImageState.h" #include "librbd/internal.h" #include "librbd/Operations.h" +#include "librbd/io/AioCompletion.h" +#include "librbd/io/ImageRequestWQ.h" #include #include #include @@ -63,19 +63,19 @@ CephContext* get_cct(IoCtx &io_ctx) { return reinterpret_cast(io_ctx.cct()); } -librbd::AioCompletion* get_aio_completion(librbd::RBD::AioCompletion *comp) { - return reinterpret_cast(comp->pc); +librbd::io::AioCompletion* get_aio_completion(librbd::RBD::AioCompletion *comp) { + return reinterpret_cast(comp->pc); } struct C_OpenComplete : public Context { librbd::ImageCtx *ictx; - librbd::AioCompletion* comp; + librbd::io::AioCompletion* comp; void **ictxp; bool reopen; - C_OpenComplete(librbd::ImageCtx *ictx, librbd::AioCompletion* comp, + C_OpenComplete(librbd::ImageCtx *ictx, librbd::io::AioCompletion* comp, void **ictxp, bool reopen = false) : ictx(ictx), comp(comp), ictxp(ictxp), reopen(reopen) { - comp->init_time(ictx, librbd::AIO_TYPE_OPEN); + comp->init_time(ictx, librbd::io::AIO_TYPE_OPEN); comp->get(); } void finish(int r) override { @@ -97,9 +97,10 @@ struct C_OpenComplete : public Context { struct C_OpenAfterCloseComplete : public Context { librbd::ImageCtx *ictx; - librbd::AioCompletion* comp; + librbd::io::AioCompletion* comp; void **ictxp; - C_OpenAfterCloseComplete(librbd::ImageCtx *ictx, librbd::AioCompletion* comp, + C_OpenAfterCloseComplete(librbd::ImageCtx *ictx, + librbd::io::AioCompletion* comp, void **ictxp) : ictx(ictx), comp(comp), ictxp(ictxp) { } @@ -112,10 +113,10 @@ struct C_OpenAfterCloseComplete : public Context { struct C_CloseComplete : public Context { CephContext *cct; - librbd::AioCompletion* comp; - C_CloseComplete(librbd::ImageCtx *ictx, librbd::AioCompletion* comp) + librbd::io::AioCompletion* comp; + C_CloseComplete(librbd::ImageCtx *ictx, librbd::io::AioCompletion* comp) : cct(ictx->cct), comp(comp) { - comp->init_time(ictx, librbd::AIO_TYPE_CLOSE); + comp->init_time(ictx, librbd::io::AIO_TYPE_CLOSE); comp->get(); } void finish(int r) override { @@ -536,37 +537,37 @@ namespace librbd { RBD::AioCompletion::AioCompletion(void *cb_arg, callback_t complete_cb) { - pc = reinterpret_cast(librbd::AioCompletion::create( + pc = reinterpret_cast(librbd::io::AioCompletion::create( cb_arg, complete_cb, this)); } bool RBD::AioCompletion::is_complete() { - librbd::AioCompletion *c = (librbd::AioCompletion *)pc; + librbd::io::AioCompletion *c = (librbd::io::AioCompletion *)pc; return c->is_complete(); } int RBD::AioCompletion::wait_for_complete() { - librbd::AioCompletion *c = (librbd::AioCompletion *)pc; + librbd::io::AioCompletion *c = (librbd::io::AioCompletion *)pc; return c->wait_for_complete(); } ssize_t RBD::AioCompletion::get_return_value() { - librbd::AioCompletion *c = (librbd::AioCompletion *)pc; + librbd::io::AioCompletion *c = (librbd::io::AioCompletion *)pc; return c->get_return_value(); } void *RBD::AioCompletion::get_arg() { - librbd::AioCompletion *c = (librbd::AioCompletion *)pc; + librbd::io::AioCompletion *c = (librbd::io::AioCompletion *)pc; return c->get_arg(); } void RBD::AioCompletion::release() { - librbd::AioCompletion *c = (librbd::AioCompletion *)pc; + librbd::io::AioCompletion *c = (librbd::io::AioCompletion *)pc; c->release(); delete this; } @@ -1217,7 +1218,7 @@ namespace librbd { tracepoint(librbd, read_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, ofs, len); bufferptr ptr(len); bl.push_back(std::move(ptr)); - int r = ictx->aio_work_queue->read(ofs, len, bl.c_str(), 0); + int r = ictx->io_work_queue->read(ofs, len, bl.c_str(), 0); tracepoint(librbd, read_exit, r); return r; } @@ -1229,7 +1230,7 @@ namespace librbd { ictx->read_only, ofs, len, op_flags); bufferptr ptr(len); bl.push_back(std::move(ptr)); - int r = ictx->aio_work_queue->read(ofs, len, bl.c_str(), op_flags); + int r = ictx->io_work_queue->read(ofs, len, bl.c_str(), op_flags); tracepoint(librbd, read_exit, r); return r; } @@ -1295,7 +1296,7 @@ namespace librbd { tracepoint(librbd, write_exit, -EINVAL); return -EINVAL; } - int r = ictx->aio_work_queue->write(ofs, len, bl.c_str(), 0); + int r = ictx->io_work_queue->write(ofs, len, bl.c_str(), 0); tracepoint(librbd, write_exit, r); return r; } @@ -1309,7 +1310,7 @@ namespace librbd { tracepoint(librbd, write_exit, -EINVAL); return -EINVAL; } - int r = ictx->aio_work_queue->write(ofs, len, bl.c_str(), op_flags); + int r = ictx->io_work_queue->write(ofs, len, bl.c_str(), op_flags); tracepoint(librbd, write_exit, r); return r; } @@ -1322,7 +1323,7 @@ namespace librbd { tracepoint(librbd, discard_exit, -EINVAL); return -EINVAL; } - int r = ictx->aio_work_queue->discard(ofs, len); + int r = ictx->io_work_queue->discard(ofs, len); tracepoint(librbd, discard_exit, r); return r; } @@ -1336,8 +1337,8 @@ namespace librbd { tracepoint(librbd, aio_write_exit, -EINVAL); return -EINVAL; } - ictx->aio_work_queue->aio_write(get_aio_completion(c), off, len, bl.c_str(), - 0); + ictx->io_work_queue->aio_write(get_aio_completion(c), off, len, bl.c_str(), + 0); tracepoint(librbd, aio_write_exit, 0); return 0; } @@ -1352,8 +1353,8 @@ namespace librbd { tracepoint(librbd, aio_write_exit, -EINVAL); return -EINVAL; } - ictx->aio_work_queue->aio_write(get_aio_completion(c), off, len, bl.c_str(), - op_flags); + ictx->io_work_queue->aio_write(get_aio_completion(c), off, len, bl.c_str(), + op_flags); tracepoint(librbd, aio_write_exit, 0); return 0; } @@ -1362,7 +1363,7 @@ namespace librbd { { ImageCtx *ictx = (ImageCtx *)ctx; tracepoint(librbd, aio_discard_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, off, len, c->pc); - ictx->aio_work_queue->aio_discard(get_aio_completion(c), off, len); + ictx->io_work_queue->aio_discard(get_aio_completion(c), off, len); tracepoint(librbd, aio_discard_exit, 0); return 0; } @@ -1374,8 +1375,8 @@ namespace librbd { tracepoint(librbd, aio_read_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, off, len, bl.c_str(), c->pc); ldout(ictx->cct, 10) << "Image::aio_read() buf=" << (void *)bl.c_str() << "~" << (void *)(bl.c_str() + len - 1) << dendl; - ictx->aio_work_queue->aio_read(get_aio_completion(c), off, len, NULL, &bl, - 0); + ictx->io_work_queue->aio_read(get_aio_completion(c), off, len, NULL, &bl, + 0); tracepoint(librbd, aio_read_exit, 0); return 0; } @@ -1388,8 +1389,8 @@ namespace librbd { ictx->read_only, off, len, bl.c_str(), c->pc, op_flags); ldout(ictx->cct, 10) << "Image::aio_read() buf=" << (void *)bl.c_str() << "~" << (void *)(bl.c_str() + len - 1) << dendl; - ictx->aio_work_queue->aio_read(get_aio_completion(c), off, len, NULL, &bl, - op_flags); + ictx->io_work_queue->aio_read(get_aio_completion(c), off, len, NULL, &bl, + op_flags); tracepoint(librbd, aio_read_exit, 0); return 0; } @@ -1407,7 +1408,7 @@ namespace librbd { { ImageCtx *ictx = (ImageCtx *)ctx; tracepoint(librbd, aio_flush_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, c->pc); - ictx->aio_work_queue->aio_flush(get_aio_completion(c)); + ictx->io_work_queue->aio_flush(get_aio_completion(c)); tracepoint(librbd, aio_flush_exit, 0); return 0; } @@ -1423,7 +1424,7 @@ namespace librbd { int Image::poll_io_events(RBD::AioCompletion **comps, int numcomp) { - AioCompletion *cs[numcomp]; + io::AioCompletion *cs[numcomp]; ImageCtx *ictx = (ImageCtx *)ctx; tracepoint(librbd, poll_io_events_enter, ictx, numcomp); int r = librbd::poll_io_events(ictx, cs, numcomp); @@ -2781,7 +2782,7 @@ extern "C" ssize_t rbd_read(rbd_image_t image, uint64_t ofs, size_t len, { librbd::ImageCtx *ictx = (librbd::ImageCtx *)image; tracepoint(librbd, read_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, ofs, len); - int r = ictx->aio_work_queue->read(ofs, len, buf, 0); + int r = ictx->io_work_queue->read(ofs, len, buf, 0); tracepoint(librbd, read_exit, r); return r; } @@ -2792,7 +2793,7 @@ extern "C" ssize_t rbd_read2(rbd_image_t image, uint64_t ofs, size_t len, librbd::ImageCtx *ictx = (librbd::ImageCtx *)image; tracepoint(librbd, read2_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, ofs, len, op_flags); - int r = ictx->aio_work_queue->read(ofs, len, buf, op_flags); + int r = ictx->io_work_queue->read(ofs, len, buf, op_flags); tracepoint(librbd, read_exit, r); return r; } @@ -2859,7 +2860,7 @@ extern "C" ssize_t rbd_write(rbd_image_t image, uint64_t ofs, size_t len, { librbd::ImageCtx *ictx = (librbd::ImageCtx *)image; tracepoint(librbd, write_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, ofs, len, buf); - int r = ictx->aio_work_queue->write(ofs, len, buf, 0); + int r = ictx->io_work_queue->write(ofs, len, buf, 0); tracepoint(librbd, write_exit, r); return r; } @@ -2870,7 +2871,7 @@ extern "C" ssize_t rbd_write2(rbd_image_t image, uint64_t ofs, size_t len, librbd::ImageCtx *ictx = (librbd::ImageCtx *)image; tracepoint(librbd, write2_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, ofs, len, buf, op_flags); - int r = ictx->aio_work_queue->write(ofs, len, buf, op_flags); + int r = ictx->io_work_queue->write(ofs, len, buf, op_flags); tracepoint(librbd, write_exit, r); return r; } @@ -2880,7 +2881,7 @@ extern "C" int rbd_discard(rbd_image_t image, uint64_t ofs, uint64_t len) { librbd::ImageCtx *ictx = (librbd::ImageCtx *)image; tracepoint(librbd, discard_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, ofs, len); - int r = ictx->aio_work_queue->discard(ofs, len); + int r = ictx->io_work_queue->discard(ofs, len); tracepoint(librbd, discard_exit, r); return r; } @@ -2901,7 +2902,7 @@ extern "C" int rbd_aio_write(rbd_image_t image, uint64_t off, size_t len, librbd::ImageCtx *ictx = (librbd::ImageCtx *)image; librbd::RBD::AioCompletion *comp = (librbd::RBD::AioCompletion *)c; tracepoint(librbd, aio_write_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, off, len, buf, comp->pc); - ictx->aio_work_queue->aio_write(get_aio_completion(comp), off, len, buf, 0); + ictx->io_work_queue->aio_write(get_aio_completion(comp), off, len, buf, 0); tracepoint(librbd, aio_write_exit, 0); return 0; } @@ -2913,8 +2914,8 @@ extern "C" int rbd_aio_write2(rbd_image_t image, uint64_t off, size_t len, librbd::RBD::AioCompletion *comp = (librbd::RBD::AioCompletion *)c; tracepoint(librbd, aio_write2_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, off, len, buf, comp->pc, op_flags); - ictx->aio_work_queue->aio_write(get_aio_completion(comp), off, len, buf, - op_flags); + ictx->io_work_queue->aio_write(get_aio_completion(comp), off, len, buf, + op_flags); tracepoint(librbd, aio_write_exit, 0); return 0; } @@ -2926,7 +2927,7 @@ extern "C" int rbd_aio_discard(rbd_image_t image, uint64_t off, uint64_t len, librbd::ImageCtx *ictx = (librbd::ImageCtx *)image; librbd::RBD::AioCompletion *comp = (librbd::RBD::AioCompletion *)c; tracepoint(librbd, aio_discard_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, off, len, comp->pc); - ictx->aio_work_queue->aio_discard(get_aio_completion(comp), off, len); + ictx->io_work_queue->aio_discard(get_aio_completion(comp), off, len); tracepoint(librbd, aio_discard_exit, 0); return 0; } @@ -2937,8 +2938,8 @@ extern "C" int rbd_aio_read(rbd_image_t image, uint64_t off, size_t len, librbd::ImageCtx *ictx = (librbd::ImageCtx *)image; librbd::RBD::AioCompletion *comp = (librbd::RBD::AioCompletion *)c; tracepoint(librbd, aio_read_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, off, len, buf, comp->pc); - ictx->aio_work_queue->aio_read(get_aio_completion(comp), off, len, buf, NULL, - 0); + ictx->io_work_queue->aio_read(get_aio_completion(comp), off, len, buf, NULL, + 0); tracepoint(librbd, aio_read_exit, 0); return 0; } @@ -2950,8 +2951,8 @@ extern "C" int rbd_aio_read2(rbd_image_t image, uint64_t off, size_t len, librbd::RBD::AioCompletion *comp = (librbd::RBD::AioCompletion *)c; tracepoint(librbd, aio_read2_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, off, len, buf, comp->pc, op_flags); - ictx->aio_work_queue->aio_read(get_aio_completion(comp), off, len, buf, NULL, - op_flags); + ictx->io_work_queue->aio_read(get_aio_completion(comp), off, len, buf, NULL, + op_flags); tracepoint(librbd, aio_read_exit, 0); return 0; } @@ -2970,7 +2971,7 @@ extern "C" int rbd_aio_flush(rbd_image_t image, rbd_completion_t c) librbd::ImageCtx *ictx = (librbd::ImageCtx *)image; librbd::RBD::AioCompletion *comp = (librbd::RBD::AioCompletion *)c; tracepoint(librbd, aio_flush_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(), ictx->read_only, comp->pc); - ictx->aio_work_queue->aio_flush(get_aio_completion(comp)); + ictx->io_work_queue->aio_flush(get_aio_completion(comp)); tracepoint(librbd, aio_flush_exit, 0); return 0; } @@ -2987,7 +2988,7 @@ extern "C" int rbd_invalidate_cache(rbd_image_t image) extern "C" int rbd_poll_io_events(rbd_image_t image, rbd_completion_t *comps, int numcomp) { librbd::ImageCtx *ictx = (librbd::ImageCtx *)image; - librbd::AioCompletion *cs[numcomp]; + librbd::io::AioCompletion *cs[numcomp]; tracepoint(librbd, poll_io_events_enter, ictx, numcomp); int r = librbd::poll_io_events(ictx, cs, numcomp); tracepoint(librbd, poll_io_events_exit, r); diff --git a/src/librbd/operation/DisableFeaturesRequest.cc b/src/librbd/operation/DisableFeaturesRequest.cc index b7e9bc473c4..504f5305700 100644 --- a/src/librbd/operation/DisableFeaturesRequest.cc +++ b/src/librbd/operation/DisableFeaturesRequest.cc @@ -5,13 +5,13 @@ #include "common/dout.h" #include "common/errno.h" #include "cls/rbd/cls_rbd_client.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageCtx.h" #include "librbd/ImageState.h" #include "librbd/Journal.h" #include "librbd/Utils.h" #include "librbd/image/SetFlagsRequest.h" +#include "librbd/io/ImageRequestWQ.h" #include "librbd/journal/RemoveRequest.h" #include "librbd/mirror/DisableRequest.h" #include "librbd/object_map/RemoveRequest.h" @@ -93,7 +93,7 @@ void DisableFeaturesRequest::send_block_writes() { ldout(cct, 20) << this << " " << __func__ << dendl; RWLock::WLocker locker(image_ctx.owner_lock); - image_ctx.aio_work_queue->block_writes(create_context_callback< + image_ctx.io_work_queue->block_writes(create_context_callback< DisableFeaturesRequest, &DisableFeaturesRequest::handle_block_writes>(this)); } @@ -624,7 +624,7 @@ Context *DisableFeaturesRequest::handle_finish(int r) { image_ctx.exclusive_lock->unblock_requests(); } - image_ctx.aio_work_queue->unblock_writes(); + image_ctx.io_work_queue->unblock_writes(); } image_ctx.state->handle_prepare_lock_complete(); diff --git a/src/librbd/operation/EnableFeaturesRequest.cc b/src/librbd/operation/EnableFeaturesRequest.cc index b1521f8cba7..621357b4802 100644 --- a/src/librbd/operation/EnableFeaturesRequest.cc +++ b/src/librbd/operation/EnableFeaturesRequest.cc @@ -4,13 +4,13 @@ #include "librbd/operation/EnableFeaturesRequest.h" #include "common/dout.h" #include "common/errno.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageCtx.h" #include "librbd/ImageState.h" #include "librbd/Journal.h" #include "librbd/Utils.h" #include "librbd/image/SetFlagsRequest.h" +#include "librbd/io/ImageRequestWQ.h" #include "librbd/journal/CreateRequest.h" #include "librbd/mirror/EnableRequest.h" #include "librbd/object_map/CreateRequest.h" @@ -91,7 +91,7 @@ void EnableFeaturesRequest::send_block_writes() { ldout(cct, 20) << this << " " << __func__ << dendl; RWLock::WLocker locker(image_ctx.owner_lock); - image_ctx.aio_work_queue->block_writes(create_context_callback< + image_ctx.io_work_queue->block_writes(create_context_callback< EnableFeaturesRequest, &EnableFeaturesRequest::handle_block_writes>(this)); } @@ -471,7 +471,7 @@ Context *EnableFeaturesRequest::handle_finish(int r) { image_ctx.exclusive_lock->unblock_requests(); } if (m_writes_blocked) { - image_ctx.aio_work_queue->unblock_writes(); + image_ctx.io_work_queue->unblock_writes(); } } image_ctx.state->handle_prepare_lock_complete(); diff --git a/src/librbd/operation/FlattenRequest.cc b/src/librbd/operation/FlattenRequest.cc index 70d358ab3c0..2cfa1ad1c13 100644 --- a/src/librbd/operation/FlattenRequest.cc +++ b/src/librbd/operation/FlattenRequest.cc @@ -2,10 +2,10 @@ // vim: ts=8 sw=2 smarttab #include "librbd/operation/FlattenRequest.h" -#include "librbd/AioObjectRequest.h" #include "librbd/AsyncObjectThrottle.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageCtx.h" +#include "librbd/io/ObjectRequest.h" #include "common/dout.h" #include "common/errno.h" #include @@ -41,8 +41,8 @@ public: bufferlist bl; string oid = image_ctx.get_object_name(m_object_no); - AioObjectWrite *req = new AioObjectWrite(&image_ctx, oid, m_object_no, 0, - bl, m_snapc, this, 0); + auto req = new io::ObjectWriteRequest(&image_ctx, oid, m_object_no, 0, + bl, m_snapc, this, 0); if (!req->has_parent()) { // stop early if the parent went away - it just means // another flatten finished first or the image was resized diff --git a/src/librbd/operation/ResizeRequest.cc b/src/librbd/operation/ResizeRequest.cc index 078c268defa..2512dd623ef 100644 --- a/src/librbd/operation/ResizeRequest.cc +++ b/src/librbd/operation/ResizeRequest.cc @@ -2,12 +2,12 @@ // vim: ts=8 sw=2 smarttab #include "librbd/operation/ResizeRequest.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageCtx.h" #include "librbd/internal.h" #include "librbd/ObjectMap.h" #include "librbd/Utils.h" +#include "librbd/io/ImageRequestWQ.h" #include "librbd/operation/TrimRequest.h" #include "common/dout.h" #include "common/errno.h" @@ -92,7 +92,7 @@ void ResizeRequest::send_pre_block_writes() { CephContext *cct = image_ctx.cct; ldout(cct, 5) << this << " " << __func__ << dendl; - image_ctx.aio_work_queue->block_writes(create_context_callback< + image_ctx.io_work_queue->block_writes(create_context_callback< ResizeRequest, &ResizeRequest::handle_pre_block_writes>(this)); } @@ -104,7 +104,7 @@ Context *ResizeRequest::handle_pre_block_writes(int *result) { if (*result < 0) { lderr(cct) << "failed to block writes: " << cpp_strerror(*result) << dendl; - image_ctx.aio_work_queue->unblock_writes(); + image_ctx.io_work_queue->unblock_writes(); return this->create_context_finisher(*result); } @@ -140,7 +140,7 @@ Context *ResizeRequest::handle_append_op_event(int *result) { if (*result < 0) { lderr(cct) << "failed to commit journal entry: " << cpp_strerror(*result) << dendl; - image_ctx.aio_work_queue->unblock_writes(); + image_ctx.io_work_queue->unblock_writes(); return this->create_context_finisher(*result); } @@ -252,7 +252,7 @@ Context *ResizeRequest::send_grow_object_map() { RWLock::WLocker snap_locker(image_ctx.snap_lock); m_shrink_size_visible = true; } - image_ctx.aio_work_queue->unblock_writes(); + image_ctx.io_work_queue->unblock_writes(); if (m_original_size == m_new_size) { return this->create_context_finisher(0); @@ -346,7 +346,7 @@ void ResizeRequest::send_post_block_writes() { ldout(cct, 5) << this << " " << __func__ << dendl; RWLock::RLocker owner_locker(image_ctx.owner_lock); - image_ctx.aio_work_queue->block_writes(create_context_callback< + image_ctx.io_work_queue->block_writes(create_context_callback< ResizeRequest, &ResizeRequest::handle_post_block_writes>(this)); } @@ -357,7 +357,7 @@ Context *ResizeRequest::handle_post_block_writes(int *result) { ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl; if (*result < 0) { - image_ctx.aio_work_queue->unblock_writes(); + image_ctx.io_work_queue->unblock_writes(); lderr(cct) << "failed to block writes prior to header update: " << cpp_strerror(*result) << dendl; return this->create_context_finisher(*result); @@ -408,7 +408,7 @@ Context *ResizeRequest::handle_update_header(int *result) { if (*result < 0) { lderr(cct) << "failed to update image header: " << cpp_strerror(*result) << dendl; - image_ctx.aio_work_queue->unblock_writes(); + image_ctx.io_work_queue->unblock_writes(); return this->create_context_finisher(*result); } @@ -440,7 +440,7 @@ void ResizeRequest::update_size_and_overlap() { } // blocked by POST_BLOCK_WRITES state - image_ctx.aio_work_queue->unblock_writes(); + image_ctx.io_work_queue->unblock_writes(); } } // namespace operation diff --git a/src/librbd/operation/SnapshotCreateRequest.cc b/src/librbd/operation/SnapshotCreateRequest.cc index ce816bb71cf..afec2896bb8 100644 --- a/src/librbd/operation/SnapshotCreateRequest.cc +++ b/src/librbd/operation/SnapshotCreateRequest.cc @@ -5,11 +5,11 @@ #include "librbd/operation/SnapshotCreateRequest.h" #include "common/dout.h" #include "common/errno.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageCtx.h" #include "librbd/ObjectMap.h" #include "librbd/Utils.h" +#include "librbd/io/ImageRequestWQ.h" #define dout_subsys ceph_subsys_rbd #undef dout_prefix @@ -68,7 +68,7 @@ void SnapshotCreateRequest::send_suspend_aio() { CephContext *cct = image_ctx.cct; ldout(cct, 5) << this << " " << __func__ << dendl; - image_ctx.aio_work_queue->block_writes(create_context_callback< + image_ctx.io_work_queue->block_writes(create_context_callback< SnapshotCreateRequest, &SnapshotCreateRequest::handle_suspend_aio>(this)); } @@ -81,7 +81,7 @@ Context *SnapshotCreateRequest::handle_suspend_aio(int *result) { if (*result < 0) { lderr(cct) << "failed to block writes: " << cpp_strerror(*result) << dendl; - image_ctx.aio_work_queue->unblock_writes(); + image_ctx.io_work_queue->unblock_writes(); return this->create_context_finisher(*result); } @@ -110,7 +110,7 @@ Context *SnapshotCreateRequest::handle_append_op_event(int *result) { ldout(cct, 5) << this << " " << __func__ << ": r=" << *result << dendl; if (*result < 0) { - image_ctx.aio_work_queue->unblock_writes(); + image_ctx.io_work_queue->unblock_writes(); lderr(cct) << "failed to commit journal entry: " << cpp_strerror(*result) << dendl; return this->create_context_finisher(*result); @@ -142,7 +142,7 @@ Context *SnapshotCreateRequest::handle_allocate_snap_id(int *result) { if (*result < 0) { save_result(result); - image_ctx.aio_work_queue->unblock_writes(); + image_ctx.io_work_queue->unblock_writes(); lderr(cct) << "failed to allocate snapshot id: " << cpp_strerror(*result) << dendl; return this->create_context_finisher(*result); @@ -214,7 +214,7 @@ Context *SnapshotCreateRequest::send_create_object_map() { if (image_ctx.object_map == nullptr || m_skip_object_map) { image_ctx.snap_lock.put_read(); - image_ctx.aio_work_queue->unblock_writes(); + image_ctx.io_work_queue->unblock_writes(); return this->create_context_finisher(0); } @@ -240,7 +240,7 @@ Context *SnapshotCreateRequest::handle_create_object_map(int *result) { assert(*result == 0); - image_ctx.aio_work_queue->unblock_writes(); + image_ctx.io_work_queue->unblock_writes(); return this->create_context_finisher(0); } @@ -268,7 +268,7 @@ Context *SnapshotCreateRequest::handle_release_snap_id(int *result) { assert(m_ret_val < 0); *result = m_ret_val; - image_ctx.aio_work_queue->unblock_writes(); + image_ctx.io_work_queue->unblock_writes(); return this->create_context_finisher(m_ret_val); } diff --git a/src/librbd/operation/SnapshotRollbackRequest.cc b/src/librbd/operation/SnapshotRollbackRequest.cc index a12edfd4e10..492b74c426a 100644 --- a/src/librbd/operation/SnapshotRollbackRequest.cc +++ b/src/librbd/operation/SnapshotRollbackRequest.cc @@ -5,11 +5,11 @@ #include "include/rados/librados.hpp" #include "common/dout.h" #include "common/errno.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/AsyncObjectThrottle.h" #include "librbd/ImageCtx.h" #include "librbd/ObjectMap.h" #include "librbd/Utils.h" +#include "librbd/io/ImageRequestWQ.h" #include "librbd/operation/ResizeRequest.h" #include "osdc/Striper.h" #include @@ -77,7 +77,7 @@ template SnapshotRollbackRequest::~SnapshotRollbackRequest() { I &image_ctx = this->m_image_ctx; if (m_blocking_writes) { - image_ctx.aio_work_queue->unblock_writes(); + image_ctx.io_work_queue->unblock_writes(); } delete m_object_map; } @@ -94,7 +94,7 @@ void SnapshotRollbackRequest::send_block_writes() { ldout(cct, 5) << this << " " << __func__ << dendl; m_blocking_writes = true; - image_ctx.aio_work_queue->block_writes(create_context_callback< + image_ctx.io_work_queue->block_writes(create_context_callback< SnapshotRollbackRequest, &SnapshotRollbackRequest::handle_block_writes>(this)); } diff --git a/src/librbd/operation/TrimRequest.cc b/src/librbd/operation/TrimRequest.cc index b3a30883e16..972c6aaf62d 100644 --- a/src/librbd/operation/TrimRequest.cc +++ b/src/librbd/operation/TrimRequest.cc @@ -3,12 +3,12 @@ #include "librbd/operation/TrimRequest.h" #include "librbd/AsyncObjectThrottle.h" -#include "librbd/AioObjectRequest.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageCtx.h" #include "librbd/internal.h" #include "librbd/ObjectMap.h" #include "librbd/Utils.h" +#include "librbd/io/ObjectRequest.h" #include "common/ContextCompletion.h" #include "common/dout.h" #include "common/errno.h" @@ -45,8 +45,8 @@ public: string oid = image_ctx.get_object_name(m_object_no); ldout(image_ctx.cct, 10) << "removing (with copyup) " << oid << dendl; - AioObjectRequest<> *req = new AioObjectTrim(&image_ctx, oid, m_object_no, - m_snapc, this, false); + auto req = new io::ObjectTrimRequest(&image_ctx, oid, m_object_no, + m_snapc, this, false); req->send(); return 0; } @@ -413,13 +413,13 @@ void TrimRequest::send_clean_boundary() { ldout(cct, 20) << " ex " << *p << dendl; Context *req_comp = new C_ContextCompletion(*completion); - AioObjectRequest<> *req; + io::ObjectRequest<> *req; if (p->offset == 0) { - req = new AioObjectTrim(&image_ctx, p->oid.name, p->objectno, snapc, - req_comp, true); + req = new io::ObjectTrimRequest(&image_ctx, p->oid.name, p->objectno, + snapc, req_comp, true); } else { - req = new AioObjectTruncate(&image_ctx, p->oid.name, p->objectno, - p->offset, snapc, req_comp); + req = new io::ObjectTruncateRequest(&image_ctx, p->oid.name, p->objectno, + p->offset, snapc, req_comp); } req->send(); } diff --git a/src/test/librbd/CMakeLists.txt b/src/test/librbd/CMakeLists.txt index 3d946fdc194..105d98be9da 100644 --- a/src/test/librbd/CMakeLists.txt +++ b/src/test/librbd/CMakeLists.txt @@ -24,10 +24,9 @@ set_target_properties(rbd_test_mock PROPERTIES COMPILE_FLAGS # doesn't use add_ceph_test because it is called by run-rbd-unit-tests.sh set(unittest_librbd_srcs test_BlockGuard.cc - test_ConsistencyGroups.cc + test_Groups.cc test_main.cc test_mock_fixture.cc - test_mock_AioImageRequest.cc test_mock_ExclusiveLock.cc test_mock_Journal.cc test_mock_ManagedLock.cc @@ -36,6 +35,7 @@ set(unittest_librbd_srcs exclusive_lock/test_mock_PostAcquireRequest.cc exclusive_lock/test_mock_PreReleaseRequest.cc image/test_mock_RefreshRequest.cc + io/test_mock_ImageRequest.cc journal/test_mock_OpenRequest.cc journal/test_mock_PromoteRequest.cc journal/test_mock_Replay.cc diff --git a/src/test/librbd/exclusive_lock/test_mock_PreReleaseRequest.cc b/src/test/librbd/exclusive_lock/test_mock_PreReleaseRequest.cc index a2fda18bf20..72249d186c3 100644 --- a/src/test/librbd/exclusive_lock/test_mock_PreReleaseRequest.cc +++ b/src/test/librbd/exclusive_lock/test_mock_PreReleaseRequest.cc @@ -53,7 +53,7 @@ public: } void expect_set_require_lock_on_read(MockImageCtx &mock_image_ctx) { - EXPECT_CALL(*mock_image_ctx.aio_work_queue, set_require_lock_on_read()); + EXPECT_CALL(*mock_image_ctx.io_work_queue, set_require_lock_on_read()); } void expect_block_writes(MockImageCtx &mock_image_ctx, int r) { @@ -62,12 +62,12 @@ public: if ((mock_image_ctx.features & RBD_FEATURE_JOURNALING) != 0) { expect_set_require_lock_on_read(mock_image_ctx); } - EXPECT_CALL(*mock_image_ctx.aio_work_queue, block_writes(_)) + EXPECT_CALL(*mock_image_ctx.io_work_queue, block_writes(_)) .WillOnce(CompleteContext(r, mock_image_ctx.image_ctx->op_work_queue)); } void expect_unblock_writes(MockImageCtx &mock_image_ctx) { - EXPECT_CALL(*mock_image_ctx.aio_work_queue, unblock_writes()); + EXPECT_CALL(*mock_image_ctx.io_work_queue, unblock_writes()); } void expect_cancel_op_requests(MockImageCtx &mock_image_ctx, int r) { diff --git a/src/test/librbd/image/test_mock_RefreshRequest.cc b/src/test/librbd/image/test_mock_RefreshRequest.cc index e9c20434def..59932f2f850 100644 --- a/src/test/librbd/image/test_mock_RefreshRequest.cc +++ b/src/test/librbd/image/test_mock_RefreshRequest.cc @@ -98,11 +98,11 @@ public: typedef RefreshParentRequest MockRefreshParentRequest; void expect_set_require_lock_on_read(MockRefreshImageCtx &mock_image_ctx) { - EXPECT_CALL(*mock_image_ctx.aio_work_queue, set_require_lock_on_read()); + EXPECT_CALL(*mock_image_ctx.io_work_queue, set_require_lock_on_read()); } void expect_clear_require_lock_on_read(MockRefreshImageCtx &mock_image_ctx) { - EXPECT_CALL(*mock_image_ctx.aio_work_queue, clear_require_lock_on_read()); + EXPECT_CALL(*mock_image_ctx.io_work_queue, clear_require_lock_on_read()); } void expect_v1_read_header(MockRefreshImageCtx &mock_image_ctx, int r) { @@ -325,12 +325,12 @@ public: } void expect_block_writes(MockImageCtx &mock_image_ctx, int r) { - EXPECT_CALL(*mock_image_ctx.aio_work_queue, block_writes(_)) + EXPECT_CALL(*mock_image_ctx.io_work_queue, block_writes(_)) .WillOnce(CompleteContext(r, mock_image_ctx.image_ctx->op_work_queue)); } void expect_unblock_writes(MockImageCtx &mock_image_ctx) { - EXPECT_CALL(*mock_image_ctx.aio_work_queue, unblock_writes()) + EXPECT_CALL(*mock_image_ctx.io_work_queue, unblock_writes()) .Times(1); } diff --git a/src/test/librbd/test_mock_AioImageRequest.cc b/src/test/librbd/io/test_mock_ImageRequest.cc similarity index 61% rename from src/test/librbd/test_mock_AioImageRequest.cc rename to src/test/librbd/io/test_mock_ImageRequest.cc index aafe2b62d96..55dd7549c0f 100644 --- a/src/test/librbd/test_mock_AioImageRequest.cc +++ b/src/test/librbd/io/test_mock_ImageRequest.cc @@ -6,8 +6,8 @@ #include "test/librbd/mock/MockImageCtx.h" #include "test/librbd/mock/MockJournal.h" #include "test/librbd/mock/cache/MockImageCache.h" -#include "librbd/AioImageRequest.h" -#include "librbd/AioObjectRequest.h" +#include "librbd/io/ImageRequest.h" +#include "librbd/io/ObjectRequest.h" namespace librbd { namespace { @@ -27,60 +27,62 @@ inline ImageCtx *get_image_ctx(MockTestImageCtx *image_ctx) { } // namespace util +namespace io { + template <> -struct AioObjectRequest : public AioObjectRequestHandle { - static AioObjectRequest* s_instance; +struct ObjectRequest : public ObjectRequestHandle { + static ObjectRequest* s_instance; Context *on_finish = nullptr; - static AioObjectRequest* create_remove(librbd::MockTestImageCtx *ictx, - const std::string &oid, - uint64_t object_no, - const ::SnapContext &snapc, - Context *completion) { + static ObjectRequest* create_remove(librbd::MockTestImageCtx *ictx, + const std::string &oid, + uint64_t object_no, + const ::SnapContext &snapc, + Context *completion) { assert(s_instance != nullptr); s_instance->on_finish = completion; return s_instance; } - static AioObjectRequest* create_truncate(librbd::MockTestImageCtx *ictx, - const std::string &oid, - uint64_t object_no, - uint64_t object_off, - const ::SnapContext &snapc, - Context *completion) { + static ObjectRequest* create_truncate(librbd::MockTestImageCtx *ictx, + const std::string &oid, + uint64_t object_no, + uint64_t object_off, + const ::SnapContext &snapc, + Context *completion) { assert(s_instance != nullptr); s_instance->on_finish = completion; return s_instance; } - static AioObjectRequest* create_write(librbd::MockTestImageCtx *ictx, - const std::string &oid, - uint64_t object_no, - uint64_t object_off, - const ceph::bufferlist &data, - const ::SnapContext &snapc, - Context *completion, int op_flags) { + static ObjectRequest* create_write(librbd::MockTestImageCtx *ictx, + const std::string &oid, + uint64_t object_no, + uint64_t object_off, + const ceph::bufferlist &data, + const ::SnapContext &snapc, + Context *completion, int op_flags) { assert(s_instance != nullptr); s_instance->on_finish = completion; return s_instance; } - static AioObjectRequest* create_zero(librbd::MockTestImageCtx *ictx, - const std::string &oid, - uint64_t object_no, uint64_t object_off, - uint64_t object_len, - const ::SnapContext &snapc, - Context *completion) { + static ObjectRequest* create_zero(librbd::MockTestImageCtx *ictx, + const std::string &oid, + uint64_t object_no, uint64_t object_off, + uint64_t object_len, + const ::SnapContext &snapc, + Context *completion) { assert(s_instance != nullptr); s_instance->on_finish = completion; return s_instance; } - AioObjectRequest() { + ObjectRequest() { assert(s_instance == nullptr); s_instance = this; } - ~AioObjectRequest() { + ~ObjectRequest() { s_instance = nullptr; } @@ -89,28 +91,28 @@ struct AioObjectRequest : public AioObjectRequestHandl }; template <> -struct AioObjectRead : public AioObjectRequest { +struct ObjectReadRequest : public ObjectRequest { typedef std::vector > Extents; typedef std::map ExtentMap; - static AioObjectRead* s_instance; + static ObjectReadRequest* s_instance; - static AioObjectRead* create(librbd::MockTestImageCtx *ictx, - const std::string &oid, - uint64_t objectno, uint64_t offset, - uint64_t len, Extents &buffer_extents, - librados::snap_t snap_id, bool sparse, - Context *completion, int op_flags) { + static ObjectReadRequest* create(librbd::MockTestImageCtx *ictx, + const std::string &oid, + uint64_t objectno, uint64_t offset, + uint64_t len, Extents &buffer_extents, + librados::snap_t snap_id, bool sparse, + Context *completion, int op_flags) { assert(s_instance != nullptr); s_instance->on_finish = completion; return s_instance; } - AioObjectRead() { + ObjectReadRequest() { assert(s_instance == nullptr); s_instance = this; } - ~AioObjectRead() { + ~ObjectReadRequest() { s_instance = nullptr; } @@ -122,14 +124,16 @@ struct AioObjectRead : public AioObjectRequest* AioObjectRequest::s_instance = nullptr; -AioObjectRead* AioObjectRead::s_instance = nullptr; +ObjectRequest* ObjectRequest::s_instance = nullptr; +ObjectReadRequest* ObjectReadRequest::s_instance = nullptr; +} // namespace io } // namespace librbd -#include "librbd/AioImageRequest.cc" +#include "librbd/io/ImageRequest.cc" namespace librbd { +namespace io { using ::testing::_; using ::testing::InSequence; @@ -137,13 +141,13 @@ using ::testing::Invoke; using ::testing::Return; using ::testing::WithArg; -struct TestMockAioImageRequest : public TestMockFixture { - typedef AioImageRequest MockAioImageRequest; - typedef AioImageWrite MockAioImageWrite; - typedef AioImageDiscard MockAioImageDiscard; - typedef AioImageFlush MockAioImageFlush; - typedef AioObjectRequest MockAioObjectRequest; - typedef AioObjectRead MockAioObjectRead; +struct TestMockIoImageRequest : public TestMockFixture { + typedef ImageRequest MockImageRequest; + typedef ImageWriteRequest MockImageWriteRequest; + typedef ImageDiscardRequest MockImageDiscardRequest; + typedef ImageFlushRequest MockImageFlushRequest; + typedef ObjectRequest MockObjectRequest; + typedef ObjectReadRequest MockObjectReadRequest; void expect_is_journal_appending(MockJournal &mock_journal, bool appending) { EXPECT_CALL(mock_journal, is_journal_appending()) @@ -160,7 +164,7 @@ struct TestMockAioImageRequest : public TestMockFixture { } void expect_object_request_send(MockImageCtx &mock_image_ctx, - MockAioObjectRequest &mock_object_request, + MockObjectRequest &mock_object_request, int r) { EXPECT_CALL(mock_object_request, send()) .WillOnce(Invoke([&mock_image_ctx, &mock_object_request, r]() { @@ -179,13 +183,13 @@ struct TestMockAioImageRequest : public TestMockFixture { } }; -TEST_F(TestMockAioImageRequest, AioWriteJournalAppendDisabled) { +TEST_F(TestMockIoImageRequest, AioWriteJournalAppendDisabled) { REQUIRE_FEATURE(RBD_FEATURE_JOURNALING); librbd::ImageCtx *ictx; ASSERT_EQ(0, open_image(m_image_name, &ictx)); - MockAioObjectRequest mock_aio_object_request; + MockObjectRequest mock_aio_object_request; MockTestImageCtx mock_image_ctx(*ictx); MockJournal mock_journal; mock_image_ctx.journal = &mock_journal; @@ -198,7 +202,7 @@ TEST_F(TestMockAioImageRequest, AioWriteJournalAppendDisabled) { C_SaferCond aio_comp_ctx; AioCompletion *aio_comp = AioCompletion::create_and_start( &aio_comp_ctx, ictx, AIO_TYPE_WRITE); - MockAioImageWrite mock_aio_image_write(mock_image_ctx, aio_comp, 0, 1, "1", + MockImageWriteRequest mock_aio_image_write(mock_image_ctx, aio_comp, 0, 1, "1", 0); { RWLock::RLocker owner_locker(mock_image_ctx.owner_lock); @@ -207,13 +211,13 @@ TEST_F(TestMockAioImageRequest, AioWriteJournalAppendDisabled) { ASSERT_EQ(0, aio_comp_ctx.wait()); } -TEST_F(TestMockAioImageRequest, AioDiscardJournalAppendDisabled) { +TEST_F(TestMockIoImageRequest, AioDiscardJournalAppendDisabled) { REQUIRE_FEATURE(RBD_FEATURE_JOURNALING); librbd::ImageCtx *ictx; ASSERT_EQ(0, open_image(m_image_name, &ictx)); - MockAioObjectRequest mock_aio_object_request; + MockObjectRequest mock_aio_object_request; MockTestImageCtx mock_image_ctx(*ictx); MockJournal mock_journal; mock_image_ctx.journal = &mock_journal; @@ -225,7 +229,7 @@ TEST_F(TestMockAioImageRequest, AioDiscardJournalAppendDisabled) { C_SaferCond aio_comp_ctx; AioCompletion *aio_comp = AioCompletion::create_and_start( &aio_comp_ctx, ictx, AIO_TYPE_DISCARD); - MockAioImageDiscard mock_aio_image_discard(mock_image_ctx, aio_comp, 0, 1); + MockImageDiscardRequest mock_aio_image_discard(mock_image_ctx, aio_comp, 0, 1); { RWLock::RLocker owner_locker(mock_image_ctx.owner_lock); mock_aio_image_discard.send(); @@ -233,7 +237,7 @@ TEST_F(TestMockAioImageRequest, AioDiscardJournalAppendDisabled) { ASSERT_EQ(0, aio_comp_ctx.wait()); } -TEST_F(TestMockAioImageRequest, AioFlushJournalAppendDisabled) { +TEST_F(TestMockIoImageRequest, AioFlushJournalAppendDisabled) { REQUIRE_FEATURE(RBD_FEATURE_JOURNALING); librbd::ImageCtx *ictx; @@ -251,7 +255,7 @@ TEST_F(TestMockAioImageRequest, AioFlushJournalAppendDisabled) { C_SaferCond aio_comp_ctx; AioCompletion *aio_comp = AioCompletion::create_and_start( &aio_comp_ctx, ictx, AIO_TYPE_FLUSH); - MockAioImageFlush mock_aio_image_flush(mock_image_ctx, aio_comp); + MockImageFlushRequest mock_aio_image_flush(mock_image_ctx, aio_comp); { RWLock::RLocker owner_locker(mock_image_ctx.owner_lock); mock_aio_image_flush.send(); @@ -259,4 +263,5 @@ TEST_F(TestMockAioImageRequest, AioFlushJournalAppendDisabled) { ASSERT_EQ(0, aio_comp_ctx.wait()); } +} // namespace io } // namespace librbd diff --git a/src/test/librbd/journal/test_Entries.cc b/src/test/librbd/journal/test_Entries.cc index 21fd17c594c..8506a6f7e4e 100644 --- a/src/test/librbd/journal/test_Entries.cc +++ b/src/test/librbd/journal/test_Entries.cc @@ -3,10 +3,10 @@ #include "test/librbd/test_fixture.h" #include "test/librbd/test_support.h" -#include "librbd/AioCompletion.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/internal.h" #include "librbd/Journal.h" +#include "librbd/io/AioCompletion.h" +#include "librbd/io/ImageRequestWQ.h" #include "librbd/journal/Types.h" #include "journal/Journaler.h" #include "journal/ReplayEntry.h" @@ -127,9 +127,9 @@ TEST_F(TestJournalEntries, AioWrite) { std::string buffer(512, '1'); C_SaferCond cond_ctx; - librbd::AioCompletion *c = librbd::AioCompletion::create(&cond_ctx); + auto c = librbd::io::AioCompletion::create(&cond_ctx); c->get(); - ictx->aio_work_queue->aio_write(c, 123, buffer.size(), buffer.c_str(), 0); + ictx->io_work_queue->aio_write(c, 123, buffer.size(), buffer.c_str(), 0); ASSERT_EQ(0, c->wait_for_complete()); c->put(); @@ -170,9 +170,9 @@ TEST_F(TestJournalEntries, AioDiscard) { ASSERT_TRUE(journaler != NULL); C_SaferCond cond_ctx; - librbd::AioCompletion *c = librbd::AioCompletion::create(&cond_ctx); + auto c = librbd::io::AioCompletion::create(&cond_ctx); c->get(); - ictx->aio_work_queue->aio_discard(c, 123, 234); + ictx->io_work_queue->aio_discard(c, 123, 234); ASSERT_EQ(0, c->wait_for_complete()); c->put(); @@ -203,9 +203,9 @@ TEST_F(TestJournalEntries, AioFlush) { ASSERT_TRUE(journaler != NULL); C_SaferCond cond_ctx; - librbd::AioCompletion *c = librbd::AioCompletion::create(&cond_ctx); + auto c = librbd::io::AioCompletion::create(&cond_ctx); c->get(); - ictx->aio_work_queue->aio_flush(c); + ictx->io_work_queue->aio_flush(c); ASSERT_EQ(0, c->wait_for_complete()); c->put(); diff --git a/src/test/librbd/journal/test_Replay.cc b/src/test/librbd/journal/test_Replay.cc index 23a99ef07b3..e2d4425f7b8 100644 --- a/src/test/librbd/journal/test_Replay.cc +++ b/src/test/librbd/journal/test_Replay.cc @@ -8,9 +8,6 @@ #include "cls/journal/cls_journal_types.h" #include "cls/journal/cls_journal_client.h" #include "journal/Journaler.h" -#include "librbd/AioCompletion.h" -#include "librbd/AioImageRequest.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageCtx.h" #include "librbd/ImageState.h" @@ -18,6 +15,9 @@ #include "librbd/internal.h" #include "librbd/Journal.h" #include "librbd/Operations.h" +#include "librbd/io/AioCompletion.h" +#include "librbd/io/ImageRequest.h" +#include "librbd/io/ImageRequestWQ.h" #include "librbd/journal/Types.h" void register_test_journal_replay() { @@ -46,7 +46,7 @@ public: void inject_into_journal(librbd::ImageCtx *ictx, T event) { C_SaferCond ctx; librbd::journal::EventEntry event_entry(event); - librbd::Journal<>::AioObjectRequests requests; + librbd::Journal<>::IOObjectRequests requests; { RWLock::RLocker owner_locker(ictx->owner_lock); uint64_t tid = ictx->journal->append_io_event(std::move(event_entry), @@ -109,21 +109,21 @@ TEST_F(TestJournalReplay, AioDiscardEvent) { ictx->features &= ~RBD_FEATURE_JOURNALING; std::string payload(4096, '1'); - librbd::AioCompletion *aio_comp = new librbd::AioCompletion(); - ictx->aio_work_queue->aio_write(aio_comp, 0, payload.size(), payload.c_str(), - 0); + auto aio_comp = new librbd::io::AioCompletion(); + ictx->io_work_queue->aio_write(aio_comp, 0, payload.size(), payload.c_str(), + 0); ASSERT_EQ(0, aio_comp->wait_for_complete()); aio_comp->release(); - aio_comp = new librbd::AioCompletion(); - ictx->aio_work_queue->aio_flush(aio_comp); + aio_comp = new librbd::io::AioCompletion(); + ictx->io_work_queue->aio_flush(aio_comp); ASSERT_EQ(0, aio_comp->wait_for_complete()); aio_comp->release(); std::string read_payload(4096, '\0'); - aio_comp = new librbd::AioCompletion(); - ictx->aio_work_queue->aio_read(aio_comp, 0, read_payload.size(), - &read_payload[0], NULL, 0); + aio_comp = new librbd::io::AioCompletion(); + ictx->io_work_queue->aio_read(aio_comp, 0, read_payload.size(), + &read_payload[0], NULL, 0); ASSERT_EQ(0, aio_comp->wait_for_complete()); aio_comp->release(); ASSERT_EQ(payload, read_payload); @@ -146,9 +146,9 @@ TEST_F(TestJournalReplay, AioDiscardEvent) { ASSERT_EQ(0, open_image(m_image_name, &ictx)); ASSERT_EQ(0, when_acquired_lock(ictx)); - aio_comp = new librbd::AioCompletion(); - ictx->aio_work_queue->aio_read(aio_comp, 0, read_payload.size(), - &read_payload[0], NULL, 0); + aio_comp = new librbd::io::AioCompletion(); + ictx->io_work_queue->aio_read(aio_comp, 0, read_payload.size(), + &read_payload[0], NULL, 0); ASSERT_EQ(0, aio_comp->wait_for_complete()); aio_comp->release(); if (ictx->cct->_conf->rbd_skip_partial_discard) { @@ -178,8 +178,8 @@ TEST_F(TestJournalReplay, AioDiscardEvent) { ASSERT_EQ(1, current_entry); // verify lock ordering constraints - aio_comp = new librbd::AioCompletion(); - ictx->aio_work_queue->aio_discard(aio_comp, 0, read_payload.size()); + aio_comp = new librbd::io::AioCompletion(); + ictx->io_work_queue->aio_discard(aio_comp, 0, read_payload.size()); ASSERT_EQ(0, aio_comp->wait_for_complete()); aio_comp->release(); } @@ -209,9 +209,9 @@ TEST_F(TestJournalReplay, AioWriteEvent) { ASSERT_EQ(0, when_acquired_lock(ictx)); std::string read_payload(4096, '\0'); - librbd::AioCompletion *aio_comp = new librbd::AioCompletion(); - ictx->aio_work_queue->aio_read(aio_comp, 0, read_payload.size(), - &read_payload[0], NULL, 0); + auto aio_comp = new librbd::io::AioCompletion(); + ictx->io_work_queue->aio_read(aio_comp, 0, read_payload.size(), + &read_payload[0], NULL, 0); ASSERT_EQ(0, aio_comp->wait_for_complete()); aio_comp->release(); ASSERT_EQ(payload, read_payload); @@ -237,9 +237,9 @@ TEST_F(TestJournalReplay, AioWriteEvent) { ASSERT_EQ(1, current_entry); // verify lock ordering constraints - aio_comp = new librbd::AioCompletion(); - ictx->aio_work_queue->aio_write(aio_comp, 0, payload.size(), payload.c_str(), - 0); + aio_comp = new librbd::io::AioCompletion(); + ictx->io_work_queue->aio_write(aio_comp, 0, payload.size(), payload.c_str(), + 0); ASSERT_EQ(0, aio_comp->wait_for_complete()); aio_comp->release(); } @@ -284,8 +284,8 @@ TEST_F(TestJournalReplay, AioFlushEvent) { ASSERT_EQ(1, current_entry); // verify lock ordering constraints - librbd::AioCompletion *aio_comp = new librbd::AioCompletion(); - ictx->aio_work_queue->aio_flush(aio_comp); + auto aio_comp = new librbd::io::AioCompletion(); + ictx->io_work_queue->aio_flush(aio_comp); ASSERT_EQ(0, aio_comp->wait_for_complete()); aio_comp->release(); } @@ -782,14 +782,14 @@ TEST_F(TestJournalReplay, ObjectPosition) { get_journal_commit_position(ictx, &initial_tag, &initial_entry); std::string payload(4096, '1'); - librbd::AioCompletion *aio_comp = new librbd::AioCompletion(); - ictx->aio_work_queue->aio_write(aio_comp, 0, payload.size(), payload.c_str(), - 0); + auto aio_comp = new librbd::io::AioCompletion(); + ictx->io_work_queue->aio_write(aio_comp, 0, payload.size(), payload.c_str(), + 0); ASSERT_EQ(0, aio_comp->wait_for_complete()); aio_comp->release(); - aio_comp = new librbd::AioCompletion(); - ictx->aio_work_queue->aio_flush(aio_comp); + aio_comp = new librbd::io::AioCompletion(); + ictx->io_work_queue->aio_flush(aio_comp); ASSERT_EQ(0, aio_comp->wait_for_complete()); aio_comp->release(); @@ -802,14 +802,14 @@ TEST_F(TestJournalReplay, ObjectPosition) { // write again - aio_comp = new librbd::AioCompletion(); - ictx->aio_work_queue->aio_write(aio_comp, 0, payload.size(), payload.c_str(), - 0); + aio_comp = new librbd::io::AioCompletion(); + ictx->io_work_queue->aio_write(aio_comp, 0, payload.size(), payload.c_str(), + 0); ASSERT_EQ(0, aio_comp->wait_for_complete()); aio_comp->release(); - aio_comp = new librbd::AioCompletion(); - ictx->aio_work_queue->aio_flush(aio_comp); + aio_comp = new librbd::io::AioCompletion(); + ictx->io_work_queue->aio_flush(aio_comp); ASSERT_EQ(0, aio_comp->wait_for_complete()); aio_comp->release(); diff --git a/src/test/librbd/journal/test_mock_Replay.cc b/src/test/librbd/journal/test_mock_Replay.cc index 6f26ccc8f87..a3847e3a69e 100644 --- a/src/test/librbd/journal/test_mock_Replay.cc +++ b/src/test/librbd/journal/test_mock_Replay.cc @@ -4,7 +4,7 @@ #include "test/librbd/test_mock_fixture.h" #include "test/librbd/test_support.h" #include "test/librbd/mock/MockImageCtx.h" -#include "librbd/AioImageRequest.h" +#include "librbd/io/ImageRequest.h" #include "librbd/journal/Replay.h" #include "librbd/journal/Types.h" #include "gmock/gmock.h" @@ -22,14 +22,17 @@ struct MockReplayImageCtx : public MockImageCtx { } // anonymous namespace +namespace io { + template <> -struct AioImageRequest { - static AioImageRequest *s_instance; +struct ImageRequest { + static ImageRequest *s_instance; MOCK_METHOD5(aio_write, void(AioCompletion *c, uint64_t off, size_t len, const char *buf, int op_flags)); - static void aio_write(MockReplayImageCtx *ictx, AioCompletion *c, uint64_t off, - size_t len, const char *buf, int op_flags) { + static void aio_write(MockReplayImageCtx *ictx, AioCompletion *c, + uint64_t off, size_t len, const char *buf, + int op_flags) { assert(s_instance != nullptr); s_instance->aio_write(c, off, len, buf, op_flags); } @@ -47,12 +50,14 @@ struct AioImageRequest { s_instance->aio_flush(c); } - AioImageRequest() { + ImageRequest() { s_instance = this; } }; -AioImageRequest *AioImageRequest::s_instance = nullptr; +ImageRequest *ImageRequest::s_instance = nullptr; + +} // namespace io namespace util { @@ -88,7 +93,7 @@ ACTION_P2(NotifyInvoke, lock, cond) { ACTION_P2(CompleteAioCompletion, r, image_ctx) { image_ctx->op_work_queue->queue(new FunctionContext([this, arg0](int r) { arg0->get(); - arg0->init_time(image_ctx, librbd::AIO_TYPE_NONE); + arg0->init_time(image_ctx, librbd::io::AIO_TYPE_NONE); arg0->set_request_count(1); arg0->complete_request(r); }), r); @@ -99,35 +104,35 @@ namespace journal { class TestMockJournalReplay : public TestMockFixture { public: - typedef AioImageRequest MockAioImageRequest; + typedef io::ImageRequest MockIoImageRequest; typedef Replay MockJournalReplay; TestMockJournalReplay() : m_invoke_lock("m_invoke_lock") { } - void expect_aio_discard(MockAioImageRequest &mock_aio_image_request, - AioCompletion **aio_comp, uint64_t off, + void expect_aio_discard(MockIoImageRequest &mock_io_image_request, + io::AioCompletion **aio_comp, uint64_t off, uint64_t len) { - EXPECT_CALL(mock_aio_image_request, aio_discard(_, off, len)) + EXPECT_CALL(mock_io_image_request, aio_discard(_, off, len)) .WillOnce(SaveArg<0>(aio_comp)); } - void expect_aio_flush(MockAioImageRequest &mock_aio_image_request, - AioCompletion **aio_comp) { - EXPECT_CALL(mock_aio_image_request, aio_flush(_)) + void expect_aio_flush(MockIoImageRequest &mock_io_image_request, + io::AioCompletion **aio_comp) { + EXPECT_CALL(mock_io_image_request, aio_flush(_)) .WillOnce(SaveArg<0>(aio_comp)); } void expect_aio_flush(MockReplayImageCtx &mock_image_ctx, - MockAioImageRequest &mock_aio_image_request, int r) { - EXPECT_CALL(mock_aio_image_request, aio_flush(_)) + MockIoImageRequest &mock_io_image_request, int r) { + EXPECT_CALL(mock_io_image_request, aio_flush(_)) .WillOnce(CompleteAioCompletion(r, mock_image_ctx.image_ctx)); } - void expect_aio_write(MockAioImageRequest &mock_aio_image_request, - AioCompletion **aio_comp, uint64_t off, + void expect_aio_write(MockIoImageRequest &mock_io_image_request, + io::AioCompletion **aio_comp, uint64_t off, uint64_t len, const char *data) { - EXPECT_CALL(mock_aio_image_request, + EXPECT_CALL(mock_io_image_request, aio_write(_, off, len, CStrEq(data), _)) .WillOnce(SaveArg<0>(aio_comp)); } @@ -250,10 +255,10 @@ public: mock_journal_replay.process(event_entry, on_ready, on_safe); } - void when_complete(MockReplayImageCtx &mock_image_ctx, AioCompletion *aio_comp, - int r) { + void when_complete(MockReplayImageCtx &mock_image_ctx, + io::AioCompletion *aio_comp, int r) { aio_comp->get(); - aio_comp->init_time(mock_image_ctx.image_ctx, librbd::AIO_TYPE_NONE); + aio_comp->init_time(mock_image_ctx.image_ctx, librbd::io::AIO_TYPE_NONE); aio_comp->set_request_count(1); aio_comp->complete_request(r); } @@ -303,14 +308,14 @@ TEST_F(TestMockJournalReplay, AioDiscard) { MockReplayImageCtx mock_image_ctx(*ictx); MockJournalReplay mock_journal_replay(mock_image_ctx); - MockAioImageRequest mock_aio_image_request; + MockIoImageRequest mock_io_image_request; expect_op_work_queue(mock_image_ctx); InSequence seq; - AioCompletion *aio_comp; + io::AioCompletion *aio_comp; C_SaferCond on_ready; C_SaferCond on_safe; - expect_aio_discard(mock_aio_image_request, &aio_comp, 123, 456); + expect_aio_discard(mock_io_image_request, &aio_comp, 123, 456); when_process(mock_journal_replay, EventEntry{AioDiscardEvent(123, 456)}, &on_ready, &on_safe); @@ -318,7 +323,7 @@ TEST_F(TestMockJournalReplay, AioDiscard) { when_complete(mock_image_ctx, aio_comp, 0); ASSERT_EQ(0, on_ready.wait()); - expect_aio_flush(mock_image_ctx, mock_aio_image_request, 0); + expect_aio_flush(mock_image_ctx, mock_io_image_request, 0); ASSERT_EQ(0, when_shut_down(mock_journal_replay, false)); ASSERT_EQ(0, on_safe.wait()); } @@ -331,14 +336,14 @@ TEST_F(TestMockJournalReplay, AioWrite) { MockReplayImageCtx mock_image_ctx(*ictx); MockJournalReplay mock_journal_replay(mock_image_ctx); - MockAioImageRequest mock_aio_image_request; + MockIoImageRequest mock_io_image_request; expect_op_work_queue(mock_image_ctx); InSequence seq; - AioCompletion *aio_comp; + io::AioCompletion *aio_comp; C_SaferCond on_ready; C_SaferCond on_safe; - expect_aio_write(mock_aio_image_request, &aio_comp, 123, 456, "test"); + expect_aio_write(mock_io_image_request, &aio_comp, 123, 456, "test"); when_process(mock_journal_replay, EventEntry{AioWriteEvent(123, 456, to_bl("test"))}, &on_ready, &on_safe); @@ -346,7 +351,7 @@ TEST_F(TestMockJournalReplay, AioWrite) { when_complete(mock_image_ctx, aio_comp, 0); ASSERT_EQ(0, on_ready.wait()); - expect_aio_flush(mock_image_ctx, mock_aio_image_request, 0); + expect_aio_flush(mock_image_ctx, mock_io_image_request, 0); ASSERT_EQ(0, when_shut_down(mock_journal_replay, false)); ASSERT_EQ(0, on_safe.wait()); } @@ -359,14 +364,14 @@ TEST_F(TestMockJournalReplay, AioFlush) { MockReplayImageCtx mock_image_ctx(*ictx); MockJournalReplay mock_journal_replay(mock_image_ctx); - MockAioImageRequest mock_aio_image_request; + MockIoImageRequest mock_io_image_request; expect_op_work_queue(mock_image_ctx); InSequence seq; - AioCompletion *aio_comp; + io::AioCompletion *aio_comp; C_SaferCond on_ready; C_SaferCond on_safe; - expect_aio_flush(mock_aio_image_request, &aio_comp); + expect_aio_flush(mock_io_image_request, &aio_comp); when_process(mock_journal_replay, EventEntry{AioFlushEvent()}, &on_ready, &on_safe); @@ -385,14 +390,14 @@ TEST_F(TestMockJournalReplay, IOError) { MockReplayImageCtx mock_image_ctx(*ictx); MockJournalReplay mock_journal_replay(mock_image_ctx); - MockAioImageRequest mock_aio_image_request; + MockIoImageRequest mock_io_image_request; expect_op_work_queue(mock_image_ctx); InSequence seq; - AioCompletion *aio_comp; + io::AioCompletion *aio_comp; C_SaferCond on_ready; C_SaferCond on_safe; - expect_aio_discard(mock_aio_image_request, &aio_comp, 123, 456); + expect_aio_discard(mock_io_image_request, &aio_comp, 123, 456); when_process(mock_journal_replay, EventEntry{AioDiscardEvent(123, 456)}, &on_ready, &on_safe); @@ -400,7 +405,7 @@ TEST_F(TestMockJournalReplay, IOError) { when_complete(mock_image_ctx, aio_comp, -EINVAL); ASSERT_EQ(-EINVAL, on_safe.wait()); - expect_aio_flush(mock_image_ctx, mock_aio_image_request, 0); + expect_aio_flush(mock_image_ctx, mock_io_image_request, 0); ASSERT_EQ(0, when_shut_down(mock_journal_replay, false)); ASSERT_EQ(0, on_ready.wait()); } @@ -413,19 +418,19 @@ TEST_F(TestMockJournalReplay, SoftFlushIO) { MockReplayImageCtx mock_image_ctx(*ictx); MockJournalReplay mock_journal_replay(mock_image_ctx); - MockAioImageRequest mock_aio_image_request; + MockIoImageRequest mock_io_image_request; expect_op_work_queue(mock_image_ctx); InSequence seq; const size_t io_count = 32; C_SaferCond on_safes[io_count]; for (size_t i = 0; i < io_count; ++i) { - AioCompletion *aio_comp; - AioCompletion *flush_comp = nullptr; + io::AioCompletion *aio_comp; + io::AioCompletion *flush_comp = nullptr; C_SaferCond on_ready; - expect_aio_discard(mock_aio_image_request, &aio_comp, 123, 456); + expect_aio_discard(mock_io_image_request, &aio_comp, 123, 456); if (i == io_count - 1) { - expect_aio_flush(mock_aio_image_request, &flush_comp); + expect_aio_flush(mock_io_image_request, &flush_comp); } when_process(mock_journal_replay, EventEntry{AioDiscardEvent(123, 456)}, @@ -452,20 +457,20 @@ TEST_F(TestMockJournalReplay, PauseIO) { MockReplayImageCtx mock_image_ctx(*ictx); MockJournalReplay mock_journal_replay(mock_image_ctx); - MockAioImageRequest mock_aio_image_request; + MockIoImageRequest mock_io_image_request; expect_op_work_queue(mock_image_ctx); InSequence seq; const size_t io_count = 64; - std::list flush_comps; + std::list flush_comps; C_SaferCond on_safes[io_count]; for (size_t i = 0; i < io_count; ++i) { - AioCompletion *aio_comp; + io::AioCompletion *aio_comp; C_SaferCond on_ready; - expect_aio_write(mock_aio_image_request, &aio_comp, 123, 456, "test"); + expect_aio_write(mock_io_image_request, &aio_comp, 123, 456, "test"); if ((i + 1) % 32 == 0) { flush_comps.push_back(nullptr); - expect_aio_flush(mock_aio_image_request, &flush_comps.back()); + expect_aio_flush(mock_io_image_request, &flush_comps.back()); } when_process(mock_journal_replay, EventEntry{AioWriteEvent(123, 456, to_bl("test"))}, @@ -493,14 +498,14 @@ TEST_F(TestMockJournalReplay, Flush) { MockReplayImageCtx mock_image_ctx(*ictx); MockJournalReplay mock_journal_replay(mock_image_ctx); - MockAioImageRequest mock_aio_image_request; + MockIoImageRequest mock_io_image_request; expect_op_work_queue(mock_image_ctx); InSequence seq; - AioCompletion *aio_comp = nullptr; + io::AioCompletion *aio_comp = nullptr; C_SaferCond on_ready; C_SaferCond on_safe; - expect_aio_discard(mock_aio_image_request, &aio_comp, 123, 456); + expect_aio_discard(mock_io_image_request, &aio_comp, 123, 456); when_process(mock_journal_replay, EventEntry{AioDiscardEvent(123, 456)}, &on_ready, &on_safe); @@ -508,7 +513,7 @@ TEST_F(TestMockJournalReplay, Flush) { when_complete(mock_image_ctx, aio_comp, 0); ASSERT_EQ(0, on_ready.wait()); - expect_aio_flush(mock_image_ctx, mock_aio_image_request, 0); + expect_aio_flush(mock_image_ctx, mock_io_image_request, 0); ASSERT_EQ(0, when_flush(mock_journal_replay)); ASSERT_EQ(0, on_safe.wait()); } diff --git a/src/test/librbd/mock/MockContextWQ.h b/src/test/librbd/mock/MockContextWQ.h index de6ecdaa5cb..f900b627df3 100644 --- a/src/test/librbd/mock/MockContextWQ.h +++ b/src/test/librbd/mock/MockContextWQ.h @@ -6,6 +6,8 @@ #include "gmock/gmock.h" +struct Context; + namespace librbd { struct MockContextWQ { diff --git a/src/test/librbd/mock/MockImageCtx.h b/src/test/librbd/mock/MockImageCtx.h index b7983facb08..1b2354df156 100644 --- a/src/test/librbd/mock/MockImageCtx.h +++ b/src/test/librbd/mock/MockImageCtx.h @@ -5,7 +5,6 @@ #define CEPH_TEST_LIBRBD_MOCK_IMAGE_CTX_H #include "include/rados/librados.hpp" -#include "test/librbd/mock/MockAioImageRequestWQ.h" #include "test/librbd/mock/MockContextWQ.h" #include "test/librbd/mock/MockExclusiveLock.h" #include "test/librbd/mock/MockImageState.h" @@ -14,6 +13,7 @@ #include "test/librbd/mock/MockObjectMap.h" #include "test/librbd/mock/MockOperations.h" #include "test/librbd/mock/MockReadahead.h" +#include "test/librbd/mock/io/MockImageRequestWQ.h" #include "common/RWLock.h" #include "common/WorkQueue.h" #include "librbd/ImageCtx.h" @@ -75,7 +75,7 @@ struct MockImageCtx { format_string(image_ctx.format_string), group_spec(image_ctx.group_spec), layout(image_ctx.layout), - aio_work_queue(new MockAioImageRequestWQ()), + io_work_queue(new io::MockImageRequestWQ()), op_work_queue(new MockContextWQ()), readahead_max_bytes(image_ctx.readahead_max_bytes), parent(NULL), operations(new MockOperations()), @@ -116,7 +116,7 @@ struct MockImageCtx { delete operations; delete image_watcher; delete op_work_queue; - delete aio_work_queue; + delete io_work_queue; } void wait_for_async_requests() { @@ -244,7 +244,7 @@ struct MockImageCtx { xlist*> async_requests; std::list async_requests_waiters; - MockAioImageRequestWQ *aio_work_queue; + io::MockImageRequestWQ *io_work_queue; MockContextWQ *op_work_queue; cache::MockImageCache *image_cache = nullptr; diff --git a/src/test/librbd/mock/MockJournal.h b/src/test/librbd/mock/MockJournal.h index 2a4b44d076a..a31a80386e3 100644 --- a/src/test/librbd/mock/MockJournal.h +++ b/src/test/librbd/mock/MockJournal.h @@ -11,11 +11,11 @@ namespace librbd { -struct AioObjectRequestHandle; struct ImageCtx; +namespace io { struct ObjectRequestHandle; } struct MockJournal { - typedef std::list AioObjectRequests; + typedef std::list ObjectRequests; static MockJournal *s_instance; static MockJournal *get_instance() { @@ -54,12 +54,12 @@ struct MockJournal { MOCK_METHOD5(append_write_event, uint64_t(uint64_t, size_t, const bufferlist &, - const AioObjectRequests &, bool)); + const ObjectRequests &, bool)); MOCK_METHOD5(append_io_event_mock, uint64_t(const journal::EventEntry&, - const AioObjectRequests &, + const ObjectRequests &, uint64_t, size_t, bool)); uint64_t append_io_event(journal::EventEntry &&event_entry, - const AioObjectRequests &requests, + const ObjectRequests &requests, uint64_t offset, size_t length, bool flush_entry) { // googlemock doesn't support move semantics diff --git a/src/test/librbd/mock/MockAioImageRequestWQ.h b/src/test/librbd/mock/io/MockImageRequestWQ.h similarity index 66% rename from src/test/librbd/mock/MockAioImageRequestWQ.h rename to src/test/librbd/mock/io/MockImageRequestWQ.h index b5b5aaeebf7..972b75f7421 100644 --- a/src/test/librbd/mock/MockAioImageRequestWQ.h +++ b/src/test/librbd/mock/io/MockImageRequestWQ.h @@ -1,16 +1,17 @@ // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab -#ifndef CEPH_TEST_LIBRBD_MOCK_AIO_IMAGE_REQUEST_WQ_H -#define CEPH_TEST_LIBRBD_MOCK_AIO_IMAGE_REQUEST_WQ_H +#ifndef CEPH_TEST_LIBRBD_MOCK_IO_IMAGE_REQUEST_WQ_H +#define CEPH_TEST_LIBRBD_MOCK_IO_IMAGE_REQUEST_WQ_H #include "gmock/gmock.h" class Context; namespace librbd { +namespace io { -struct MockAioImageRequestWQ { +struct MockImageRequestWQ { MOCK_METHOD1(block_writes, void(Context *)); MOCK_METHOD0(unblock_writes, void()); @@ -20,6 +21,7 @@ struct MockAioImageRequestWQ { MOCK_CONST_METHOD0(is_lock_request_needed, bool()); }; +} // namespace io } // namespace librbd -#endif // CEPH_TEST_LIBRBD_MOCK_AIO_IMAGE_REQUEST_WQ_H +#endif // CEPH_TEST_LIBRBD_MOCK_IO_IMAGE_REQUEST_WQ_H diff --git a/src/test/librbd/operation/test_mock_DisableFeaturesRequest.cc b/src/test/librbd/operation/test_mock_DisableFeaturesRequest.cc index 53e4d6beaf7..4d451c71545 100644 --- a/src/test/librbd/operation/test_mock_DisableFeaturesRequest.cc +++ b/src/test/librbd/operation/test_mock_DisableFeaturesRequest.cc @@ -6,9 +6,9 @@ #include "test/librbd/mock/MockImageCtx.h" #include "test/librbd/mock/MockJournalPolicy.h" #include "cls/rbd/cls_rbd_client.h" -#include "librbd/AioCompletion.h" #include "librbd/internal.h" #include "librbd/image/SetFlagsRequest.h" +#include "librbd/io/AioCompletion.h" #include "librbd/mirror/DisableRequest.h" #include "librbd/journal/RemoveRequest.h" #include "librbd/journal/StandardPolicy.h" @@ -203,12 +203,12 @@ public: } void expect_block_writes(MockOperationImageCtx &mock_image_ctx) { - EXPECT_CALL(*mock_image_ctx.aio_work_queue, block_writes(_)) + EXPECT_CALL(*mock_image_ctx.io_work_queue, block_writes(_)) .WillOnce(CompleteContext(0, mock_image_ctx.image_ctx->op_work_queue)); } void expect_unblock_writes(MockOperationImageCtx &mock_image_ctx) { - EXPECT_CALL(*mock_image_ctx.aio_work_queue, unblock_writes()).Times(1); + EXPECT_CALL(*mock_image_ctx.io_work_queue, unblock_writes()).Times(1); } void expect_verify_lock_ownership(MockOperationImageCtx &mock_image_ctx) { diff --git a/src/test/librbd/operation/test_mock_EnableFeaturesRequest.cc b/src/test/librbd/operation/test_mock_EnableFeaturesRequest.cc index 90ee5f79fce..5085d04dfca 100644 --- a/src/test/librbd/operation/test_mock_EnableFeaturesRequest.cc +++ b/src/test/librbd/operation/test_mock_EnableFeaturesRequest.cc @@ -5,10 +5,10 @@ #include "test/librbd/test_support.h" #include "test/librbd/mock/MockImageCtx.h" #include "cls/rbd/cls_rbd_client.h" -#include "librbd/AioCompletion.h" #include "librbd/Operations.h" #include "librbd/internal.h" #include "librbd/image/SetFlagsRequest.h" +#include "librbd/io/AioCompletion.h" #include "librbd/mirror/EnableRequest.h" #include "librbd/journal/CreateRequest.h" #include "librbd/journal/Types.h" @@ -212,12 +212,12 @@ public: } void expect_block_writes(MockOperationImageCtx &mock_image_ctx) { - EXPECT_CALL(*mock_image_ctx.aio_work_queue, block_writes(_)) + EXPECT_CALL(*mock_image_ctx.io_work_queue, block_writes(_)) .WillOnce(CompleteContext(0, mock_image_ctx.image_ctx->op_work_queue)); } void expect_unblock_writes(MockOperationImageCtx &mock_image_ctx) { - EXPECT_CALL(*mock_image_ctx.aio_work_queue, unblock_writes()).Times(1); + EXPECT_CALL(*mock_image_ctx.io_work_queue, unblock_writes()).Times(1); } void expect_verify_lock_ownership(MockOperationImageCtx &mock_image_ctx) { diff --git a/src/test/librbd/operation/test_mock_ResizeRequest.cc b/src/test/librbd/operation/test_mock_ResizeRequest.cc index 090a1609943..851f34a108f 100644 --- a/src/test/librbd/operation/test_mock_ResizeRequest.cc +++ b/src/test/librbd/operation/test_mock_ResizeRequest.cc @@ -62,12 +62,12 @@ public: typedef TrimRequest MockTrimRequest; void expect_block_writes(MockImageCtx &mock_image_ctx, int r) { - EXPECT_CALL(*mock_image_ctx.aio_work_queue, block_writes(_)) + EXPECT_CALL(*mock_image_ctx.io_work_queue, block_writes(_)) .WillOnce(CompleteContext(r, mock_image_ctx.image_ctx->op_work_queue)); } void expect_unblock_writes(MockImageCtx &mock_image_ctx) { - EXPECT_CALL(*mock_image_ctx.aio_work_queue, unblock_writes()) + EXPECT_CALL(*mock_image_ctx.io_work_queue, unblock_writes()) .Times(1); } diff --git a/src/test/librbd/operation/test_mock_SnapshotCreateRequest.cc b/src/test/librbd/operation/test_mock_SnapshotCreateRequest.cc index dada4a552b7..3fce272a6bd 100644 --- a/src/test/librbd/operation/test_mock_SnapshotCreateRequest.cc +++ b/src/test/librbd/operation/test_mock_SnapshotCreateRequest.cc @@ -31,7 +31,7 @@ public: typedef SnapshotCreateRequest MockSnapshotCreateRequest; void expect_block_writes(MockImageCtx &mock_image_ctx) { - EXPECT_CALL(*mock_image_ctx.aio_work_queue, block_writes(_)) + EXPECT_CALL(*mock_image_ctx.io_work_queue, block_writes(_)) .WillOnce(CompleteContext(0, mock_image_ctx.image_ctx->op_work_queue)); } @@ -93,7 +93,7 @@ public: } void expect_unblock_writes(MockImageCtx &mock_image_ctx) { - EXPECT_CALL(*mock_image_ctx.aio_work_queue, unblock_writes()) + EXPECT_CALL(*mock_image_ctx.io_work_queue, unblock_writes()) .Times(1); } diff --git a/src/test/librbd/operation/test_mock_SnapshotRollbackRequest.cc b/src/test/librbd/operation/test_mock_SnapshotRollbackRequest.cc index 42cedf8a16a..a65206c42b9 100644 --- a/src/test/librbd/operation/test_mock_SnapshotRollbackRequest.cc +++ b/src/test/librbd/operation/test_mock_SnapshotRollbackRequest.cc @@ -88,12 +88,12 @@ public: typedef ResizeRequest MockResizeRequest; void expect_block_writes(MockOperationImageCtx &mock_image_ctx, int r) { - EXPECT_CALL(*mock_image_ctx.aio_work_queue, block_writes(_)) + EXPECT_CALL(*mock_image_ctx.io_work_queue, block_writes(_)) .WillOnce(CompleteContext(r, mock_image_ctx.image_ctx->op_work_queue)); } void expect_unblock_writes(MockOperationImageCtx &mock_image_ctx) { - EXPECT_CALL(*mock_image_ctx.aio_work_queue, unblock_writes()) + EXPECT_CALL(*mock_image_ctx.io_work_queue, unblock_writes()) .Times(1); } diff --git a/src/test/librbd/test_ConsistencyGroups.cc b/src/test/librbd/test_Groups.cc similarity index 95% rename from src/test/librbd/test_ConsistencyGroups.cc rename to src/test/librbd/test_Groups.cc index db30fe6b684..39f30959abb 100644 --- a/src/test/librbd/test_ConsistencyGroups.cc +++ b/src/test/librbd/test_Groups.cc @@ -12,12 +12,12 @@ #include "common/RWLock.h" #include "cls/lock/cls_lock_client.h" #include "cls/lock/cls_lock_types.h" -#include "librbd/AioCompletion.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/internal.h" #include "librbd/ImageCtx.h" #include "librbd/ImageWatcher.h" #include "librbd/WatchNotifyTypes.h" +#include "librbd/io/AioCompletion.h" +#include "librbd/io/ImageRequestWQ.h" #include "test/librados/test.h" #include "gtest/gtest.h" #include @@ -35,7 +35,7 @@ using namespace ceph; using namespace boost::assign; using namespace librbd::watch_notify; -void register_test_consistency_groups() { +void register_test_groups() { } class TestLibCG : public TestFixture { diff --git a/src/test/librbd/test_ImageWatcher.cc b/src/test/librbd/test_ImageWatcher.cc index 740d030a618..24d420898ad 100644 --- a/src/test/librbd/test_ImageWatcher.cc +++ b/src/test/librbd/test_ImageWatcher.cc @@ -12,12 +12,12 @@ #include "common/RWLock.h" #include "cls/lock/cls_lock_client.h" #include "cls/lock/cls_lock_types.h" -#include "librbd/AioCompletion.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/internal.h" #include "librbd/ImageCtx.h" #include "librbd/ImageWatcher.h" #include "librbd/WatchNotifyTypes.h" +#include "librbd/io/AioCompletion.h" +#include "librbd/io/ImageRequestWQ.h" #include "test/librados/test.h" #include "gtest/gtest.h" #include diff --git a/src/test/librbd/test_fixture.cc b/src/test/librbd/test_fixture.cc index 7b7dc05a7c2..bf3e149dfc8 100644 --- a/src/test/librbd/test_fixture.cc +++ b/src/test/librbd/test_fixture.cc @@ -3,11 +3,11 @@ #include "test/librbd/test_fixture.h" #include "test/librbd/test_support.h" #include "include/stringify.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageState.h" #include "librbd/ImageWatcher.h" #include "librbd/Operations.h" +#include "librbd/io/ImageRequestWQ.h" #include "cls/lock/cls_lock_client.h" #include "cls/lock/cls_lock_types.h" #include "cls/rbd/cls_rbd_types.h" @@ -123,7 +123,7 @@ int TestFixture::unlock_image() { } int TestFixture::acquire_exclusive_lock(librbd::ImageCtx &ictx) { - int r = ictx.aio_work_queue->write(0, 0, "", 0); + int r = ictx.io_work_queue->write(0, 0, "", 0); if (r != 0) { return r; } diff --git a/src/test/librbd/test_internal.cc b/src/test/librbd/test_internal.cc index fc192959773..743559be78d 100644 --- a/src/test/librbd/test_internal.cc +++ b/src/test/librbd/test_internal.cc @@ -3,15 +3,15 @@ #include "cls/rbd/cls_rbd_types.h" #include "test/librbd/test_fixture.h" #include "test/librbd/test_support.h" -#include "librbd/AioCompletion.h" -#include "librbd/AioImageRequest.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageState.h" #include "librbd/ImageWatcher.h" #include "librbd/internal.h" #include "librbd/ObjectMap.h" #include "librbd/Operations.h" +#include "librbd/io/AioCompletion.h" +#include "librbd/io/ImageRequest.h" +#include "librbd/io/ImageRequestWQ.h" #include #include #include @@ -272,9 +272,9 @@ TEST_F(TestInternal, AioWriteRequestsLock) { std::string buffer(256, '1'); Context *ctx = new DummyContext(); - librbd::AioCompletion *c = librbd::AioCompletion::create(ctx); + auto c = librbd::io::AioCompletion::create(ctx); c->get(); - ictx->aio_work_queue->aio_write(c, 0, buffer.size(), buffer.c_str(), 0); + ictx->io_work_queue->aio_write(c, 0, buffer.size(), buffer.c_str(), 0); bool is_owner; ASSERT_EQ(0, librbd::is_exclusive_lock_owner(ictx, &is_owner)); @@ -294,9 +294,9 @@ TEST_F(TestInternal, AioDiscardRequestsLock) { ASSERT_EQ(0, lock_image(*ictx, LOCK_EXCLUSIVE, "manually locked")); Context *ctx = new DummyContext(); - librbd::AioCompletion *c = librbd::AioCompletion::create(ctx); + auto c = librbd::io::AioCompletion::create(ctx); c->get(); - ictx->aio_work_queue->aio_discard(c, 0, 256); + ictx->io_work_queue->aio_discard(c, 0, 256); bool is_owner; ASSERT_EQ(0, librbd::is_exclusive_lock_owner(ictx, &is_owner)); @@ -493,7 +493,7 @@ TEST_F(TestInternal, SnapshotCopyup) bufferlist bl; bl.append(std::string(256, '1')); - ASSERT_EQ(256, ictx->aio_work_queue->write(0, bl.length(), bl.c_str(), 0)); + ASSERT_EQ(256, ictx->io_work_queue->write(0, bl.length(), bl.c_str(), 0)); ASSERT_EQ(0, snap_create(*ictx, "snap1")); ASSERT_EQ(0, ictx->operations->snap_protect("snap1")); @@ -512,7 +512,7 @@ TEST_F(TestInternal, SnapshotCopyup) ASSERT_EQ(0, snap_create(*ictx2, "snap1")); ASSERT_EQ(0, snap_create(*ictx2, "snap2")); - ASSERT_EQ(256, ictx2->aio_work_queue->write(256, bl.length(), bl.c_str(), 0)); + ASSERT_EQ(256, ictx2->io_work_queue->write(256, bl.length(), bl.c_str(), 0)); librados::IoCtx snap_ctx; snap_ctx.dup(ictx2->data_ctx); @@ -541,10 +541,10 @@ TEST_F(TestInternal, SnapshotCopyup) const char *snap_name = it->empty() ? NULL : it->c_str(); ASSERT_EQ(0, librbd::snap_set(ictx2, snap_name)); - ASSERT_EQ(256, ictx2->aio_work_queue->read(0, 256, read_bl.c_str(), 0)); + ASSERT_EQ(256, ictx2->io_work_queue->read(0, 256, read_bl.c_str(), 0)); ASSERT_TRUE(bl.contents_equal(read_bl)); - ASSERT_EQ(256, ictx2->aio_work_queue->read(256, 256, read_bl.c_str(), 0)); + ASSERT_EQ(256, ictx2->io_work_queue->read(256, 256, read_bl.c_str(), 0)); if (snap_name == NULL) { ASSERT_TRUE(bl.contents_equal(read_bl)); } else { @@ -589,8 +589,8 @@ TEST_F(TestInternal, ResizeCopyup) bufferlist bl; bl.append(std::string(4096, '1')); for (size_t i = 0; i < m_image_size; i += bl.length()) { - ASSERT_EQ(bl.length(), ictx->aio_work_queue->write(i, bl.length(), - bl.c_str(), 0)); + ASSERT_EQ(bl.length(), ictx->io_work_queue->write(i, bl.length(), + bl.c_str(), 0)); } ASSERT_EQ(0, snap_create(*ictx, "snap1")); @@ -623,8 +623,8 @@ TEST_F(TestInternal, ResizeCopyup) } for (size_t i = 2 << order; i < m_image_size; i += bl.length()) { - ASSERT_EQ(bl.length(), ictx2->aio_work_queue->read(i, bl.length(), - read_bl.c_str(), 0)); + ASSERT_EQ(bl.length(), ictx2->io_work_queue->read(i, bl.length(), + read_bl.c_str(), 0)); ASSERT_TRUE(bl.contents_equal(read_bl)); } } @@ -651,8 +651,8 @@ TEST_F(TestInternal, DiscardCopyup) bufferlist bl; bl.append(std::string(4096, '1')); for (size_t i = 0; i < m_image_size; i += bl.length()) { - ASSERT_EQ(bl.length(), ictx->aio_work_queue->write(i, bl.length(), - bl.c_str(), 0)); + ASSERT_EQ(bl.length(), ictx->io_work_queue->write(i, bl.length(), + bl.c_str(), 0)); } ASSERT_EQ(0, snap_create(*ictx, "snap1")); @@ -672,7 +672,7 @@ TEST_F(TestInternal, DiscardCopyup) read_bl.push_back(read_ptr); ASSERT_EQ(static_cast(m_image_size - 64), - ictx2->aio_work_queue->discard(32, m_image_size - 64)); + ictx2->io_work_queue->discard(32, m_image_size - 64)); ASSERT_EQ(0, librbd::snap_set(ictx2, "snap1")); { @@ -682,8 +682,8 @@ TEST_F(TestInternal, DiscardCopyup) } for (size_t i = 0; i < m_image_size; i += bl.length()) { - ASSERT_EQ(bl.length(), ictx2->aio_work_queue->read(i, bl.length(), - read_bl.c_str(), 0)); + ASSERT_EQ(bl.length(), ictx2->io_work_queue->read(i, bl.length(), + read_bl.c_str(), 0)); ASSERT_TRUE(bl.contents_equal(read_bl)); } } @@ -695,12 +695,12 @@ TEST_F(TestInternal, ShrinkFlushesCache) { std::string buffer(4096, '1'); // ensure write-path is initialized - ictx->aio_work_queue->write(0, buffer.size(), buffer.c_str(), 0); + ictx->io_work_queue->write(0, buffer.size(), buffer.c_str(), 0); C_SaferCond cond_ctx; - librbd::AioCompletion *c = librbd::AioCompletion::create(&cond_ctx); + auto c = librbd::io::AioCompletion::create(&cond_ctx); c->get(); - ictx->aio_work_queue->aio_write(c, 0, buffer.size(), buffer.c_str(), 0); + ictx->io_work_queue->aio_write(c, 0, buffer.size(), buffer.c_str(), 0); librbd::NoOpProgressContext no_op; ASSERT_EQ(0, ictx->operations->resize(m_image_size >> 1, true, no_op)); @@ -790,7 +790,7 @@ TEST_F(TestInternal, WriteFullCopyup) { bufferlist bl; bl.append(std::string(1 << ictx->order, '1')); ASSERT_EQ(bl.length(), - ictx->aio_work_queue->write(0, bl.length(), bl.c_str(), 0)); + ictx->io_work_queue->write(0, bl.length(), bl.c_str(), 0)); ASSERT_EQ(0, librbd::flush(ictx)); ASSERT_EQ(0, create_snapshot("snap1", true)); @@ -819,7 +819,7 @@ TEST_F(TestInternal, WriteFullCopyup) { bufferlist write_full_bl; write_full_bl.append(std::string(1 << ictx2->order, '2')); ASSERT_EQ(write_full_bl.length(), - ictx2->aio_work_queue->write(0, write_full_bl.length(), + ictx2->io_work_queue->write(0, write_full_bl.length(), write_full_bl.c_str(), 0)); ASSERT_EQ(0, ictx2->operations->flatten(no_op)); @@ -828,13 +828,13 @@ TEST_F(TestInternal, WriteFullCopyup) { bufferlist read_bl; read_bl.push_back(read_ptr); - ASSERT_EQ(read_bl.length(), ictx2->aio_work_queue->read(0, read_bl.length(), - read_bl.c_str(), 0)); + ASSERT_EQ(read_bl.length(), ictx2->io_work_queue->read(0, read_bl.length(), + read_bl.c_str(), 0)); ASSERT_TRUE(write_full_bl.contents_equal(read_bl)); ASSERT_EQ(0, librbd::snap_set(ictx2, "snap1")); - ASSERT_EQ(read_bl.length(), ictx2->aio_work_queue->read(0, read_bl.length(), - read_bl.c_str(), 0)); + ASSERT_EQ(read_bl.length(), ictx2->io_work_queue->read(0, read_bl.length(), + read_bl.c_str(), 0)); ASSERT_TRUE(bl.contents_equal(read_bl)); } diff --git a/src/test/librbd/test_main.cc b/src/test/librbd/test_main.cc index 8835162d8f0..0aa6aeeb81c 100644 --- a/src/test/librbd/test_main.cc +++ b/src/test/librbd/test_main.cc @@ -10,6 +10,7 @@ extern void register_test_librbd(); #ifdef TEST_LIBRBD_INTERNALS +extern void register_test_groups(); extern void register_test_image_watcher(); extern void register_test_internal(); extern void register_test_journal_entries(); @@ -18,13 +19,13 @@ extern void register_test_object_map(); extern void register_test_operations(); extern void register_test_mirroring(); extern void register_test_mirroring_watcher(); -extern void register_test_consistency_groups(); #endif // TEST_LIBRBD_INTERNALS int main(int argc, char **argv) { register_test_librbd(); #ifdef TEST_LIBRBD_INTERNALS + register_test_groups(); register_test_image_watcher(); register_test_internal(); register_test_journal_entries(); @@ -33,7 +34,6 @@ int main(int argc, char **argv) register_test_operations(); register_test_mirroring(); register_test_mirroring_watcher(); - register_test_consistency_groups(); #endif // TEST_LIBRBD_INTERNALS ::testing::InitGoogleTest(&argc, argv); diff --git a/src/test/librbd/test_mirroring.cc b/src/test/librbd/test_mirroring.cc index b2c0cff5ae5..8e70f383b23 100644 --- a/src/test/librbd/test_mirroring.cc +++ b/src/test/librbd/test_mirroring.cc @@ -13,15 +13,15 @@ */ #include "test/librbd/test_fixture.h" #include "test/librbd/test_support.h" -#include "librbd/AioCompletion.h" -#include "librbd/AioImageRequest.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageState.h" #include "librbd/ImageWatcher.h" #include "librbd/internal.h" #include "librbd/ObjectMap.h" #include "librbd/Operations.h" +#include "librbd/io/AioCompletion.h" +#include "librbd/io/ImageRequest.h" +#include "librbd/io/ImageRequestWQ.h" #include "librbd/journal/Types.h" #include "journal/Journaler.h" #include "journal/Settings.h" diff --git a/src/test/librbd/test_mock_ExclusiveLock.cc b/src/test/librbd/test_mock_ExclusiveLock.cc index 68ceda27797..f593f834803 100644 --- a/src/test/librbd/test_mock_ExclusiveLock.cc +++ b/src/test/librbd/test_mock_ExclusiveLock.cc @@ -214,15 +214,15 @@ public: } void expect_set_require_lock_on_read(MockExclusiveLockImageCtx &mock_image_ctx) { - EXPECT_CALL(*mock_image_ctx.aio_work_queue, set_require_lock_on_read()); + EXPECT_CALL(*mock_image_ctx.io_work_queue, set_require_lock_on_read()); } void expect_clear_require_lock_on_read(MockExclusiveLockImageCtx &mock_image_ctx) { - EXPECT_CALL(*mock_image_ctx.aio_work_queue, clear_require_lock_on_read()); + EXPECT_CALL(*mock_image_ctx.io_work_queue, clear_require_lock_on_read()); } void expect_block_writes(MockExclusiveLockImageCtx &mock_image_ctx) { - EXPECT_CALL(*mock_image_ctx.aio_work_queue, block_writes(_)) + EXPECT_CALL(*mock_image_ctx.io_work_queue, block_writes(_)) .WillOnce(CompleteContext(0, mock_image_ctx.image_ctx->op_work_queue)); if ((mock_image_ctx.features & RBD_FEATURE_JOURNALING) != 0) { expect_set_require_lock_on_read(mock_image_ctx); @@ -231,7 +231,7 @@ public: void expect_unblock_writes(MockExclusiveLockImageCtx &mock_image_ctx) { expect_clear_require_lock_on_read(mock_image_ctx); - EXPECT_CALL(*mock_image_ctx.aio_work_queue, unblock_writes()); + EXPECT_CALL(*mock_image_ctx.io_work_queue, unblock_writes()); } void expect_prepare_lock_complete(MockExclusiveLockImageCtx &mock_image_ctx) { @@ -272,7 +272,7 @@ public: } void expect_is_lock_request_needed(MockExclusiveLockImageCtx &mock_image_ctx, bool ret) { - EXPECT_CALL(*mock_image_ctx.aio_work_queue, is_lock_request_needed()) + EXPECT_CALL(*mock_image_ctx.io_work_queue, is_lock_request_needed()) .WillRepeatedly(Return(ret)); } diff --git a/src/test/librbd/test_mock_Journal.cc b/src/test/librbd/test_mock_Journal.cc index 04847e0fe03..c7a6ea30417 100644 --- a/src/test/librbd/test_mock_Journal.cc +++ b/src/test/librbd/test_mock_Journal.cc @@ -10,10 +10,10 @@ #include "common/Mutex.h" #include "cls/journal/cls_journal_types.h" #include "journal/Journaler.h" -#include "librbd/AioCompletion.h" -#include "librbd/AioObjectRequest.h" #include "librbd/Journal.h" #include "librbd/Utils.h" +#include "librbd/io/AioCompletion.h" +#include "librbd/io/ObjectRequest.h" #include "librbd/journal/Replay.h" #include "librbd/journal/RemoveRequest.h" #include "librbd/journal/CreateRequest.h" @@ -426,9 +426,9 @@ public: uint64_t when_append_io_event(MockJournalImageCtx &mock_image_ctx, MockJournal &mock_journal, - AioObjectRequest<> *object_request = nullptr) { + io::ObjectRequest<> *object_request = nullptr) { RWLock::RLocker owner_locker(mock_image_ctx.owner_lock); - MockJournal::AioObjectRequests object_requests; + MockJournal::IOObjectRequests object_requests; if (object_request != nullptr) { object_requests.push_back(object_request); } @@ -1018,7 +1018,7 @@ TEST_F(TestMockJournal, EventCommitError) { }; C_SaferCond object_request_ctx; - AioObjectRemove *object_request = new AioObjectRemove( + auto object_request = new io::ObjectRemoveRequest( ictx, "oid", 0, {}, &object_request_ctx); ::journal::MockFuture mock_future; @@ -1059,7 +1059,7 @@ TEST_F(TestMockJournal, EventCommitErrorWithPendingWriteback) { }; C_SaferCond object_request_ctx; - AioObjectRemove *object_request = new AioObjectRemove( + auto object_request = new io::ObjectRemoveRequest( ictx, "oid", 0, {}, &object_request_ctx); ::journal::MockFuture mock_future; diff --git a/src/test/rbd_mirror/image_sync/test_mock_ObjectCopyRequest.cc b/src/test/rbd_mirror/image_sync/test_mock_ObjectCopyRequest.cc index e1177bf0680..8c5e92e3f21 100644 --- a/src/test/rbd_mirror/image_sync/test_mock_ObjectCopyRequest.cc +++ b/src/test/rbd_mirror/image_sync/test_mock_ObjectCopyRequest.cc @@ -5,11 +5,11 @@ #include "include/interval_set.h" #include "include/rbd/librbd.hpp" #include "include/rbd/object_map_types.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/ImageCtx.h" #include "librbd/ImageState.h" #include "librbd/internal.h" #include "librbd/Operations.h" +#include "librbd/io/ImageRequestWQ.h" #include "test/librados_test_stub/MockTestMemIoCtxImpl.h" #include "test/librbd/mock/MockImageCtx.h" #include "tools/rbd_mirror/Threads.h" @@ -55,7 +55,7 @@ void scribble(librbd::ImageCtx *image_ctx, int num_ops, size_t max_size, bufferlist bl; bl.append(std::string(len, '1')); - int r = image_ctx->aio_work_queue->write(off, len, bl.c_str(), 0); + int r = image_ctx->io_work_queue->write(off, len, bl.c_str(), 0); ASSERT_EQ(static_cast(len), r); interval_set w; @@ -265,16 +265,16 @@ public: bufferlist remote_bl; remote_bl.append(std::string(object_size, '1')); - r = m_remote_image_ctx->aio_work_queue->read(0, object_size, - remote_bl.c_str(), 0); + r = m_remote_image_ctx->io_work_queue->read(0, object_size, + remote_bl.c_str(), 0); if (r < 0) { return r; } bufferlist local_bl; local_bl.append(std::string(object_size, '1')); - r = m_local_image_ctx->aio_work_queue->read(0, object_size, - local_bl.c_str(), 0); + r = m_local_image_ctx->io_work_queue->read(0, object_size, + local_bl.c_str(), 0); if (r < 0) { return r; } @@ -485,7 +485,7 @@ TEST_F(TestMockImageSyncObjectCopyRequest, Trim) { // trim the object uint64_t trim_offset = rand() % one.range_end(); - ASSERT_LE(0, m_remote_image_ctx->aio_work_queue->discard( + ASSERT_LE(0, m_remote_image_ctx->io_work_queue->discard( trim_offset, one.range_end() - trim_offset)); ASSERT_EQ(0, create_snap("sync")); @@ -529,7 +529,7 @@ TEST_F(TestMockImageSyncObjectCopyRequest, Remove) { // remove the object uint64_t object_size = 1 << m_remote_image_ctx->order; - ASSERT_LE(0, m_remote_image_ctx->aio_work_queue->discard(0, object_size)); + ASSERT_LE(0, m_remote_image_ctx->io_work_queue->discard(0, object_size)); ASSERT_EQ(0, create_snap("sync")); librbd::MockTestImageCtx mock_remote_image_ctx(*m_remote_image_ctx); librbd::MockTestImageCtx mock_local_image_ctx(*m_local_image_ctx); diff --git a/src/test/rbd_mirror/test_ImageReplayer.cc b/src/test/rbd_mirror/test_ImageReplayer.cc index 644b41ce752..29ab47ff63a 100644 --- a/src/test/rbd_mirror/test_ImageReplayer.cc +++ b/src/test/rbd_mirror/test_ImageReplayer.cc @@ -23,8 +23,6 @@ #include "cls/rbd/cls_rbd_types.h" #include "cls/rbd/cls_rbd_client.h" #include "journal/Journaler.h" -#include "librbd/AioCompletion.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageCtx.h" #include "librbd/ImageState.h" @@ -32,6 +30,8 @@ #include "librbd/Operations.h" #include "librbd/Utils.h" #include "librbd/internal.h" +#include "librbd/io/AioCompletion.h" +#include "librbd/io/ImageRequestWQ.h" #include "tools/rbd_mirror/types.h" #include "tools/rbd_mirror/ImageReplayer.h" #include "tools/rbd_mirror/ImageSyncThrottler.h" @@ -306,7 +306,7 @@ public: size_t len) { size_t written; - written = ictx->aio_work_queue->write(off, len, test_data, 0); + written = ictx->io_work_queue->write(off, len, test_data, 0); printf("wrote: %d\n", (int)written); ASSERT_EQ(len, written); } @@ -318,7 +318,7 @@ public: char *result = (char *)malloc(len + 1); ASSERT_NE(static_cast(NULL), result); - read = ictx->aio_work_queue->read(off, len, result, 0); + read = ictx->io_work_queue->read(off, len, result, 0); printf("read: %d\n", (int)read); ASSERT_EQ(len, static_cast(read)); result[len] = '\0'; @@ -339,9 +339,9 @@ public: void flush(librbd::ImageCtx *ictx) { C_SaferCond aio_flush_ctx; - librbd::AioCompletion *c = librbd::AioCompletion::create(&aio_flush_ctx); + auto c = librbd::io::AioCompletion::create(&aio_flush_ctx); c->get(); - ictx->aio_work_queue->aio_flush(c); + ictx->io_work_queue->aio_flush(c); ASSERT_EQ(0, c->wait_for_complete()); c->put(); diff --git a/src/test/rbd_mirror/test_ImageSync.cc b/src/test/rbd_mirror/test_ImageSync.cc index 2b79e6ba2da..de68bddfd12 100644 --- a/src/test/rbd_mirror/test_ImageSync.cc +++ b/src/test/rbd_mirror/test_ImageSync.cc @@ -6,12 +6,12 @@ #include "include/rbd/librbd.hpp" #include "journal/Journaler.h" #include "journal/Settings.h" -#include "librbd/AioImageRequestWQ.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageCtx.h" #include "librbd/ImageState.h" #include "librbd/internal.h" #include "librbd/Operations.h" +#include "librbd/io/ImageRequestWQ.h" #include "librbd/journal/Types.h" #include "tools/rbd_mirror/ImageSync.h" #include "tools/rbd_mirror/Threads.h" @@ -32,11 +32,11 @@ void scribble(librbd::ImageCtx *image_ctx, int num_ops, size_t max_size) uint64_t len = 1 + rand() % max_size; if (rand() % 4 == 0) { - ASSERT_EQ((int)len, image_ctx->aio_work_queue->discard(off, len)); + ASSERT_EQ((int)len, image_ctx->io_work_queue->discard(off, len)); } else { std::string str(len, '1'); - ASSERT_EQ((int)len, image_ctx->aio_work_queue->write(off, len, - str.c_str(), 0)); + ASSERT_EQ((int)len, image_ctx->io_work_queue->write(off, len, + str.c_str(), 0)); } } @@ -128,9 +128,9 @@ TEST_F(TestImageSync, Simple) { for (uint64_t offset = 0; offset < m_remote_image_ctx->size; offset += object_size) { - ASSERT_LE(0, m_remote_image_ctx->aio_work_queue->read( + ASSERT_LE(0, m_remote_image_ctx->io_work_queue->read( offset, object_size, read_remote_bl.c_str(), 0)); - ASSERT_LE(0, m_local_image_ctx->aio_work_queue->read( + ASSERT_LE(0, m_local_image_ctx->io_work_queue->read( offset, object_size, read_local_bl.c_str(), 0)); ASSERT_TRUE(read_remote_bl.contents_equal(read_local_bl)); } @@ -144,8 +144,8 @@ TEST_F(TestImageSync, Resize) { uint64_t len = object_size / 10; std::string str(len, '1'); - ASSERT_EQ((int)len, m_remote_image_ctx->aio_work_queue->write(off, len, - str.c_str(), 0)); + ASSERT_EQ((int)len, m_remote_image_ctx->io_work_queue->write(off, len, + str.c_str(), 0)); { RWLock::RLocker owner_locker(m_remote_image_ctx->owner_lock); ASSERT_EQ(0, m_remote_image_ctx->flush()); @@ -168,9 +168,9 @@ TEST_F(TestImageSync, Resize) { bufferlist read_local_bl; read_local_bl.append(std::string(len, '\0')); - ASSERT_LE(0, m_remote_image_ctx->aio_work_queue->read( + ASSERT_LE(0, m_remote_image_ctx->io_work_queue->read( off, len, read_remote_bl.c_str(), 0)); - ASSERT_LE(0, m_local_image_ctx->aio_work_queue->read( + ASSERT_LE(0, m_local_image_ctx->io_work_queue->read( off, len, read_local_bl.c_str(), 0)); ASSERT_TRUE(read_remote_bl.contents_equal(read_local_bl)); @@ -184,8 +184,8 @@ TEST_F(TestImageSync, Discard) { uint64_t len = object_size / 10; std::string str(len, '1'); - ASSERT_EQ((int)len, m_remote_image_ctx->aio_work_queue->write(off, len, - str.c_str(), 0)); + ASSERT_EQ((int)len, m_remote_image_ctx->io_work_queue->write(off, len, + str.c_str(), 0)); { RWLock::RLocker owner_locker(m_remote_image_ctx->owner_lock); ASSERT_EQ(0, m_remote_image_ctx->flush()); @@ -193,8 +193,8 @@ TEST_F(TestImageSync, Discard) { ASSERT_EQ(0, create_snap(m_remote_image_ctx, "snap", nullptr)); - ASSERT_EQ((int)len - 2, m_remote_image_ctx->aio_work_queue->discard(off + 1, - len - 2)); + ASSERT_EQ((int)len - 2, m_remote_image_ctx->io_work_queue->discard(off + 1, + len - 2)); { RWLock::RLocker owner_locker(m_remote_image_ctx->owner_lock); ASSERT_EQ(0, m_remote_image_ctx->flush()); @@ -210,9 +210,9 @@ TEST_F(TestImageSync, Discard) { bufferlist read_local_bl; read_local_bl.append(std::string(object_size, '\0')); - ASSERT_LE(0, m_remote_image_ctx->aio_work_queue->read( + ASSERT_LE(0, m_remote_image_ctx->io_work_queue->read( off, len, read_remote_bl.c_str(), 0)); - ASSERT_LE(0, m_local_image_ctx->aio_work_queue->read( + ASSERT_LE(0, m_local_image_ctx->io_work_queue->read( off, len, read_local_bl.c_str(), 0)); ASSERT_TRUE(read_remote_bl.contents_equal(read_local_bl)); @@ -280,9 +280,9 @@ TEST_F(TestImageSync, SnapshotStress) { ASSERT_EQ(remote_size, local_size); for (uint64_t offset = 0; offset < remote_size; offset += object_size) { - ASSERT_LE(0, m_remote_image_ctx->aio_work_queue->read( + ASSERT_LE(0, m_remote_image_ctx->io_work_queue->read( offset, object_size, read_remote_bl.c_str(), 0)); - ASSERT_LE(0, m_local_image_ctx->aio_work_queue->read( + ASSERT_LE(0, m_local_image_ctx->io_work_queue->read( offset, object_size, read_local_bl.c_str(), 0)); ASSERT_TRUE(read_remote_bl.contents_equal(read_local_bl)); } -- 2.39.5