]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: cleanup parent cache
authorshangdehao1 <dehao.shang@intel.com>
Sun, 9 Jun 2019 23:30:43 +0000 (07:30 +0800)
committerJason Dillaman <dillaman@redhat.com>
Mon, 24 Jun 2019 21:36:53 +0000 (17:36 -0400)
- remove compiler warning.
- add error log level.
- modify tool/immutable_obj_cache unit testing.

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

index c2c772b3a1ff1a459eceb33370a2b28af1db654a..b6428b193bf49aa10f25daea855544ff14f4b04f 100644 (file)
@@ -28,7 +28,7 @@ namespace cache {
 template <typename I>
 ParentCacheObjectDispatch<I>::ParentCacheObjectDispatch(
     I* image_ctx) : m_image_ctx(image_ctx), m_cache_client(nullptr),
-    m_initialized(false), m_object_store(nullptr), m_re_connecting(false) {
+    m_object_store(nullptr), m_initialized(false), m_re_connecting(false) {
   std::string controller_path =
     ((CephContext*)(m_image_ctx->cct))->_conf.get_val<std::string>("immutable_object_cache_sock");
   m_cache_client = new CacheClient(controller_path.c_str(), m_image_ctx->cct);
@@ -77,7 +77,7 @@ bool ParentCacheObjectDispatch<I>::read(
   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.*/
+   * or session occur any error, try to re-connect daemon.*/
   if (!m_cache_client->is_session_work()) {
     if(!m_re_connecting.load()) {
       ldout(cct, 20) << "try to re-connct RO daemon. " << dendl;
@@ -92,7 +92,6 @@ bool ParentCacheObjectDispatch<I>::read(
     ldout(cct, 5) << "session don't work, dispatch current request to lower object layer " << dendl;
     return false;
   }
-
   ceph_assert(m_cache_client->is_session_work());
 
   CacheGenContextURef ctx = make_gen_lambda_context<ObjectCacheRequest*,
@@ -111,9 +110,9 @@ bool ParentCacheObjectDispatch<I>::read(
 
 template <typename I>
 void ParentCacheObjectDispatch<I>::handle_read_cache(
-    ObjectCacheRequest* ack, uint64_t read_off,
-    uint64_t read_len, ceph::bufferlist* read_data,
-    io::DispatchResult* dispatch_result, Context* on_dispatched) {
+     ObjectCacheRequest* ack, uint64_t read_off, uint64_t read_len,
+     ceph::bufferlist* read_data, io::DispatchResult* dispatch_result,
+     Context* on_dispatched) {
   auto cct = m_image_ctx->cct;
   ldout(cct, 20) << dendl;
 
@@ -159,7 +158,7 @@ int ParentCacheObjectDispatch<I>::create_cache_session(Context* on_finish, bool
 
   Context* register_ctx = new FunctionContext([this, cct, on_finish](int ret) {
     if (ret < 0) {
-      ldout(cct, 20) << "Parent cache fail to register client." << dendl;
+      lderr(cct) << "Parent cache fail to register client." << dendl;
       handle_register_client(false);
       on_finish->complete(-1);
       return;
@@ -173,7 +172,7 @@ int ParentCacheObjectDispatch<I>::create_cache_session(Context* on_finish, bool
   Context* connect_ctx = new FunctionContext(
     [this, cct, register_ctx](int ret) {
     if (ret < 0) {
-      ldout(cct, 20) << "Parent cache fail to connect RO daeomn." << dendl;
+      lderr(cct) << "Parent cache fail to connect RO daeomn." << dendl;
       register_ctx->complete(-1);
       return;
     }
index 20a81fb050117aea1c26225b61bf7442a9f4594e..d7b6403a93a8f3f391edc8cea2dbbd3545bdd277 100644 (file)
@@ -141,9 +141,9 @@ private:
   int handle_register_client(bool reg);
   int create_cache_session(Context* on_finish, bool is_reconnect);
 
-  CacheClient *m_cache_client = nullptr;
   ImageCtxT* m_image_ctx;
-  SharedPersistentObjectCacher *m_object_store = nullptr;
+  CacheClient *m_cache_client;
+  SharedPersistentObjectCacher *m_object_store;
   bool m_initialized;
   std::atomic<bool> m_re_connecting;
 };
index 89a0fa6c4493ac31908a3ab86c2834472b1719dc..d1a1aa2cf1b91a8bb3398a71f48e432c7109da87 100644 (file)
@@ -58,8 +58,8 @@ public:
       }
     }
 
-    auto ctx = new FunctionContext([](bool reg) {
-      ASSERT_TRUE(reg);
+    auto ctx = new FunctionContext([](int reg) {
+      ASSERT_TRUE(reg == 0);
     });
     m_cache_client->register_client(ctx);
     ASSERT_TRUE(m_cache_client->is_session_work());
index f00e5149ef652dc449142fbaf0ba834806da6527..8703a69f76fc9a86e5260b5a3f6570e06e84b1df 100644 (file)
@@ -106,8 +106,8 @@ public:
   void test_register_client(uint64_t random_index) {
     ASSERT_TRUE(m_cache_client_vec[random_index] == nullptr);
 
-    auto ctx = new FunctionContext([](bool ret){
-       ASSERT_TRUE(ret);
+    auto ctx = new FunctionContext([](int ret){
+       ASSERT_TRUE(ret == 0);
     });
     auto session = create_session(random_index);
     session->register_client(ctx);
index 9f4f0cb4da0b3fbdbd7d5b2a0eed94b2e7620bf4..632ce1bd573f4ef50f35c58a6cebb4d9530a75c1 100644 (file)
@@ -262,7 +262,6 @@ TEST_F(TestMockParentImageCache, test_disble_interface) {
   std::string temp_oid("12345");
   ceph::bufferlist temp_bl;
   ::SnapContext *temp_snapc = nullptr;
-  io::ExtentMap *temp_extent_map = nullptr;
   io::DispatchResult* temp_dispatch_result = nullptr;
   io::Extents temp_buffer_extents;
   int* temp_op_flags = nullptr;
@@ -270,7 +269,6 @@ TEST_F(TestMockParentImageCache, test_disble_interface) {
   Context** temp_on_finish = nullptr;
   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(0, 0, 0, *temp_snapc, 0, *temp_trace, temp_op_flags,
@@ -284,7 +282,7 @@ TEST_F(TestMockParentImageCache, test_disble_interface) {
   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,
+  ASSERT_EQ(mock_parent_image_cache->flush(io::FLUSH_SOURCE_USER, *temp_trace, temp_journal_tid,
             temp_dispatch_result, temp_on_finish, temp_on_dispatched), false);
   ASSERT_EQ(mock_parent_image_cache->invalidate_cache(nullptr), false);
   ASSERT_EQ(mock_parent_image_cache->reset_existence_cache(nullptr), false);
@@ -328,9 +326,9 @@ TEST_F(TestMockParentImageCache, test_read) {
   C_SaferCond cond;
   Context* on_finish = &cond;
 
-  auto& expect = EXPECT_CALL(*(mock_parent_image_cache->get_cache_client()), is_session_work())
-                   .WillOnce(Return(true))
-                   .WillOnce(Return(true));
+  auto& expect = EXPECT_CALL(*(mock_parent_image_cache->get_cache_client()), is_session_work());
+  expect.WillOnce(Return(true)).WillOnce(Return(true));
+
   expect_cache_lookup_object(*mock_parent_image_cache, on_finish); 
 
   mock_parent_image_cache->read(0, 0, 4096, CEPH_NOSNAP, 0, {},