]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd/cache: remove unnecessary WriteLogCache 37609/head
authorlixiaoy1 <xiaoyan.li@intel.com>
Fri, 9 Oct 2020 10:30:04 +0000 (06:30 -0400)
committerlixiaoy1 <xiaoyan.li@intel.com>
Sat, 10 Oct 2020 12:52:08 +0000 (08:52 -0400)
Remove the class librbd::cache::WriteLogCache.

Signed-off-by: Li, Xiaoyan <xiaoyan.li@intel.com>
14 files changed:
src/librbd/CMakeLists.txt
src/librbd/cache/WriteLogCache.cc [deleted file]
src/librbd/cache/WriteLogCache.h [deleted file]
src/librbd/cache/WriteLogImageDispatch.cc [new file with mode: 0644]
src/librbd/cache/WriteLogImageDispatch.h [new file with mode: 0644]
src/librbd/cache/pwl/AbstractWriteLog.h
src/librbd/cache/pwl/ImageDispatch.cc [deleted file]
src/librbd/cache/pwl/ImageDispatch.h [deleted file]
src/librbd/cache/pwl/InitRequest.cc
src/librbd/cache/pwl/InitRequest.h
src/librbd/cache/pwl/ShutdownRequest.cc
src/librbd/cache/pwl/ShutdownRequest.h
src/librbd/exclusive_lock/PreReleaseRequest.cc
src/test/librbd/cache/test_mock_ReplicatedWriteLog.cc

index c25ca46f69f0ede2d2f2c89919e11b142f179697..62137fb52aa63130376aecb4fad555d1235b6d2f 100644 (file)
@@ -195,8 +195,7 @@ if(WITH_RBD_RWL)
     cache/pwl/Types.cc
     cache/pwl/ReplicatedWriteLog.cc
     cache/pwl/AbstractWriteLog.cc
-    cache/pwl/ImageDispatch.cc
-    cache/WriteLogCache.cc)
+    cache/WriteLogImageDispatch.cc)
 endif()
 
 add_library(rbd_api STATIC librbd.cc)
