]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: removed object cacher hooks from IO object request
authorJason Dillaman <dillaman@redhat.com>
Tue, 27 Feb 2018 23:29:19 +0000 (18:29 -0500)
committerJason Dillaman <dillaman@redhat.com>
Wed, 7 Mar 2018 17:45:42 +0000 (12:45 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/io/ObjectDispatch.cc
src/librbd/io/ObjectRequest.cc
src/librbd/io/ObjectRequest.h
src/test/librbd/io/test_mock_ObjectRequest.cc

index a1055fce55b716bfd0055e29c52056c3f7b363e0..31090238ed8a14c459374a452a7b67f1cf691233 100644 (file)
@@ -42,8 +42,8 @@ bool ObjectDispatch<I>::read(
   *dispatch_result = DISPATCH_RESULT_COMPLETE;
   auto req = new ObjectReadRequest<I>(m_image_ctx, oid, object_no, object_off,
                                       object_len, snap_id, op_flags,
-                                      false, parent_trace, read_data,
-                                      extent_map, on_dispatched);
+                                      parent_trace, read_data, extent_map,
+                                      on_dispatched);
   req->send();
   return true;
 }
index b5537d75af7375455893a5b0b3fc25b91bf6859e..bc1d9e93fc3a7efb7c9e130530cf4ab10b0b66ff 100644 (file)
@@ -185,15 +185,14 @@ template <typename I>
 ObjectReadRequest<I>::ObjectReadRequest(I *ictx, const std::string &oid,
                                         uint64_t objectno, uint64_t offset,
                                         uint64_t len, librados::snap_t snap_id,
-                                        int op_flags, bool cache_initiated,
+                                        int op_flags,
                                         const ZTracer::Trace &parent_trace,
                                         bufferlist* read_data,
                                         ExtentMap* extent_map,
                                         Context *completion)
   : ObjectRequest<I>(ictx, oid, objectno, offset, len, snap_id, "read",
                      parent_trace, completion),
-    m_op_flags(op_flags), m_cache_initiated(cache_initiated),
-    m_read_data(read_data), m_extent_map(extent_map) {
+    m_op_flags(op_flags), m_read_data(read_data), m_extent_map(extent_map) {
 }
 
 template <typename I>
@@ -201,44 +200,7 @@ void ObjectReadRequest<I>::send() {
   I *image_ctx = this->m_ictx;
   ldout(image_ctx->cct, 20) << dendl;
 
-  if (!m_cache_initiated && image_ctx->object_cacher != nullptr) {
-    read_cache();
-  } else {
-    read_object();
-  }
-}
-
-template <typename I>
-void ObjectReadRequest<I>::read_cache() {
-  I *image_ctx = this->m_ictx;
-  ldout(image_ctx->cct, 20) << dendl;
-
-  // must use async callback to avoid cache_lock cycle
-  auto cache_ctx = util::create_async_context_callback(
-    *image_ctx, util::create_context_callback<
-      ObjectReadRequest<I>, &ObjectReadRequest<I>::handle_read_cache>(this));
-  image_ctx->aio_read_from_cache(
-    this->m_oid, this->m_object_no, m_read_data, this->m_object_len,
-    this->m_object_off, cache_ctx, m_op_flags,
-    (this->m_trace.valid() ? &this->m_trace : nullptr));
-}
-
-template <typename I>
-void ObjectReadRequest<I>::handle_read_cache(int r) {
-  I *image_ctx = this->m_ictx;
-  ldout(image_ctx->cct, 20) << "r=" << r << dendl;
-
-  if (r == -ENOENT) {
-    read_parent();
-    return;
-  } else if (r < 0) {
-    lderr(image_ctx->cct) << "failed to read from cache: "
-                          << cpp_strerror(r) << dendl;
-    this->finish(r);
-    return;
-  }
-
-  this->finish(0);
+  read_object();
 }
 
 template <typename I>
index ebb10f590a8b62f9b8362a17b9196589fd38822c..9e8f3996c5e3ccc7282955e3beb37d9723a25d86 100644 (file)
@@ -98,20 +98,19 @@ public:
   static ObjectReadRequest* create(ImageCtxT *ictx, const std::string &oid,
                                    uint64_t objectno, uint64_t offset,
                                    uint64_t len, librados::snap_t snap_id,
-                                   int op_flags, bool cache_initiated,
+                                   int op_flags,
                                    const ZTracer::Trace &parent_trace,
                                    ceph::bufferlist* read_data,
                                    ExtentMap* extent_map, Context *completion) {
     return new ObjectReadRequest(ictx, oid, objectno, offset, len,
-                                 snap_id, op_flags, cache_initiated,
-                                 parent_trace, read_data, extent_map,
-                                 completion);
+                                 snap_id, op_flags, parent_trace, read_data,
+                                 extent_map, completion);
   }
 
   ObjectReadRequest(ImageCtxT *ictx, const std::string &oid,
                     uint64_t objectno, uint64_t offset, uint64_t len,
                     librados::snap_t snap_id, int op_flags,
-                    bool cache_initiated, const ZTracer::Trace &parent_trace,
+                    const ZTracer::Trace &parent_trace,
                     ceph::bufferlist* read_data, ExtentMap* extent_map,
                     Context *completion);
 
