From 21bcc7598a2e87d384996cbcfad8b8ca3f3e774f Mon Sep 17 00:00:00 2001 From: Yuan Zhou Date: Wed, 23 Jan 2019 23:36:57 +0800 Subject: [PATCH] tools: clean up immutable obj cache Signed-off-by: Yuan Zhou --- src/test/immutable_object_cache/test_object_store.cc | 2 +- src/tools/immutable_object_cache/CMakeLists.txt | 9 +-------- src/tools/immutable_object_cache/CacheController.cc | 12 +++++++++--- src/tools/immutable_object_cache/CacheController.h | 1 - src/tools/immutable_object_cache/ObjectCacheStore.cc | 4 ++-- src/tools/immutable_object_cache/ObjectCacheStore.h | 3 +-- 6 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/test/immutable_object_cache/test_object_store.cc b/src/test/immutable_object_cache/test_object_store.cc index caa14dc9a1a32..e82f42c7ca243 100644 --- a/src/test/immutable_object_cache/test_object_store.cc +++ b/src/test/immutable_object_cache/test_object_store.cc @@ -54,7 +54,7 @@ public: ASSERT_EQ(0, m_test_rados->ioctx_create(m_temp_pool_name.c_str(), m_local_io_ctx)); m_temp_volume_name = "test_volume"; m_ceph_context = reinterpret_cast(m_test_rados->cct()); - m_object_cache_store = new ObjectCacheStore(m_ceph_context, nullptr); + m_object_cache_store = new ObjectCacheStore(m_ceph_context); } void init_object_cache_store(std::string pool_name, std::string vol_name, uint64_t vol_size, bool reset) { diff --git a/src/tools/immutable_object_cache/CMakeLists.txt b/src/tools/immutable_object_cache/CMakeLists.txt index fa713f639a3ec..74362c9a27d59 100644 --- a/src/tools/immutable_object_cache/CMakeLists.txt +++ b/src/tools/immutable_object_cache/CMakeLists.txt @@ -12,16 +12,9 @@ set(ceph_immutable_object_cache_files add_library(ceph_immutable_object_cache_lib STATIC ${ceph_immutable_object_cache_files}) add_executable(ceph-immutable-object-cache - ObjectCacheFile.cc - ObjectCacheStore.cc - CacheController.cc - CacheServer.cc - CacheSession.cc - SimplePolicy.cc - Utils.cc - Types.cc main.cc) target_link_libraries(ceph-immutable-object-cache + ceph_immutable_object_cache_lib librados-cxx stdc++fs global) diff --git a/src/tools/immutable_object_cache/CacheController.cc b/src/tools/immutable_object_cache/CacheController.cc index 8e07aea930b34..9337453381ec8 100644 --- a/src/tools/immutable_object_cache/CacheController.cc +++ b/src/tools/immutable_object_cache/CacheController.cc @@ -25,12 +25,19 @@ CacheController::~CacheController() { int CacheController::init() { ldout(m_cct, 20) << dendl; - m_object_cache_store = new ObjectCacheStore(m_cct, pcache_op_work_queue); + m_object_cache_store = new ObjectCacheStore(m_cct); //TODO(): make this configurable int r = m_object_cache_store->init(true); if (r < 0) { lderr(m_cct) << "init error\n" << dendl; + return r; } + + r = m_object_cache_store->init_cache(); + if (r < 0) { + lderr(m_cct) << "init error\n" << dendl; + } + return r; } @@ -65,8 +72,7 @@ void CacheController::handle_request(uint64_t session_id, ObjectCacheRequest* re switch (req->m_head.type) { case RBDSC_REGISTER: { - // init cache layout for volume - m_object_cache_store->init_cache(); + // TODO(): skip register and allow clients to lookup directly req->m_head.type = RBDSC_REGISTER_REPLY; m_cache_server->send(session_id, req); diff --git a/src/tools/immutable_object_cache/CacheController.h b/src/tools/immutable_object_cache/CacheController.h index 4d112c027b52f..79b3b9525de1b 100644 --- a/src/tools/immutable_object_cache/CacheController.h +++ b/src/tools/immutable_object_cache/CacheController.h @@ -32,7 +32,6 @@ class CacheController { std::vector m_args; CephContext *m_cct; ObjectCacheStore *m_object_cache_store; - ContextWQ* pcache_op_work_queue; }; } // namespace immutable_obj_cache diff --git a/src/tools/immutable_object_cache/ObjectCacheStore.cc b/src/tools/immutable_object_cache/ObjectCacheStore.cc index 9f27d9f50e7b9..e50c1da948061 100644 --- a/src/tools/immutable_object_cache/ObjectCacheStore.cc +++ b/src/tools/immutable_object_cache/ObjectCacheStore.cc @@ -16,8 +16,8 @@ namespace efs = std::experimental::filesystem; namespace ceph { namespace immutable_obj_cache { -ObjectCacheStore::ObjectCacheStore(CephContext *cct, ContextWQ* work_queue) - : m_cct(cct), m_work_queue(work_queue), m_rados(new librados::Rados()), +ObjectCacheStore::ObjectCacheStore(CephContext *cct) + : m_cct(cct), m_rados(new librados::Rados()), m_ioctxs_lock("ceph::cache::ObjectCacheStore::m_ioctxs_lock") { object_cache_max_size = diff --git a/src/tools/immutable_object_cache/ObjectCacheStore.h b/src/tools/immutable_object_cache/ObjectCacheStore.h index 01bd7d61e3077..f3b14289694e4 100644 --- a/src/tools/immutable_object_cache/ObjectCacheStore.h +++ b/src/tools/immutable_object_cache/ObjectCacheStore.h @@ -25,7 +25,7 @@ typedef shared_ptr IoCtxRef; class ObjectCacheStore { public: - ObjectCacheStore(CephContext *cct, ContextWQ* work_queue); + ObjectCacheStore(CephContext *cct); ~ObjectCacheStore(); int init(bool reset); int shutdown(); @@ -47,7 +47,6 @@ class ObjectCacheStore int do_evict(std::string cache_file); CephContext *m_cct; - ContextWQ* m_work_queue; RadosRef m_rados; std::map m_ioctxs; Mutex m_ioctxs_lock; -- 2.39.5