diff --git a/src/librbd/cache/WriteLogCache.cc b/src/librbd/cache/WriteLogCache.cc
deleted file mode 100644 (file)
index ecbd5aa..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-
-#include "WriteLogCache.h"
-#include "librbd/cache/pwl/ReplicatedWriteLog.h"
-#include "librbd/cache/pwl/ImageCacheState.h"
-
-#undef dout_subsys
-#define dout_subsys ceph_subsys_rbd_pwl
-#undef dout_prefix
-#define dout_prefix *_dout << "librbd::cache::WriteLogCache: " << this << " " \
-                           <<  __func__ << ": "
-
-namespace librbd {
-namespace cache {
-
-using namespace librbd::cache::pwl;
-
-template <typename I>
-WriteLogCache<I>::WriteLogCache(I &image_ctx, librbd::cache::pwl::ImageCacheState<I>* cache_state) {
-  m_write_log = new librbd::cache::pwl::ReplicatedWriteLog<I>(image_ctx, cache_state);
-}
-
-template <typename I>
-WriteLogCache<I>::~WriteLogCache() {
-  delete m_write_log;
-}
-
-template <typename I>
-void WriteLogCache<I>::aio_read(Extents&& image_extents,
-                                ceph::bufferlist* bl,
-                                int fadvise_flags,
-                                Context *on_finish) {
-  m_write_log->read(std::move(image_extents), std::move(bl), fadvise_flags,
-                    on_finish);
-}
-
-template <typename I>
-void WriteLogCache<I>::aio_write(Extents &&image_extents,
-                                 bufferlist&& bl,
-                                 int fadvise_flags,
-                                 Context *on_finish) {
-  m_write_log->write(std::move(image_extents), std::move(bl),
-                     fadvise_flags, on_finish);
-}
-
-template <typename I>
-void WriteLogCache<I>::aio_discard(uint64_t offset, uint64_t length,
-                                   uint32_t discard_granularity_bytes,
-                                   Context *on_finish) {
-  m_write_log->discard(offset, length, discard_granularity_bytes, on_finish);
-}
-
-template <typename I>
-void WriteLogCache<I>::aio_flush(io::FlushSource flush_source, Context *on_finish) {
-  m_write_log->flush(flush_source, on_finish);
-}
-
-template <typename I>
-void WriteLogCache<I>::aio_writesame(uint64_t offset, uint64_t length,
-                                     bufferlist&& bl, int fadvise_flags,
-                                     Context *on_finish) {
-  m_write_log->writesame(offset, length, std::move(bl), fadvise_flags,
-                         on_finish);
-}
-
-template <typename I>
-void WriteLogCache<I>::aio_compare_and_write(Extents &&image_extents,
-                                             bufferlist&& cmp_bl,
-                                             bufferlist&& bl,
-                                             uint64_t *mismatch_offset,
-                                             int fadvise_flags,
-                                             Context *on_finish) {
-  m_write_log->compare_and_write(std::move(image_extents), std::move(cmp_bl),
-                                 std::move(bl), mismatch_offset, fadvise_flags,
-                                 on_finish);
-}
-
-template <typename I>
-void WriteLogCache<I>::init(Context *on_finish) {
-  m_write_log->init(on_finish);
-}
-
-template <typename I>
-void WriteLogCache<I>::shut_down(Context *on_finish) {
-  m_write_log->shut_down(on_finish);
-}
-
-template <typename I>
-void WriteLogCache<I>::invalidate(Context *on_finish) {
-  m_write_log->invalidate(on_finish);
-}
-
-template <typename I>
-void WriteLogCache<I>::flush(Context *on_finish) {
-  m_write_log->flush(on_finish);
-}
-
-} // namespace cache
-} // namespace librbd
-
-template class librbd::cache::WriteLogCache<librbd::ImageCtx>;
diff --git a/src/librbd/cache/WriteLogCache.h b/src/librbd/cache/WriteLogCache.h
deleted file mode 100644 (file)
index 5a6bbdf..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-
-#ifndef CEPH_LIBRBD_CACHE_WRITE_LOG_CACHE
-#define CEPH_LIBRBD_CACHE_WRITE_LOG_CACHE
-
-#include "librbd/cache/ImageCache.h"
-#include "librbd/io/Types.h"
-
-namespace librbd {
-
-struct ImageCtx;
-
-namespace cache {
-
-namespace pwl {
-template <typename> class AbstractWriteLog;
-template <typename> class ImageCacheState;
-}
-
-template <typename ImageCtxT>
-class WriteLogCache {
-public:
-  typedef io::Extent Extent;
-  typedef io::Extents Extents;
-
-  WriteLogCache(ImageCtxT &image_ctx, librbd::cache::pwl::ImageCacheState<ImageCtxT>* cache_state);
-  ~WriteLogCache();
-  WriteLogCache(const WriteLogCache&) = delete;
-  WriteLogCache &operator=(const WriteLogCache&) = delete;
-
-  /// client AIO methods
-  void aio_read(Extents&& image_extents, ceph::bufferlist *bl,
-                int fadvise_flags, Context *on_finish) ;
-  void aio_write(Extents&& image_extents, ceph::bufferlist&& bl,
-                 int fadvise_flags, Context *on_finish) ;
-  void aio_discard(uint64_t offset, uint64_t length,
-                   uint32_t discard_granularity_bytes,
-                   Context *on_finish) ;
-  void aio_flush(io::FlushSource flush_source, Context *on_finish) ;
-  void aio_writesame(uint64_t offset, uint64_t length,
-                     ceph::bufferlist&& bl,
-                     int fadvise_flags, Context *on_finish) ;
-  void aio_compare_and_write(Extents&& image_extents,
-                             ceph::bufferlist&& cmp_bl, ceph::bufferlist&& bl,
-                             uint64_t *mismatch_offset,int fadvise_flags,
-                             Context *on_finish) ;
-
-  /// internal state methods
-  void init(Context *on_finish) ;
-  void shut_down(Context *on_finish) ;
-  void invalidate(Context *on_finish) ;
-  void flush(Context *on_finish) ;
-
-  librbd::cache::pwl::AbstractWriteLog<ImageCtxT> *m_write_log;
-};
-
-} // namespace cache
-} // namespace librbd
-
-extern template class librbd::cache::WriteLogCache<librbd::ImageCtx>;
-
-#endif // CEPH_LIBRBD_CACHE_WRITE_LOG_CACHE
diff --git a/src/librbd/cache/WriteLogImageDispatch.cc b/src/librbd/cache/WriteLogImageDispatch.cc
new file mode 100644 (file)
index 0000000..254eb43
--- /dev/null
@@ -0,0 +1,232 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "common/dout.h"
+#include "librbd/cache/pwl/AbstractWriteLog.h"
+#include "librbd/cache/pwl/ShutdownRequest.h"
+#include "librbd/cache/WriteLogImageDispatch.h"
+#include "librbd/ImageCtx.h"
+#include "librbd/io/AioCompletion.h"
+#include "librbd/io/Utils.h"
+
+#define dout_subsys ceph_subsys_rbd_pwl
+#undef dout_prefix
+#define dout_prefix *_dout << "librbd::cache::WriteLogImageDispatch: " << this << " " \
+                           << __func__ << ": "
+
+namespace librbd {
+namespace cache {
+
+namespace {
+
+void start_in_flight_io(io::AioCompletion* aio_comp) {
+  if (!aio_comp->async_op.started()) {
+    aio_comp->start_op();
+  }
+}
+
+} // anonymous namespace
+
+template <typename I>
+void WriteLogImageDispatch<I>::shut_down(Context* on_finish) {
+  ceph_assert(m_image_cache != nullptr);
+
+  Context* ctx = new LambdaContext(
+      [this, on_finish](int r) {
+        m_image_cache = nullptr;
+       on_finish->complete(r);
+      });
+
+  cache::pwl::ShutdownRequest<I> *req = cache::pwl::ShutdownRequest<I>::create(
+    *m_image_ctx, m_image_cache, ctx);
+  req->send();
+}
+
+template <typename I>
+bool WriteLogImageDispatch<I>::read(
+    io::AioCompletion* aio_comp, io::Extents &&image_extents,
+    io::ReadResult &&read_result, IOContext io_context,
+    int op_flags, int read_flags,
+    const ZTracer::Trace &parent_trace, uint64_t tid,
+    std::atomic<uint32_t>* image_dispatch_flags,
+    io::DispatchResult* dispatch_result,
+    Context** on_finish, Context* on_dispatched) {
+  auto cct = m_image_ctx->cct;
+  ldout(cct, 20) << "image_extents=" << image_extents << dendl;
+
+  *dispatch_result = io::DISPATCH_RESULT_COMPLETE;
+  if (preprocess_length(aio_comp, image_extents)) {
+    return true;
+  }
+
+  start_in_flight_io(aio_comp);
+
+  aio_comp->set_request_count(1);
+  aio_comp->read_result = std::move(read_result);
+  uint64_t length = io::util::extents_length(image_extents);
+  aio_comp->read_result.set_clip_length(length);
+
+  auto *req_comp = new io::ReadResult::C_ImageReadRequest(
+    aio_comp, image_extents);
+
+  m_image_cache->read(std::move(image_extents),
+                      &req_comp->bl, op_flags,
+                      req_comp);
+  return true;
+}
+
+template <typename I>
+bool WriteLogImageDispatch<I>::write(
+    io::AioCompletion* aio_comp, io::Extents &&image_extents, bufferlist &&bl,
+    IOContext io_context, int op_flags, const ZTracer::Trace &parent_trace,
+    uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
+    io::DispatchResult* dispatch_result,
+    Context** on_finish, Context* on_dispatched) {
+  auto cct = m_image_ctx->cct;
+  ldout(cct, 20) << "image_extents=" << image_extents << dendl;
+
+  *dispatch_result = io::DISPATCH_RESULT_COMPLETE;
+  if (preprocess_length(aio_comp, image_extents)) {
+    return true;
+  }
+
+  start_in_flight_io(aio_comp);
+
+  aio_comp->set_request_count(1);
+  io::C_AioRequest *req_comp = new io::C_AioRequest(aio_comp);
+  m_image_cache->write(std::move(image_extents),
+                       std::move(bl), op_flags, req_comp);
+  return true;
+}
+
+template <typename I>
+bool WriteLogImageDispatch<I>::discard(
+    io::AioCompletion* aio_comp, io::Extents &&image_extents,
+    uint32_t discard_granularity_bytes, IOContext io_context,
+    const ZTracer::Trace &parent_trace,
+    uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
+    io::DispatchResult* dispatch_result,
+    Context** on_finish, Context* on_dispatched) {
+  auto cct = m_image_ctx->cct;
+  ldout(cct, 20) << "image_extents=" << image_extents << dendl;
+
+  *dispatch_result = io::DISPATCH_RESULT_COMPLETE;
+  if (preprocess_length(aio_comp, image_extents)) {
+    return true;
+  }
+
+  start_in_flight_io(aio_comp);
+
+  aio_comp->set_request_count(image_extents.size());
+  for (auto &extent : image_extents) {
+    io::C_AioRequest *req_comp = new io::C_AioRequest(aio_comp);
+    m_image_cache->discard(extent.first, extent.second,
+                           discard_granularity_bytes,
+                           req_comp);
+  }
+  return true;
+}
+
+template <typename I>
+bool WriteLogImageDispatch<I>::write_same(
+    io::AioCompletion* aio_comp, io::Extents &&image_extents,
+    bufferlist &&bl, IOContext io_context,
+    int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
+    std::atomic<uint32_t>* image_dispatch_flags,
+    io::DispatchResult* dispatch_result,
+    Context** on_finish, Context* on_dispatched) {
+  auto cct = m_image_ctx->cct;
+  ldout(cct, 20) << "image_extents=" << image_extents << dendl;
+
+  *dispatch_result = io::DISPATCH_RESULT_COMPLETE;
+  if (preprocess_length(aio_comp, image_extents)) {
+    return true;
+  }
+
+  start_in_flight_io(aio_comp);
+
+  aio_comp->set_request_count(image_extents.size());
+  for (auto &extent : image_extents) {
+    io::C_AioRequest *req_comp = new io::C_AioRequest(aio_comp);
+    m_image_cache->writesame(extent.first, extent.second,
+                             std::move(bl), op_flags,
+                             req_comp);
+  }
+  return true;
+}
+
+template <typename I>
+bool WriteLogImageDispatch<I>::compare_and_write(
+    io::AioCompletion* aio_comp, io::Extents &&image_extents, bufferlist &&cmp_bl,
+    bufferlist &&bl, uint64_t *mismatch_offset, IOContext io_context,
+    int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
+    std::atomic<uint32_t>* image_dispatch_flags,
+    io::DispatchResult* dispatch_result,
+    Context** on_finish, Context* on_dispatched) {
+  auto cct = m_image_ctx->cct;
+  ldout(cct, 20) << "image_extents=" << image_extents << dendl;
+
+  *dispatch_result = io::DISPATCH_RESULT_COMPLETE;
+  if (preprocess_length(aio_comp, image_extents)) {
+    return true;
+  }
+
+  start_in_flight_io(aio_comp);
+
+  aio_comp->set_request_count(1);
+  io::C_AioRequest *req_comp = new io::C_AioRequest(aio_comp);
+  m_image_cache->compare_and_write(
+    std::move(image_extents), std::move(cmp_bl), std::move(bl),
+    mismatch_offset, op_flags, req_comp);
+  return true;
+}
+
+template <typename I>
+bool WriteLogImageDispatch<I>::flush(
+    io::AioCompletion* aio_comp, io::FlushSource flush_source,
+    const ZTracer::Trace &parent_trace, uint64_t tid,
+    std::atomic<uint32_t>* image_dispatch_flags,
+    io::DispatchResult* dispatch_result,
+    Context** on_finish, Context* on_dispatched) {
+  auto cct = m_image_ctx->cct;
+  ldout(cct, 20) << "tid=" << tid << dendl;
+
+  start_in_flight_io(aio_comp);
+
+  *dispatch_result = io::DISPATCH_RESULT_COMPLETE;
+
+  aio_comp->set_request_count(1);
+  io::C_AioRequest *req_comp = new io::C_AioRequest(aio_comp);
+  m_image_cache->flush(flush_source, req_comp);
+
+  return true;
+}
+
+template <typename I>
+bool WriteLogImageDispatch<I>::list_snaps(
+    io::AioCompletion* aio_comp, io::Extents&& image_extents,
+    io::SnapIds&& snap_ids,
+    int list_snaps_flags, io::SnapshotDelta* snapshot_delta,
+    const ZTracer::Trace &parent_trace, uint64_t tid,
+    std::atomic<uint32_t>* image_dispatch_flags,
+    io::DispatchResult* dispatch_result, Context** on_finish,
+    Context* on_dispatched) {
+  return false;
+}
+
+
+template <typename I>
+bool WriteLogImageDispatch<I>::preprocess_length(
+    io::AioCompletion* aio_comp, io::Extents &image_extents) const {
+  auto total_bytes = io::util::extents_length(image_extents);
+  if (total_bytes == 0) {
+    aio_comp->set_request_count(0);
+    return true;
+  }
+  return false;
+}
+
+} // namespace io
+} // namespace librbd
+
+template class librbd::cache::WriteLogImageDispatch<librbd::ImageCtx>;
diff --git a/src/librbd/cache/WriteLogImageDispatch.h b/src/librbd/cache/WriteLogImageDispatch.h
new file mode 100644 (file)
index 0000000..86d3f70
--- /dev/null
@@ -0,0 +1,102 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_LIBRBD_WRITELOG_IMAGE_DISPATCH_H
+#define CEPH_LIBRBD_WRITELOG_IMAGE_DISPATCH_H
+
+#include "librbd/io/ImageDispatchInterface.h"
+#include "include/int_types.h"
+#include "include/buffer.h"
+#include "common/zipkin_trace.h"
+#include "librbd/io/ReadResult.h"
+#include "librbd/io/Types.h"
+
+struct Context;
+
+namespace librbd {
+
+struct ImageCtx;
+
+namespace cache {
+
+namespace pwl { template <typename> class AbstractWriteLog; }
+
+template <typename ImageCtxT>
+class WriteLogImageDispatch : public io::ImageDispatchInterface {
+public:
+  WriteLogImageDispatch(ImageCtxT* image_ctx,
+                        pwl::AbstractWriteLog<ImageCtx> *image_cache) :
+    m_image_ctx(image_ctx), m_image_cache(image_cache) {
+  }
+
+  io::ImageDispatchLayer get_dispatch_layer() const override {
+    return io::IMAGE_DISPATCH_LAYER_WRITEBACK_CACHE;
+  }
+
+  void shut_down(Context* on_finish) override;
+
+  bool read(
+      io::AioCompletion* aio_comp, io::Extents &&image_extents,
+      io::ReadResult &&read_result, IOContext io_context,
+      int op_flags, int read_flags,
+      const ZTracer::Trace &parent_trace, uint64_t tid,
+      std::atomic<uint32_t>* image_dispatch_flags,
+      io::DispatchResult* dispatch_result, Context** on_finish,
+      Context* on_dispatched) override;
+    bool write(
+      io::AioCompletion* aio_comp, io::Extents &&image_extents, bufferlist &&bl,
+      IOContext io_context, int op_flags, const ZTracer::Trace &parent_trace,
+      uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
+      io::DispatchResult* dispatch_result,
+      Context** on_finish, Context* on_dispatched) override;
+  bool discard(
+      io::AioCompletion* aio_comp, io::Extents &&image_extents,
+      uint32_t discard_granularity_bytes, IOContext io_context,
+      const ZTracer::Trace &parent_trace, uint64_t tid,
+      std::atomic<uint32_t>* image_dispatch_flags,
+      io::DispatchResult* dispatch_result,
+      Context** on_finish, Context* on_dispatched) override;
+  bool write_same(
+      io::AioCompletion* aio_comp, io::Extents &&image_extents, bufferlist &&bl,
+      IOContext io_context, int op_flags, const ZTracer::Trace &parent_trace,
+      uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
+      io::DispatchResult* dispatch_result,
+      Context** on_finish, Context* on_dispatched) override;
+  bool compare_and_write(
+      io::AioCompletion* aio_comp, io::Extents &&image_extents,
+      bufferlist &&cmp_bl,
+      bufferlist &&bl, uint64_t *mismatch_offset,
+      IOContext io_context, int op_flags,
+      const ZTracer::Trace &parent_trace, uint64_t tid,
+      std::atomic<uint32_t>* image_dispatch_flags,
+      io::DispatchResult* dispatch_result,
+      Context** on_finish, Context* on_dispatched) override;
+  bool flush(
+      io::AioCompletion* aio_comp, io::FlushSource flush_source,
+      const ZTracer::Trace &parent_trace, uint64_t tid,
+      std::atomic<uint32_t>* image_dispatch_flags,
+      io::DispatchResult* dispatch_result,
+      Context** on_finish, Context* on_dispatched) override;
+  bool list_snaps(
+    io::AioCompletion* aio_comp, io::Extents&& image_extents,
+    io::SnapIds&& snap_ids, int list_snaps_flags,
+    io::SnapshotDelta* snapshot_delta,
+    const ZTracer::Trace &parent_trace, uint64_t tid,
+    std::atomic<uint32_t>* image_dispatch_flags,
+    io::DispatchResult* dispatch_result, Context** on_finish,
+    Context* on_dispatched) override;
+
+private:
+  ImageCtxT* m_image_ctx;
+  pwl::AbstractWriteLog<ImageCtx> *m_image_cache;
+
+  bool preprocess_length(
+      io::AioCompletion* aio_comp, io::Extents &image_extents) const;
+};
+
+} // namespace cache
+} // namespace librbd
+
+extern template class librbd::cache::WriteLogImageDispatch<librbd::ImageCtx>;
+
+#endif // CEPH_LIBRBD_WRITELOG_IMAGE_DISPATCH_H
index 5796e1b9df389346fbda77e93b6bacca095a6220..c6787027051388b791ea97419cd08f7705247d96 100644 (file)
@@ -7,7 +7,6 @@
 #include "common/RWLock.h"
 #include "common/WorkQueue.h"
 #include "common/AsyncOpTracker.h"
