]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: modify Parent cache interface
authorshangdehao1 <dehao.shang@intel.com>
Sun, 9 Jun 2019 19:47:24 +0000 (03:47 +0800)
committerJason Dillaman <dillaman@redhat.com>
Mon, 24 Jun 2019 21:35:40 +0000 (17:35 -0400)
follow the recent ObjectDispatchInterface to adjust parent cache hook

Signed-off-by: Dehao Shang <dehao.shang@intel.com>
src/librbd/cache/ParentCacheObjectDispatch.cc
src/librbd/cache/ParentCacheObjectDispatch.h
src/test/librbd/cache/test_mock_ParentImageCache.cc

index daa1c1f707fb0f6a09b57dde6324abf72afde6ac..c2c772b3a1ff1a459eceb33370a2b28af1db654a 100644 (file)
@@ -20,6 +20,7 @@
                            << this << " " << __func__ << ": "
 
 using namespace ceph::immutable_obj_cache;
+using librbd::util::data_object_name;
 
 namespace librbd {
 namespace cache {
@@ -63,7 +64,7 @@ void ParentCacheObjectDispatch<I>::init() {
 
 template <typename I>
 bool ParentCacheObjectDispatch<I>::read(
-    const std::string &oid, uint64_t object_no, uint64_t object_off,
+    uint64_t object_no, uint64_t object_off,
     uint64_t object_len, librados::snap_t snap_id, int op_flags,
     const ZTracer::Trace &parent_trace, ceph::bufferlist* read_data,
     io::ExtentMap* extent_map, int* object_dispatch_flags,
@@ -73,6 +74,7 @@ bool ParentCacheObjectDispatch<I>::read(
   ldout(cct, 20) << "object_no=" << object_no << " " << object_off << "~"
                  << object_len << dendl;
   ceph_assert(m_initialized);
+  string oid = data_object_name(m_image_ctx, object_no);
 
   /* if RO daemon still don't startup, or RO daemon crash,
    * or session have any error, try to re-connect daemon.*/
index 4bacc278645fa8f4704939f9b5ae4da4af7076e6..20a81fb050117aea1c26225b61bf7442a9f4594e 100644 (file)
@@ -5,7 +5,6 @@
 #define CEPH_LIBRBD_CACHE_PARENT_CACHER_OBJECT_DISPATCH_H
 
 #include "common/Mutex.h"
-//#include "SharedPersistentObjectCacher.h"
 #include "librbd/io/ObjectDispatchInterface.h"
 #include "tools/immutable_object_cache/CacheClient.h"
 #include "librbd/cache/TypeTraits.h"
@@ -41,16 +40,16 @@ public:
   }
 
   bool read(
-      const std::string &oid, uint64_t object_no, uint64_t object_off,
-      uint64_t object_len, librados::snap_t snap_id, int op_flags,
+      uint64_t object_no, uint64_t object_off, uint64_t object_len,
+      librados::snap_t snap_id, int op_flags,
       const ZTracer::Trace &parent_trace, ceph::bufferlist* read_data,
       io::ExtentMap* extent_map, int* object_dispatch_flags,
       io::DispatchResult* dispatch_result, Context** on_finish,
       Context* on_dispatched) override;
 
   bool discard(
-      const std::string &oid, uint64_t object_no, uint64_t object_off,
-      uint64_t object_len, const ::SnapContext &snapc, int discard_flags,
+      uint64_t object_no, uint64_t object_off, uint64_t object_len, 
+      const ::SnapContext &snapc, int discard_flags,
       const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
       uint64_t* journal_tid, io::DispatchResult* dispatch_result,
       Context** on_finish, Context* on_dispatched) {
@@ -58,8 +57,8 @@ public:
   }
 
   bool write(
-      const std::string &oid, uint64_t object_no, uint64_t object_off,
-      ceph::bufferlist&& data, const ::SnapContext &snapc, int op_flags,
+      uint64_t object_no, uint64_t object_off, ceph::bufferlist&& data,
+      const ::SnapContext &snapc, int op_flags,
       const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
       uint64_t* journal_tid, io::DispatchResult* dispatch_result,
       Context** on_finish, Context* on_dispatched) {
@@ -67,9 +66,9 @@ public:
   }
 
   bool write_same(
-      const std::string &oid, uint64_t object_no, uint64_t object_off,
-      uint64_t object_len, io::Extents&& buffer_extents,
-      ceph::bufferlist&& data, const ::SnapContext &snapc, int op_flags,
+      uint64_t object_no, uint64_t object_off, uint64_t object_len,
+      io::LightweightBufferExtents&& buffer_extents, ceph::bufferlist&& data, 
+      const ::SnapContext &snapc, int op_flags,
       const ZTracer::Trace &parent_trace, int* object_dispatch_flags,
       uint64_t* journal_tid, io::DispatchResult* dispatch_result,
       Context** on_finish, Context* on_dispatched) {
@@ -77,9 +76,8 @@ public:
   }
 
   bool compare_and_write(
-      const std::string &oid, uint64_t object_no, uint64_t object_off,
-      ceph::bufferlist&& cmp_data, ceph::bufferlist&& write_data,
-      const ::SnapContext &snapc, int op_flags,
+      uint64_t object_no, uint64_t object_off, ceph::bufferlist&& cmp_data, 
+      ceph::bufferlist&& write_data, const ::SnapContext &snapc, int op_flags,
       const ZTracer::Trace &parent_trace, uint64_t* mismatch_offset,
       int* object_dispatch_flags, uint64_t* journal_tid,
       io::DispatchResult* dispatch_result, Context** on_finish,
index fe6482d6020da393cfd8175d2c9a8aaea6f1afb5..9f4f0cb4da0b3fbdbd7d5b2a0eed94b2e7620bf4 100644 (file)
@@ -271,17 +271,18 @@ TEST_F(TestMockParentImageCache, test_disble_interface) {
   Context* temp_on_dispatched = nullptr;
   ZTracer::Trace* temp_trace = nullptr;
   io::FlushSource temp_flush_source;
+  io::LightweightBufferExtents buffer_extents;
   
-  ASSERT_EQ(mock_parent_image_cache->discard(temp_oid, 0, 0, 0, *temp_snapc, 0, *temp_trace, temp_op_flags, 
+  ASSERT_EQ(mock_parent_image_cache->discard(0, 0, 0, *temp_snapc, 0, *temp_trace, temp_op_flags,
             temp_journal_tid, temp_dispatch_result, temp_on_finish, temp_on_dispatched), false);
-  ASSERT_EQ(mock_parent_image_cache->write(temp_oid, 0, 0, std::move(temp_bl), *temp_snapc, 0,
-            *temp_trace, temp_op_flags, temp_journal_tid, temp_dispatch_result, 
+  ASSERT_EQ(mock_parent_image_cache->write(0, 0, std::move(temp_bl), *temp_snapc, 0,
+            *temp_trace, temp_op_flags, temp_journal_tid, temp_dispatch_result,
             temp_on_finish, temp_on_dispatched), false);
-  ASSERT_EQ(mock_parent_image_cache->write_same(temp_oid, 0, 0, 0, std::move(temp_buffer_extents),
+  ASSERT_EQ(mock_parent_image_cache->write_same(0, 0, 0, std::move(buffer_extents),
             std::move(temp_bl), *temp_snapc, 0, *temp_trace, temp_op_flags,
             temp_journal_tid, temp_dispatch_result, temp_on_finish, temp_on_dispatched), false );
-  ASSERT_EQ(mock_parent_image_cache->compare_and_write(temp_oid, 0, 0, std::move(temp_bl), std::move(temp_bl), 
-            *temp_snapc, 0, *temp_trace, temp_journal_tid, temp_op_flags, temp_journal_tid, 
+  ASSERT_EQ(mock_parent_image_cache->compare_and_write(0, 0, std::move(temp_bl), std::move(temp_bl),
+            *temp_snapc, 0, *temp_trace, temp_journal_tid, temp_op_flags, temp_journal_tid,
             temp_dispatch_result, temp_on_finish, temp_on_dispatched), false);
   ASSERT_EQ(mock_parent_image_cache->flush(temp_flush_source, *temp_trace, temp_journal_tid,
             temp_dispatch_result, temp_on_finish, temp_on_dispatched), false);
@@ -332,7 +333,7 @@ TEST_F(TestMockParentImageCache, test_read) {
                    .WillOnce(Return(true));
   expect_cache_lookup_object(*mock_parent_image_cache, on_finish); 
 
-  mock_parent_image_cache->read(ictx->get_object_name(0), 0, 0, 4096, CEPH_NOSNAP, 0, {}, 
+  mock_parent_image_cache->read(0, 0, 4096, CEPH_NOSNAP, 0, {},
                         nullptr, nullptr, nullptr, nullptr, &on_finish, nullptr);
   ASSERT_EQ(0, cond.wait());