@@ -125,16 +124,11 @@ private:
   /**
    * @verbatim
    *
-   *           <start>
-   *              |
-   *              |
-   *    /--------/ \--------\
-   *    |                   |
-   *    | (cache            | (cache
-   *    v  disabled)        v  enabled)
-   * READ_OBJECT      READ_CACHE
-   *    |                   |
-   *    |/------------------/
+   * <start>
+   *    |
+   *    |
+   *    v
+   * READ_OBJECT
    *    |
    *    v (skip if not needed)
    * READ_PARENT
@@ -149,14 +143,10 @@ private:
    */
 
   int m_op_flags;
-  bool m_cache_initiated;
 
   ceph::bufferlist* m_read_data;
   ExtentMap* m_extent_map;
 
-  void read_cache();
-  void handle_read_cache(int r);
-
   void read_object();
   void handle_read_object(int r);
 
index 00d0e42e56ec5fe76252ffb0f1ef7dcc37bf802d..b97afeff99d2fdbfd989a061d75d3491dea2baa0 100644 (file)
@@ -327,8 +327,8 @@ TEST_F(TestMockIoObjectRequest, Read) {
   ExtentMap extent_map;
   C_SaferCond ctx;
   auto req = MockObjectReadRequest::create(
-    &mock_image_ctx, ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0,
-    false, {}, &bl, &extent_map, &ctx);
+    &mock_image_ctx, ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0, {},
+    &bl, &extent_map, &ctx);
   req->send();
   ASSERT_EQ(0, ctx.wait());
 }
@@ -358,8 +358,8 @@ TEST_F(TestMockIoObjectRequest, SparseReadThreshold) {
   C_SaferCond ctx;
   auto req = MockObjectReadRequest::create(
     &mock_image_ctx, ictx->get_object_name(0), 0, 0,
-    ictx->sparse_read_threshold_bytes, CEPH_NOSNAP, 0, false, {},
-    &bl, &extent_map, &ctx);
+    ictx->sparse_read_threshold_bytes, CEPH_NOSNAP, 0, {}, &bl, &extent_map,
+    &ctx);
   req->send();
   ASSERT_EQ(0, ctx.wait());
 }
@@ -386,8 +386,8 @@ TEST_F(TestMockIoObjectRequest, ReadError) {
   ExtentMap extent_map;
   C_SaferCond ctx;
   auto req = MockObjectReadRequest::create(
-    &mock_image_ctx, ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0,
-    false, {}, &bl, &extent_map, &ctx);
+    &mock_image_ctx, ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0, {},
+    &bl, &extent_map, &ctx);
   req->send();
   ASSERT_EQ(-EPERM, ctx.wait());
 }
@@ -435,8 +435,8 @@ TEST_F(TestMockIoObjectRequest, ParentRead) {
   ExtentMap extent_map;
   C_SaferCond ctx;
   auto req = MockObjectReadRequest::create(
-    &mock_image_ctx, ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0,
-    false, {}, &bl, &extent_map, &ctx);
+    &mock_image_ctx, ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0, {},
+    &bl, &extent_map, &ctx);
   req->send();
   ASSERT_EQ(0, ctx.wait());
 }
@@ -484,8 +484,8 @@ TEST_F(TestMockIoObjectRequest, ParentReadError) {
   ExtentMap extent_map;
   C_SaferCond ctx;
   auto req = MockObjectReadRequest::create(
-    &mock_image_ctx, ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0,
-    false,  {}, &bl, &extent_map, &ctx);
+    &mock_image_ctx, ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0, {},
+    &bl, &extent_map, &ctx);
   req->send();
   ASSERT_EQ(-EPERM, ctx.wait());
 }
@@ -538,8 +538,8 @@ TEST_F(TestMockIoObjectRequest, CopyOnRead) {
   ExtentMap extent_map;
   C_SaferCond ctx;
   auto req = MockObjectReadRequest::create(
-    &mock_image_ctx, ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0,
-    false, {}, &bl, &extent_map, &ctx);
+    &mock_image_ctx, ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0, {},
+    &bl, &extent_map, &ctx);
   req->send();
   ASSERT_EQ(0, ctx.wait());
 }