cache/ImageWriteback.cc
cache/ObjectCacherObjectDispatch.cc
cache/ParentCacheObjectDispatch.cc
- cache/SharedPersistentObjectCacher.cc
cache/ObjectCacherWriteback.cc
cache/PassthroughImageCache.cc
cache/WriteAroundObjectDispatch.cc
if (reg) {
ldout(cct, 20) << "Parent cache open cache handler" << dendl;
- m_object_store = new SharedPersistentObjectCacher<I>(m_image_ctx, m_image_ctx->shared_cache_path);
+ m_object_store = new SharedPersistentObjectCacher(m_image_ctx, m_image_ctx->shared_cache_path);
}
return 0;
}
return 0;
}
+template <typename I>
+ParentCacheObjectDispatch<I>::SharedPersistentObjectCacher::SharedPersistentObjectCacher (
+ I *image_ctx, std::string cache_path)
+ : m_image_ctx(image_ctx) {
+ auto *cct = m_image_ctx->cct;
+ ldout(cct, 20) << dendl;
+}
+
+template <typename I>
+ParentCacheObjectDispatch<I>::SharedPersistentObjectCacher::~SharedPersistentObjectCacher() {
+}
+
+template <typename I>
+int ParentCacheObjectDispatch<I>::SharedPersistentObjectCacher::read_object(
+ std::string file_path, ceph::bufferlist* read_data, uint64_t offset,
+ uint64_t length, Context *on_finish) {
+
+ auto *cct = m_image_ctx->cct;
+ ldout(cct, 20) << "file path: " << file_path << dendl;
+
+ std::string error;
+ int ret = read_data->pread_file(file_path.c_str(), offset, length, &error);
+ if (ret < 0) {
+ ldout(cct, 5) << "read from file return error: " << error
+ << "file path= " << file_path
+ << dendl;
+ return ret;
+ }
+ return read_data->length();
+}
+
} // namespace cache
} // namespace librbd
#define CEPH_LIBRBD_CACHE_PARENT_CACHER_OBJECT_DISPATCH_H
#include "common/Mutex.h"
-#include "SharedPersistentObjectCacher.h"
+//#include "SharedPersistentObjectCacher.h"
#include "librbd/io/ObjectDispatchInterface.h"
#include "tools/immutable_object_cache/CacheClient.h"
#include "librbd/cache/TypeTraits.h"
}
private:
+
+ class SharedPersistentObjectCacher {
+ public:
+
+ SharedPersistentObjectCacher(ImageCtxT *image_ctx, std::string cache_path);
+ ~SharedPersistentObjectCacher();
+
+ int read_object(std::string file_path, ceph::bufferlist* read_data,
+ uint64_t offset, uint64_t length, Context *on_finish);
+
+ private:
+ ImageCtxT *m_image_ctx;
+ };
+
void handle_read_cache(
ceph::immutable_obj_cache::ObjectCacheRequest* ack,
uint64_t read_off, uint64_t read_len,
CacheClient *m_cache_client = nullptr;
ImageCtxT* m_image_ctx;
- SharedPersistentObjectCacher<ImageCtxT> *m_object_store = nullptr;
+ SharedPersistentObjectCacher *m_object_store = nullptr;
bool m_initialized;
std::atomic<bool> m_re_connecting;
};
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-
-#include "librbd/cache/SharedPersistentObjectCacher.h"
-#include "include/buffer.h"
-#include "common/dout.h"
-#include "librbd/ImageCtx.h"
-
-#define dout_subsys ceph_subsys_rbd
-#undef dout_prefix
-#define dout_prefix *_dout << "librbd::cache::SharedPersistentObjectCacher: " << this \
- << " " << __func__ << ": "
-
-namespace librbd {
-namespace cache {
-
-template <typename I>
-SharedPersistentObjectCacher<I>::SharedPersistentObjectCacher(I *image_ctx, std::string cache_path)
- : m_image_ctx(image_ctx) {
- auto *cct = m_image_ctx->cct;
- ldout(cct, 20) << dendl;
-}
-
-template <typename I>
-SharedPersistentObjectCacher<I>::~SharedPersistentObjectCacher() {
-}
-
-template <typename I>
-int SharedPersistentObjectCacher<I>::read_object(std::string file_path,
- ceph::bufferlist* read_data, uint64_t offset, uint64_t length,
- Context *on_finish) {
-
- auto *cct = m_image_ctx->cct;
- ldout(cct, 20) << "file path: " << file_path << dendl;
-
- std::string error;
- int ret = read_data->pread_file(file_path.c_str(), offset, length, &error);
- if (ret < 0) {
- ldout(cct, 5) << "read from file return error: " << error
- << "file path= " << file_path
- << dendl;
- return ret;
- }
- return read_data->length();
-}
-
-
-} // namespace cache
-} // namespace librbd
-
-template class librbd::cache::SharedPersistentObjectCacher<librbd::ImageCtx>;
+++ /dev/null
-// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
-// vim: ts=8 sw=2 smarttab
-
-#ifndef CEPH_LIBRBD_CACHE_SHARED_PERSISTENT_OBJECT_CACHER
-#define CEPH_LIBRBD_CACHE_SHARED_PERSISTENT_OBJECT_CACHER
-
-#include "include/buffer_fwd.h"
-#include "include/int_types.h"
-#include "common/Mutex.h"
-#include <vector>
-#include <unordered_map>
-
-struct Context;
-
-namespace librbd {
-
-struct ImageCtx;
-
-namespace cache {
-
-template <typename ImageCtxT>
-class SharedPersistentObjectCacher {
-public:
-
- SharedPersistentObjectCacher(ImageCtxT *image_ctx, std::string cache_path);
- ~SharedPersistentObjectCacher();
-
- int read_object(std::string file_path, ceph::bufferlist* read_data,
- uint64_t offset, uint64_t length, Context *on_finish);
-
-private:
- ImageCtxT *m_image_ctx;
-};
-
-} // namespace cache
-} // namespace librbd
-
-extern template class librbd::cache::SharedPersistentObjectCacher<librbd::ImageCtx>;
-
-#endif // CEPH_LIBRBD_CACHE_FILE_IMAGE_STORE
#include "tools/immutable_object_cache/CacheClient.h"
#include "test/immutable_object_cache/MockCacheDaemon.h"
#include "librbd/cache/ParentCacheObjectDispatch.h"
-#include "librbd/cache/SharedPersistentObjectCacher.h"
#include "test/librbd/test_mock_fixture.h"
#include "test/librbd/mock/MockImageCtx.h"
}; // namespace librbd
#include "librbd/cache/ParentCacheObjectDispatch.cc"
-#include "librbd/cache/SharedPersistentObjectCacher.cc"
template class librbd::cache::ParentCacheObjectDispatch<librbd::MockParentImageCacheImageCtx>;
-template class librbd::cache::SharedPersistentObjectCacher<librbd::MockParentImageCacheImageCtx>;
namespace librbd {