-#include "librbd/cache/ImageCache.h"
 #include "librbd/cache/ImageWriteback.h"
 #include "librbd/Utils.h"
 #include "librbd/BlockGuard.h"
@@ -15,7 +14,6 @@
 #include "librbd/cache/pwl/LogOperation.h"
 #include "librbd/cache/pwl/Request.h"
 #include "librbd/cache/pwl/LogMap.h"
-#include "librbd/cache/pwl/Types.h"
 #include <functional>
 #include <list>
 
diff --git a/src/librbd/cache/pwl/ImageDispatch.cc b/src/librbd/cache/pwl/ImageDispatch.cc
deleted file mode 100644 (file)
index 1473541..0000000
+++ /dev/null
@@ -1,234 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-
-#include "common/dout.h"
-#include "librbd/cache/pwl/ImageDispatch.h"
-#include "librbd/cache/pwl/ShutdownRequest.h"
-#include "librbd/cache/WriteLogCache.h"
-#include "librbd/ImageCtx.h"
-#include "librbd/io/AioCompletion.h"
-#include "librbd/io/Utils.h"
-
-#define dout_subsys ceph_subsys_rbd_pwl
-#undef dout_prefix
-#define dout_prefix *_dout << "librbd::cache::pwl::ImageDispatch: " << this << " " \
-                           << __func__ << ": "
-
-namespace librbd {
-namespace cache {
-namespace pwl{
-
-namespace {
-
-void start_in_flight_io(io::AioCompletion* aio_comp) {
-  if (!aio_comp->async_op.started()) {
-    aio_comp->start_op();
-  }
-}
-
-} // anonymous namespace
-
-template <typename I>
-void ImageDispatch<I>::shut_down(Context* on_finish) {
-  ceph_assert(m_image_cache != nullptr);
-
-  Context* ctx = new LambdaContext(
-      [this, on_finish](int r) {
-        m_image_cache = nullptr;
-       on_finish->complete(r);
-      });
-
-  cache::pwl::ShutdownRequest<I> *req = cache::pwl::ShutdownRequest<I>::create(
-    *m_image_ctx, m_image_cache, ctx);
-  req->send();
-}
-
-template <typename I>
-bool ImageDispatch<I>::read(
-    io::AioCompletion* aio_comp, io::Extents &&image_extents,
-    io::ReadResult &&read_result, IOContext io_context,
-    int op_flags, int read_flags,
-    const ZTracer::Trace &parent_trace, uint64_t tid,
-    std::atomic<uint32_t>* image_dispatch_flags,
-    io::DispatchResult* dispatch_result,
-    Context** on_finish, Context* on_dispatched) {
-  auto cct = m_image_ctx->cct;
-  ldout(cct, 20) << "image_extents=" << image_extents << dendl;
-
-  *dispatch_result = io::DISPATCH_RESULT_COMPLETE;
-  if (preprocess_length(aio_comp, image_extents)) {
-    return true;
-  }
-
-  start_in_flight_io(aio_comp);
-
-  aio_comp->set_request_count(1);
-  aio_comp->read_result = std::move(read_result);
-  uint64_t length = io::util::extents_length(image_extents);
-  aio_comp->read_result.set_clip_length(length);
-
-  auto *req_comp = new io::ReadResult::C_ImageReadRequest(
-    aio_comp, image_extents);
-
-  m_image_cache->aio_read(std::move(image_extents),
-                          &req_comp->bl, op_flags,
-                          req_comp);
-  return true;
-}
-
-template <typename I>
-bool ImageDispatch<I>::write(
-    io::AioCompletion* aio_comp, io::Extents &&image_extents, bufferlist &&bl,
-    IOContext io_context, int op_flags, const ZTracer::Trace &parent_trace,
-    uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
-    io::DispatchResult* dispatch_result,
-    Context** on_finish, Context* on_dispatched) {
-  auto cct = m_image_ctx->cct;
-  ldout(cct, 20) << "image_extents=" << image_extents << dendl;
-
-  *dispatch_result = io::DISPATCH_RESULT_COMPLETE;
-  if (preprocess_length(aio_comp, image_extents)) {
-    return true;
-  }
-
-  start_in_flight_io(aio_comp);
-
-  aio_comp->set_request_count(1);
-  io::C_AioRequest *req_comp = new io::C_AioRequest(aio_comp);
-  m_image_cache->aio_write(std::move(image_extents),
-                           std::move(bl), op_flags, req_comp);
-  return true;
-}
-
-template <typename I>
-bool ImageDispatch<I>::discard(
-    io::AioCompletion* aio_comp, io::Extents &&image_extents,
-    uint32_t discard_granularity_bytes, IOContext io_context,
-    const ZTracer::Trace &parent_trace,
-    uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
-    io::DispatchResult* dispatch_result,
-    Context** on_finish, Context* on_dispatched) {
-  auto cct = m_image_ctx->cct;
-  ldout(cct, 20) << "image_extents=" << image_extents << dendl;
-
-  *dispatch_result = io::DISPATCH_RESULT_COMPLETE;
-  if (preprocess_length(aio_comp, image_extents)) {
-    return true;
-  }
-
-  start_in_flight_io(aio_comp);
-
-  aio_comp->set_request_count(image_extents.size());
-  for (auto &extent : image_extents) {
-    io::C_AioRequest *req_comp = new io::C_AioRequest(aio_comp);
-    m_image_cache->aio_discard(extent.first, extent.second,
-                               discard_granularity_bytes,
-                               req_comp);
-  }
-  return true;
-}
-
-template <typename I>
-bool ImageDispatch<I>::write_same(
-    io::AioCompletion* aio_comp, io::Extents &&image_extents,
-    bufferlist &&bl, IOContext io_context,
-    int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
-    std::atomic<uint32_t>* image_dispatch_flags,
-    io::DispatchResult* dispatch_result,
-    Context** on_finish, Context* on_dispatched) {
-  auto cct = m_image_ctx->cct;
-  ldout(cct, 20) << "image_extents=" << image_extents << dendl;
-
-  *dispatch_result = io::DISPATCH_RESULT_COMPLETE;
-  if (preprocess_length(aio_comp, image_extents)) {
-    return true;
-  }
-
-  start_in_flight_io(aio_comp);
-
-  aio_comp->set_request_count(image_extents.size());
-  for (auto &extent : image_extents) {
-    io::C_AioRequest *req_comp = new io::C_AioRequest(aio_comp);
-    m_image_cache->aio_writesame(extent.first, extent.second,
-                                 std::move(bl), op_flags,
-                                 req_comp);
-  }
-  return true;
-}
-
-template <typename I>
-bool ImageDispatch<I>::compare_and_write(
-    io::AioCompletion* aio_comp, io::Extents &&image_extents, bufferlist &&cmp_bl,
-    bufferlist &&bl, uint64_t *mismatch_offset, IOContext io_context,
-    int op_flags, const ZTracer::Trace &parent_trace, uint64_t tid,
-    std::atomic<uint32_t>* image_dispatch_flags,
-    io::DispatchResult* dispatch_result,
-    Context** on_finish, Context* on_dispatched) {
-  auto cct = m_image_ctx->cct;
-  ldout(cct, 20) << "image_extents=" << image_extents << dendl;
-
-  *dispatch_result = io::DISPATCH_RESULT_COMPLETE;
-  if (preprocess_length(aio_comp, image_extents)) {
-    return true;
-  }
-
-  start_in_flight_io(aio_comp);
-
-  aio_comp->set_request_count(1);
-  io::C_AioRequest *req_comp = new io::C_AioRequest(aio_comp);
-  m_image_cache->aio_compare_and_write(
-    std::move(image_extents), std::move(cmp_bl), std::move(bl),
-    mismatch_offset, op_flags, req_comp);
-  return true;
-}
-
-template <typename I>
-bool ImageDispatch<I>::flush(
-    io::AioCompletion* aio_comp, io::FlushSource flush_source,
-    const ZTracer::Trace &parent_trace, uint64_t tid,
-    std::atomic<uint32_t>* image_dispatch_flags,
-    io::DispatchResult* dispatch_result,
-    Context** on_finish, Context* on_dispatched) {
-  auto cct = m_image_ctx->cct;
-  ldout(cct, 20) << "tid=" << tid << dendl;
-
-  start_in_flight_io(aio_comp);
-
-  *dispatch_result = io::DISPATCH_RESULT_COMPLETE;
-
-  aio_comp->set_request_count(1);
-  io::C_AioRequest *req_comp = new io::C_AioRequest(aio_comp);
-  m_image_cache->aio_flush(flush_source, req_comp);
-
-  return true;
-}
-
-template <typename I>
-bool ImageDispatch<I>::list_snaps(
-    io::AioCompletion* aio_comp, io::Extents&& image_extents,
-    io::SnapIds&& snap_ids,
-    int list_snaps_flags, io::SnapshotDelta* snapshot_delta,
-    const ZTracer::Trace &parent_trace, uint64_t tid,
-    std::atomic<uint32_t>* image_dispatch_flags,
-    io::DispatchResult* dispatch_result, Context** on_finish,
-    Context* on_dispatched) {
-  ceph_abort();
-}
-
-
-template <typename I>
-bool ImageDispatch<I>::preprocess_length(
-    io::AioCompletion* aio_comp, io::Extents &image_extents) const {
-  auto total_bytes = io::util::extents_length(image_extents);
-  if (total_bytes == 0) {
-    aio_comp->set_request_count(0);
-    return true;
-  }
-  return false;
-}
-
-} // namespace pwl
-} // namespace io
-} // namespace librbd
-
-template class librbd::cache::pwl::ImageDispatch<librbd::ImageCtx>;
diff --git a/src/librbd/cache/pwl/ImageDispatch.h b/src/librbd/cache/pwl/ImageDispatch.h
deleted file mode 100644 (file)
index 322aba4..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-
-#ifndef CEPH_LIBRBD_PWL_IMAGE_DISPATCH_H
-#define CEPH_LIBRBD_PWL_IMAGE_DISPATCH_H
-
-#include "librbd/io/ImageDispatchInterface.h"
-#include "include/int_types.h"
-#include "include/buffer.h"
-#include "common/zipkin_trace.h"
-#include "librbd/io/ReadResult.h"
-#include "librbd/io/Types.h"
-
-struct Context;
-
-namespace librbd {
-
-struct ImageCtx;
-
-namespace cache {
-
-template<typename>
-class WriteLogCache;
-
-namespace pwl {
-
-template <typename ImageCtxT>
-class ImageDispatch : public io::ImageDispatchInterface {
-public:
-  ImageDispatch(ImageCtxT* image_ctx,
-                   WriteLogCache<ImageCtx> *image_cache) :
-    m_image_ctx(image_ctx), m_image_cache(image_cache) {
-  }
-
-  io::ImageDispatchLayer get_dispatch_layer() const override {
-    return io::IMAGE_DISPATCH_LAYER_WRITEBACK_CACHE;
-  }
-
-  void shut_down(Context* on_finish) override;
-
-  bool read(
-      io::AioCompletion* aio_comp, io::Extents &&image_extents,
-      io::ReadResult &&read_result, IOContext io_context,
-      int op_flags, int read_flags,
-      const ZTracer::Trace &parent_trace, uint64_t tid,
-      std::atomic<uint32_t>* image_dispatch_flags,
-      io::DispatchResult* dispatch_result, Context** on_finish,
-      Context* on_dispatched) override;
-    bool write(
-      io::AioCompletion* aio_comp, io::Extents &&image_extents, bufferlist &&bl,
-      IOContext io_context, int op_flags, const ZTracer::Trace &parent_trace,
-      uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
-      io::DispatchResult* dispatch_result,
-      Context** on_finish, Context* on_dispatched) override;
-  bool discard(
-      io::AioCompletion* aio_comp, io::Extents &&image_extents,
-      uint32_t discard_granularity_bytes, IOContext io_context,
-      const ZTracer::Trace &parent_trace, uint64_t tid,
-      std::atomic<uint32_t>* image_dispatch_flags,
-      io::DispatchResult* dispatch_result,
-      Context** on_finish, Context* on_dispatched) override;
-  bool write_same(
-      io::AioCompletion* aio_comp, io::Extents &&image_extents, bufferlist &&bl,
-      IOContext io_context, int op_flags, const ZTracer::Trace &parent_trace,
-      uint64_t tid, std::atomic<uint32_t>* image_dispatch_flags,
-      io::DispatchResult* dispatch_result,
-      Context** on_finish, Context* on_dispatched) override;
-  bool compare_and_write(
-      io::AioCompletion* aio_comp, io::Extents &&image_extents,
-      bufferlist &&cmp_bl,
-      bufferlist &&bl, uint64_t *mismatch_offset,
-      IOContext io_context, int op_flags,
-      const ZTracer::Trace &parent_trace, uint64_t tid,
-      std::atomic<uint32_t>* image_dispatch_flags,
-      io::DispatchResult* dispatch_result,
-      Context** on_finish, Context* on_dispatched) override;
-  bool flush(
-      io::AioCompletion* aio_comp, io::FlushSource flush_source,
-      const ZTracer::Trace &parent_trace, uint64_t tid,
-      std::atomic<uint32_t>* image_dispatch_flags,
-      io::DispatchResult* dispatch_result,
-      Context** on_finish, Context* on_dispatched) override;
-  bool list_snaps(
-    io::AioCompletion* aio_comp, io::Extents&& image_extents,
-    io::SnapIds&& snap_ids, int list_snaps_flags,
-    io::SnapshotDelta* snapshot_delta,
-    const ZTracer::Trace &parent_trace, uint64_t tid,
-    std::atomic<uint32_t>* image_dispatch_flags,
-    io::DispatchResult* dispatch_result, Context** on_finish,
-    Context* on_dispatched) override;
-
-private:
-  ImageCtxT* m_image_ctx;
-  cache::WriteLogCache<ImageCtx> *m_image_cache;
-
-  bool preprocess_length(
-      io::AioCompletion* aio_comp, io::Extents &image_extents) const;
-};
-
-} // namespace pwl
-} // namespace cache
-} // namespace librbd
-
-extern template class librbd::cache::pwl::ImageDispatch<librbd::ImageCtx>;
-
-#endif // CEPH_LIBRBD_PWL_IMAGE_DISPATCH_H
index 1df48cdf50c64b702a80a042ce72880fcd61a544..1f696d518bd33aa3d765090b4fc35e99d81abde5 100644 (file)
@@ -10,8 +10,8 @@
 
 #if defined(WITH_RBD_RWL)
 #include "librbd/cache/pwl/ImageCacheState.h"
-#include "librbd/cache/pwl/ImageDispatch.h"
-#include "librbd/cache/WriteLogCache.h"
+#include "librbd/cache/pwl/ReplicatedWriteLog.h"
+#include "librbd/cache/WriteLogImageDispatch.h"
 #endif // WITH_RBD_RWL
 
 #include "librbd/cache/Utils.h"
@@ -78,8 +78,8 @@ void InitRequest<I>::get_image_cache_state() {
   switch(cache_type) {
     case cache::IMAGE_CACHE_TYPE_RWL:
       m_image_cache =
-        new librbd::cache::WriteLogCache<I>(m_image_ctx,
-                                            cache_state);
+        new librbd::cache::pwl::ReplicatedWriteLog<I>(m_image_ctx,
+                                                      cache_state);
       break;
     default:
       delete cache_state;
@@ -161,7 +161,7 @@ void InitRequest<I>::handle_set_feature_bit(int r) {
   }
 
   // Register RWL dispatch
-  auto image_dispatch = new cache::pwl::ImageDispatch<I>(&m_image_ctx, m_image_cache);
+  auto image_dispatch = new cache::WriteLogImageDispatch<I>(&m_image_ctx, m_image_cache);
 
   m_image_ctx.io_image_dispatcher->register_dispatch(image_dispatch);
 
index 8030e17104c84d98fcb6e736f485bdc70dc11466..b1bda3eda1cac94e65c4143919fcdafe7e81d15e 100644 (file)
@@ -14,11 +14,11 @@ namespace io { class ImageDispatchInterface; }
 
 namespace cache {
 
-template<typename>
-class WriteLogCache;
-
 namespace pwl {
 
+template<typename>
+class AbstractWriteLog;
+
 template<typename>
 class ImageCacheState;
 
@@ -56,7 +56,7 @@ private:
   InitRequest(ImageCtxT &image_ctx, Context *on_finish);
 
   ImageCtxT &m_image_ctx;
-  cache::WriteLogCache<ImageCtx> *m_image_cache;
+  AbstractWriteLog<ImageCtxT> *m_image_cache;
   Context *m_on_finish;
 
   int m_error_result;
index 8af1cc2707d1cea0a13b536435942a4026d9cb5e..bb3c9520984e103d9e28a14da8b1dfa2362e29c0 100644 (file)
@@ -2,7 +2,6 @@
 // vim: ts=8 sw=2 smarttab
 
 #include "librbd/cache/pwl/ShutdownRequest.h"
-#include "librbd/cache/WriteLogCache.h"
 #include "librbd/ImageCtx.h"
 #include "librbd/Utils.h"
 #include "common/dout.h"
@@ -11,6 +10,9 @@
 #include "librbd/asio/ContextWQ.h"
 #include "librbd/cache/Types.h"
 
+#if defined(WITH_RBD_RWL)
+#include "librbd/cache/pwl/AbstractWriteLog.h"
+#endif // WITH_RBD_RWL
 
 #define dout_subsys ceph_subsys_rbd_pwl
 #undef dout_prefix
@@ -27,7 +29,7 @@ using librbd::util::create_context_callback;
 template <typename I>
 ShutdownRequest<I>* ShutdownRequest<I>::create(
     I &image_ctx,
-    cache::WriteLogCache<ImageCtx> *image_cache,
+    AbstractWriteLog<I> *image_cache,
     Context *on_finish) {
   return new ShutdownRequest(image_ctx, image_cache, on_finish);
 }
@@ -35,7 +37,7 @@ ShutdownRequest<I>* ShutdownRequest<I>::create(
 template <typename I>
 ShutdownRequest<I>::ShutdownRequest(
     I &image_ctx,
-    cache::WriteLogCache<ImageCtx> *image_cache,
+    AbstractWriteLog<I> *image_cache,
     Context *on_finish)
   : m_image_ctx(image_ctx),
     m_image_cache(image_cache),
@@ -45,9 +47,14 @@ ShutdownRequest<I>::ShutdownRequest(
 
 template <typename I>
 void ShutdownRequest<I>::send() {
+#if defined(WITH_RBD_RWL)
   send_shutdown_image_cache();
+#else
+  finish();
+#endif // WITH_RBD_RWL
 }
 
+#if defined(WITH_RBD_RWL)
 template <typename I>
 void ShutdownRequest<I>::send_shutdown_image_cache() {
   CephContext *cct = m_image_ctx.cct;
@@ -144,6 +151,8 @@ void ShutdownRequest<I>::handle_remove_image_cache_state(int r) {
   finish();
 }
 
+#endif // WITH_RBD_RWL
+
 template <typename I>
 void ShutdownRequest<I>::finish() {
   m_on_finish->complete(m_error_result);
index ec8da976b0b0510ad7767b83bacaaa885a88fd2d..2ed22f72782ca846442f53348c7ce717ade7baff 100644 (file)
@@ -12,11 +12,11 @@ class ImageCtx;
 
 namespace cache {
 
-template<typename>
-class WriteLogCache;
-
 namespace pwl {
 
+template<typename>
+class AbstractWriteLog;
+
 template<typename>
 class ImageCacheState;
 
@@ -25,7 +25,7 @@ class ShutdownRequest {
 public:
   static ShutdownRequest* create(
       ImageCtxT &image_ctx,
-      cache::WriteLogCache<ImageCtx> *image_cache,
+      AbstractWriteLog<ImageCtxT> *image_cache,
       Context *on_finish);
 
   void send();
@@ -55,11 +55,11 @@ private:
    */
 
   ShutdownRequest(ImageCtxT &image_ctx,
-    cache::WriteLogCache<ImageCtx> *image_cache,
+    AbstractWriteLog<ImageCtxT> *image_cache,
     Context *on_finish);
 
   ImageCtxT &m_image_ctx;
-  cache::WriteLogCache<ImageCtx> *m_image_cache;
+  AbstractWriteLog<ImageCtxT> *m_image_cache;
   Context *m_on_finish;
 
   int m_error_result;
index 83799eb5a245cafeca2fd131e082aba19d2997b5..d6b2990237f893fc73b7823b87befefb46f7816c 100644 (file)
@@ -5,7 +5,6 @@
 #include "common/AsyncOpTracker.h"
 #include "common/dout.h"
 #include "common/errno.h"
-#include "librbd/cache/pwl/ShutdownRequest.h"
 #include "librbd/ExclusiveLock.h"
 #include "librbd/ImageState.h"
 #include "librbd/ImageWatcher.h"
index 6027b28a207496db8a8f06395292c996a07f6ca2..5c650021e290889ab91b56056b33ddb828c2d362 100644 (file)
@@ -7,10 +7,10 @@
 #include "test/librbd/test_support.h"
 #include "test/librbd/mock/MockImageCtx.h"
 #include "include/rbd/librbd.hpp"
+#include "librbd/cache/pwl/AbstractWriteLog.h"
 #include "librbd/cache/pwl/ImageCacheState.h"
 #include "librbd/cache/pwl/Types.h"
 #include "librbd/cache/ImageWriteback.h"
-#include "librbd/cache/WriteLogCache.h"
 
 
 namespace librbd {
@@ -36,7 +36,6 @@ inline ImageCtx *get_image_ctx(MockImageCtx *image_ctx) {
 } // namespace util
 } // namespace librbd
 
-#include "librbd/cache/WriteLogCache.cc"
 #include "librbd/cache/pwl/AbstractWriteLog.cc"
 #include "librbd/cache/pwl/ReplicatedWriteLog.cc"
 
@@ -47,6 +46,7 @@ inline ImageCtx *get_image_ctx(MockImageCtx *image_ctx) {
 
 namespace librbd {
 namespace cache {
+namespace pwl {
 
 using ::testing::_;
 using ::testing::DoDefault;
@@ -54,7 +54,7 @@ using ::testing::InSequence;
 using ::testing::Invoke;
 
 struct TestMockCacheReplicatedWriteLog : public TestMockFixture {
-  typedef WriteLogCache<librbd::MockImageCtx> MockReplicatedWriteLog;
+  typedef librbd::cache::pwl::ReplicatedWriteLog<librbd::MockImageCtx> MockReplicatedWriteLog;
   typedef librbd::cache::pwl::ImageCacheState<librbd::MockImageCtx> MockImageCacheStateRWL;
 
   MockImageCacheStateRWL *get_cache_state(MockImageCtx& mock_image_ctx) {
@@ -192,7 +192,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, init_shutdown) {
   ASSERT_EQ(0, finish_ctx2.wait());
 }
 
-TEST_F(TestMockCacheReplicatedWriteLog, aio_write) {
+TEST_F(TestMockCacheReplicatedWriteLog, write) {
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
 
@@ -212,7 +212,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_write) {
   bufferlist bl;
   bl.append(std::string(4096, '1'));
   int fadvise_flags = 0;
-  rwl.aio_write(std::move(image_extents), std::move(bl), fadvise_flags, &finish_ctx2);
+  rwl.write(std::move(image_extents), std::move(bl), fadvise_flags, &finish_ctx2);
   ASSERT_EQ(0, finish_ctx2.wait());
 
   MockContextRWL finish_ctx3;
@@ -242,7 +242,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, flush) {
   bl.append(std::string(4096, '1'));
   bufferlist bl_copy = bl;
   int fadvise_flags = 0;
-  rwl.aio_write(std::move(image_extents), std::move(bl), fadvise_flags, &finish_ctx2);
+  rwl.write(std::move(image_extents), std::move(bl), fadvise_flags, &finish_ctx2);
   ASSERT_EQ(0, finish_ctx2.wait());
 
   MockContextRWL finish_ctx_flush;
@@ -257,7 +257,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, flush) {
   ASSERT_EQ(0, finish_ctx3.wait());
 }
 
-TEST_F(TestMockCacheReplicatedWriteLog, aio_flush_source_shutdown) {
+TEST_F(TestMockCacheReplicatedWriteLog, flush_source_shutdown) {
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
 
@@ -277,12 +277,12 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_flush_source_shutdown) {
   bufferlist bl;
   bl.append(std::string(4096, '1'));
   int fadvise_flags = 0;
-  rwl.aio_write(std::move(image_extents), std::move(bl), fadvise_flags, &finish_ctx2);
+  rwl.write(std::move(image_extents), std::move(bl), fadvise_flags, &finish_ctx2);
   ASSERT_EQ(0, finish_ctx2.wait());
 
   MockContextRWL finish_ctx_flush;
   expect_context_complete(finish_ctx_flush, 0);
-  rwl.aio_flush(io::FLUSH_SOURCE_SHUTDOWN, &finish_ctx_flush);
+  rwl.flush(io::FLUSH_SOURCE_SHUTDOWN, &finish_ctx_flush);
   ASSERT_EQ(0, finish_ctx_flush.wait());
 
   MockContextRWL finish_ctx3;
@@ -291,7 +291,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_flush_source_shutdown) {
   ASSERT_EQ(0, finish_ctx3.wait());
 }
 
-TEST_F(TestMockCacheReplicatedWriteLog, aio_flush_source_internal) {
+TEST_F(TestMockCacheReplicatedWriteLog, flush_source_internal) {
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
 
@@ -311,12 +311,12 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_flush_source_internal) {
   bufferlist bl;
   bl.append(std::string(4096, '1'));
   int fadvise_flags = 0;
-  rwl.aio_write(std::move(image_extents), std::move(bl), fadvise_flags, &finish_ctx2);
+  rwl.write(std::move(image_extents), std::move(bl), fadvise_flags, &finish_ctx2);
   ASSERT_EQ(0, finish_ctx2.wait());
 
   MockContextRWL finish_ctx_flush;
   expect_context_complete(finish_ctx_flush, 0);
-  rwl.aio_flush(io::FLUSH_SOURCE_INTERNAL, &finish_ctx_flush);
+  rwl.flush(io::FLUSH_SOURCE_INTERNAL, &finish_ctx_flush);
   ASSERT_EQ(0, finish_ctx_flush.wait());
 
   MockContextRWL finish_ctx3;
@@ -325,7 +325,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_flush_source_internal) {
   ASSERT_EQ(0, finish_ctx3.wait());
 }
 
-TEST_F(TestMockCacheReplicatedWriteLog, aio_flush_source_user) {
+TEST_F(TestMockCacheReplicatedWriteLog, flush_source_user) {
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
 
@@ -345,13 +345,13 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_flush_source_user) {
   bufferlist bl;
   bl.append(std::string(4096, '1'));
   int fadvise_flags = 0;
-  rwl.aio_write(std::move(image_extents), std::move(bl), fadvise_flags, &finish_ctx2);
+  rwl.write(std::move(image_extents), std::move(bl), fadvise_flags, &finish_ctx2);
   ASSERT_EQ(0, finish_ctx2.wait());
 
   usleep(10000);
   MockContextRWL finish_ctx_flush;
   expect_context_complete(finish_ctx_flush, 0);
-  rwl.aio_flush(io::FLUSH_SOURCE_USER, &finish_ctx_flush);
+  rwl.flush(io::FLUSH_SOURCE_USER, &finish_ctx_flush);
   ASSERT_EQ(0, finish_ctx_flush.wait());
 
   MockContextRWL finish_ctx3;
@@ -360,7 +360,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_flush_source_user) {
   ASSERT_EQ(0, finish_ctx3.wait());
 }
 
-TEST_F(TestMockCacheReplicatedWriteLog, aio_read_hit_rwl_cache) {
+TEST_F(TestMockCacheReplicatedWriteLog, read_hit_rwl_cache) {
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
 
@@ -381,14 +381,14 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_read_hit_rwl_cache) {
   bl.append(std::string(4096, '1'));
   bufferlist bl_copy = bl;
   int fadvise_flags = 0;
-  rwl.aio_write(std::move(image_extents), std::move(bl), fadvise_flags, &finish_ctx2);
+  rwl.write(std::move(image_extents), std::move(bl), fadvise_flags, &finish_ctx2);
   ASSERT_EQ(0, finish_ctx2.wait());
 
   MockContextRWL finish_ctx_read;
   expect_context_complete(finish_ctx_read, 0);
   Extents image_extents_read{{0, 4096}};
   bufferlist read_bl;
-  rwl.aio_read(std::move(image_extents_read), &read_bl, fadvise_flags, &finish_ctx_read);
+  rwl.read(std::move(image_extents_read), &read_bl, fadvise_flags, &finish_ctx_read);
   ASSERT_EQ(0, finish_ctx_read.wait());
   ASSERT_EQ(4096, read_bl.length());
   ASSERT_TRUE(bl_copy.contents_equal(read_bl));
@@ -399,7 +399,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_read_hit_rwl_cache) {
   ASSERT_EQ(0, finish_ctx3.wait());
 }
 
-TEST_F(TestMockCacheReplicatedWriteLog, aio_read_hit_part_rwl_cache) {
+TEST_F(TestMockCacheReplicatedWriteLog, read_hit_part_rwl_cache) {
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
 
@@ -420,7 +420,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_read_hit_part_rwl_cache) {
   bl.append(std::string(4096, '1'));
   bufferlist bl_copy = bl;
   int fadvise_flags = 0;
-  rwl.aio_write(std::move(image_extents), std::move(bl), fadvise_flags, &finish_ctx2);
+  rwl.write(std::move(image_extents), std::move(bl), fadvise_flags, &finish_ctx2);
   ASSERT_EQ(0, finish_ctx2.wait());
 
   MockContextRWL finish_ctx_read;
@@ -429,7 +429,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_read_hit_part_rwl_cache) {
   bl_copy.begin(511).copy(4096-512, hit_bl);
   expect_context_complete(finish_ctx_read, 512);
   bufferlist read_bl;
-  rwl.aio_read(std::move(image_extents_read), &read_bl, fadvise_flags, &finish_ctx_read);
+  rwl.read(std::move(image_extents_read), &read_bl, fadvise_flags, &finish_ctx_read);
   ASSERT_EQ(512, finish_ctx_read.wait());
   ASSERT_EQ(4096, read_bl.length());
   bufferlist read_bl_hit;
@@ -442,7 +442,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_read_hit_part_rwl_cache) {
   ASSERT_EQ(0, finish_ctx3.wait());
 }
 
-TEST_F(TestMockCacheReplicatedWriteLog, aio_read_miss_rwl_cache) {
+TEST_F(TestMockCacheReplicatedWriteLog, read_miss_rwl_cache) {
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
 
@@ -462,7 +462,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_read_miss_rwl_cache) {
   bufferlist bl;
   bl.append(std::string(4096, '1'));
   int fadvise_flags = 0;
-  rwl.aio_write(std::move(image_extents), std::move(bl), fadvise_flags, &finish_ctx2);
+  rwl.write(std::move(image_extents), std::move(bl), fadvise_flags, &finish_ctx2);
   ASSERT_EQ(0, finish_ctx2.wait());
 
   MockContextRWL finish_ctx_read;
@@ -470,7 +470,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_read_miss_rwl_cache) {
   expect_context_complete(finish_ctx_read, 4096);
   bufferlist read_bl;
   ASSERT_EQ(0, read_bl.length());
-  rwl.aio_read(std::move(image_extents_read), &read_bl, fadvise_flags, &finish_ctx_read);
+  rwl.read(std::move(image_extents_read), &read_bl, fadvise_flags, &finish_ctx_read);
   ASSERT_EQ(4096, finish_ctx_read.wait());
   ASSERT_EQ(4096, read_bl.length());
 
@@ -480,7 +480,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_read_miss_rwl_cache) {
   ASSERT_EQ(0, finish_ctx3.wait());
 }
 
-TEST_F(TestMockCacheReplicatedWriteLog, aio_discard) {
+TEST_F(TestMockCacheReplicatedWriteLog, discard) {
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
 
@@ -501,18 +501,18 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_discard) {
   bl.append(std::string(4096, '1'));
   bufferlist bl_copy = bl;
   int fadvise_flags = 0;
-  rwl.aio_write(std::move(image_extents), std::move(bl), fadvise_flags, &finish_ctx2);
+  rwl.write(std::move(image_extents), std::move(bl), fadvise_flags, &finish_ctx2);
   ASSERT_EQ(0, finish_ctx2.wait());
 
   MockContextRWL finish_ctx_discard;
   expect_context_complete(finish_ctx_discard, 0);
-  rwl.aio_discard(0, 4096, 1, &finish_ctx_discard);
+  rwl.discard(0, 4096, 1, &finish_ctx_discard);
   ASSERT_EQ(0, finish_ctx_discard.wait());
 
   MockContextRWL finish_ctx_read;
   bufferlist read_bl;
   expect_context_complete(finish_ctx_read, 0);
-  rwl.aio_read({{0, 4096}}, &read_bl, fadvise_flags, &finish_ctx_read);
+  rwl.read({{0, 4096}}, &read_bl, fadvise_flags, &finish_ctx_read);
   ASSERT_EQ(0, finish_ctx_read.wait());
   ASSERT_EQ(4096, read_bl.length());
   ASSERT_TRUE(read_bl.is_zero());
@@ -524,7 +524,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_discard) {
   ASSERT_EQ(0, finish_ctx3.wait());
 }
 
-TEST_F(TestMockCacheReplicatedWriteLog, aio_writesame) {
+TEST_F(TestMockCacheReplicatedWriteLog, writesame) {
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
 
@@ -544,13 +544,13 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_writesame) {
   bl.append(std::string(512, '1'));
   test_bl.append(std::string(4096, '1'));
   int fadvise_flags = 0;
-  rwl.aio_writesame(0, 4096, std::move(bl), fadvise_flags, &finish_ctx2);
+  rwl.writesame(0, 4096, std::move(bl), fadvise_flags, &finish_ctx2);
   ASSERT_EQ(0, finish_ctx2.wait());
 
   MockContextRWL finish_ctx_read;
   bufferlist read_bl;
   expect_context_complete(finish_ctx_read, 0);
-  rwl.aio_read({{0, 4096}}, &read_bl, fadvise_flags, &finish_ctx_read);
+  rwl.read({{0, 4096}}, &read_bl, fadvise_flags, &finish_ctx_read);
   ASSERT_EQ(0, finish_ctx_read.wait());
   ASSERT_EQ(4096, read_bl.length());
   ASSERT_TRUE(test_bl.contents_equal(read_bl));
@@ -583,7 +583,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, invalidate) {
   bl.append(std::string(4096, '1'));
   bufferlist bl_copy = bl;
   int fadvise_flags = 0;
-  rwl.aio_write(std::move(image_extents), std::move(bl), fadvise_flags, &finish_ctx2);
+  rwl.write(std::move(image_extents), std::move(bl), fadvise_flags, &finish_ctx2);
   ASSERT_EQ(0, finish_ctx2.wait());
 
   MockContextRWL finish_ctx_invalidate;
@@ -598,7 +598,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, invalidate) {
   ASSERT_EQ(0, finish_ctx3.wait());
 }
 
-TEST_F(TestMockCacheReplicatedWriteLog, aio_compare_and_write_compare_matched) {
+TEST_F(TestMockCacheReplicatedWriteLog, compare_and_write_compare_matched) {
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
 
@@ -619,7 +619,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_compare_and_write_compare_matched) {
   bl1.append(std::string(4096, '1'));
   bufferlist com_bl = bl1;
   int fadvise_flags = 0;
-  rwl.aio_write(std::move(image_extents), std::move(bl1), fadvise_flags, &finish_ctx2);
+  rwl.write(std::move(image_extents), std::move(bl1), fadvise_flags, &finish_ctx2);
   ASSERT_EQ(0, finish_ctx2.wait());
 
   MockContextRWL finish_ctx_cw;
@@ -628,7 +628,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_compare_and_write_compare_matched) {
   bufferlist bl2_copy = bl2;
   uint64_t mismatch_offset = -1;
   expect_context_complete(finish_ctx_cw, 0);
-  rwl.aio_compare_and_write({{0, 4096}}, std::move(com_bl), std::move(bl2),
+  rwl.compare_and_write({{0, 4096}}, std::move(com_bl), std::move(bl2),
                             &mismatch_offset, fadvise_flags, &finish_ctx_cw);
   ASSERT_EQ(0, finish_ctx_cw.wait());
   ASSERT_EQ(0, mismatch_offset);
@@ -636,7 +636,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_compare_and_write_compare_matched) {
   MockContextRWL finish_ctx_read;
   bufferlist read_bl;
   expect_context_complete(finish_ctx_read, 0);
-  rwl.aio_read({{0, 4096}}, &read_bl, fadvise_flags, &finish_ctx_read);
+  rwl.read({{0, 4096}}, &read_bl, fadvise_flags, &finish_ctx_read);
   ASSERT_EQ(0, finish_ctx_read.wait());
   ASSERT_EQ(4096, read_bl.length());
   ASSERT_TRUE(bl2_copy.contents_equal(read_bl));
@@ -648,7 +648,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_compare_and_write_compare_matched) {
   ASSERT_EQ(0, finish_ctx3.wait());
 }
 
-TEST_F(TestMockCacheReplicatedWriteLog, aio_compare_and_write_compare_failed) {
+TEST_F(TestMockCacheReplicatedWriteLog, compare_and_write_compare_failed) {
   librbd::ImageCtx *ictx;
   ASSERT_EQ(0, open_image(m_image_name, &ictx));
 
@@ -669,7 +669,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_compare_and_write_compare_failed) {
   bl1.append(std::string(4096, '1'));
   bufferlist bl1_copy = bl1;
   int fadvise_flags = 0;
-  rwl.aio_write(std::move(image_extents), std::move(bl1), fadvise_flags, &finish_ctx2);
+  rwl.write(std::move(image_extents), std::move(bl1), fadvise_flags, &finish_ctx2);
   ASSERT_EQ(0, finish_ctx2.wait());
 
   MockContextRWL finish_ctx_cw;
@@ -678,7 +678,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_compare_and_write_compare_failed) {
   bufferlist com_bl = bl2;
   uint64_t mismatch_offset = -1;
   expect_context_complete(finish_ctx_cw, -EILSEQ);
-  rwl.aio_compare_and_write({{0, 4096}}, std::move(com_bl), std::move(bl2),
+  rwl.compare_and_write({{0, 4096}}, std::move(com_bl), std::move(bl2),
                             &mismatch_offset, fadvise_flags, &finish_ctx_cw);
   ASSERT_EQ(-EILSEQ, finish_ctx_cw.wait());
   ASSERT_EQ(0, mismatch_offset);
@@ -686,7 +686,7 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_compare_and_write_compare_failed) {
   MockContextRWL finish_ctx_read;
   bufferlist read_bl;
   expect_context_complete(finish_ctx_read, 0);
-  rwl.aio_read({{0, 4096}}, &read_bl, fadvise_flags, &finish_ctx_read);
+  rwl.read({{0, 4096}}, &read_bl, fadvise_flags, &finish_ctx_read);
   ASSERT_EQ(0, finish_ctx_read.wait());
   ASSERT_EQ(4096, read_bl.length());
   ASSERT_TRUE(bl1_copy.contents_equal(read_bl));
@@ -697,5 +697,6 @@ TEST_F(TestMockCacheReplicatedWriteLog, aio_compare_and_write_compare_failed) {
   ASSERT_EQ(0, finish_ctx3.wait());
 }
 
+} // namespace pwl
 } // namespace cache
 } // namespace librbd