1 From 26f4a0804c035895fd77e9a70f47ede3f4512bde Mon Sep 17 00:00:00 2001
2 From: Yuan Zhou <yuan.zhou@intel.com>
3 Date: Wed, 20 Jun 2018 11:34:17 +0800
4 Subject: [PATCH 02/10] librbd: cleanup rbd shared RO cache
6 - adding namespace for rbd cache controller
7 - move SyncFile code under librbd/cache/
9 Signed-off-by: Yuan Zhou <yuan.zhou@intel.com>
11 src/librbd/CMakeLists.txt | 2 +-
12 src/librbd/cache/SharedPersistentObjectCacher.cc | 4 +-
13 src/librbd/cache/SharedPersistentObjectCacher.h | 6 +-
14 .../cache/SharedPersistentObjectCacherFile.cc | 114 +++++++++++++++++++++
15 .../cache/SharedPersistentObjectCacherFile.h | 74 +++++++++++++
16 .../SharedPersistentObjectCacherObjectDispatch.cc | 4 +-
17 .../SharedPersistentObjectCacherObjectDispatch.h | 2 +-
18 src/os/CacheStore/SyncFile.cc | 110 --------------------
19 src/os/CacheStore/SyncFile.h | 74 -------------
20 src/tools/rbd_cache/CMakeLists.txt | 2 +-
21 src/tools/rbd_cache/CacheController.cc | 9 +-
22 src/tools/rbd_cache/CacheController.h | 55 ++++++++++
23 src/tools/rbd_cache/CacheController.hpp | 49 ---------
24 src/tools/rbd_cache/CacheControllerSocket.hpp | 6 ++
25 .../rbd_cache/CacheControllerSocketClient.hpp | 5 +
26 src/tools/rbd_cache/CacheControllerSocketCommon.h | 5 +
27 src/tools/rbd_cache/ObjectCacheStore.cc | 7 +-
28 src/tools/rbd_cache/ObjectCacheStore.h | 9 +-
29 src/tools/rbd_cache/main.cc | 6 +-
30 19 files changed, 293 insertions(+), 250 deletions(-)
31 create mode 100644 src/librbd/cache/SharedPersistentObjectCacherFile.cc
32 create mode 100644 src/librbd/cache/SharedPersistentObjectCacherFile.h
33 delete mode 100644 src/os/CacheStore/SyncFile.cc
34 delete mode 100644 src/os/CacheStore/SyncFile.h
35 create mode 100644 src/tools/rbd_cache/CacheController.h
36 delete mode 100644 src/tools/rbd_cache/CacheController.hpp
38 diff --git a/src/librbd/CMakeLists.txt b/src/librbd/CMakeLists.txt
39 index 92539a8..540ee78 100644
40 --- a/src/librbd/CMakeLists.txt
41 +++ b/src/librbd/CMakeLists.txt
42 @@ -34,6 +34,7 @@ set(librbd_internal_srcs
43 cache/ObjectCacherObjectDispatch.cc
44 cache/SharedPersistentObjectCacherObjectDispatch.cc
45 cache/SharedPersistentObjectCacher.cc
46 + cache/SharedPersistentObjectCacherFile.cc
47 deep_copy/ImageCopyRequest.cc
48 deep_copy/MetadataCopyRequest.cc
49 deep_copy/ObjectCopyRequest.cc
50 @@ -124,7 +125,6 @@ set(librbd_internal_srcs
53 watcher/RewatchRequest.cc
54 - ${CMAKE_SOURCE_DIR}/src/os/CacheStore/SyncFile.cc
55 ${CMAKE_SOURCE_DIR}/src/common/ContextCompletion.cc)
57 add_library(rbd_api STATIC librbd.cc)
58 diff --git a/src/librbd/cache/SharedPersistentObjectCacher.cc b/src/librbd/cache/SharedPersistentObjectCacher.cc
59 index a849260..260567c 100644
60 --- a/src/librbd/cache/SharedPersistentObjectCacher.cc
61 +++ b/src/librbd/cache/SharedPersistentObjectCacher.cc
62 @@ -19,7 +19,7 @@ SharedPersistentObjectCacher<I>::SharedPersistentObjectCacher(I *image_ctx, std:
63 : m_image_ctx(image_ctx), m_cache_path(cache_path),
64 m_file_map_lock("librbd::cache::SharedObjectCacher::filemaplock") {
65 auto *cct = m_image_ctx->cct;
67 + ldout(cct, 20) << dendl;
71 @@ -40,7 +40,7 @@ int SharedPersistentObjectCacher<I>::read_object(std::string oid, ceph::bufferli
72 std::string cache_file_name = m_image_ctx->data_ctx.get_pool_name() + oid;
74 //TODO(): make a cache for cachefile fd
75 - os::CacheStore::SyncFile* target_cache_file = new os::CacheStore::SyncFile(cct, cache_file_name);
76 + SyncFile* target_cache_file = new SyncFile(cct, cache_file_name);
77 target_cache_file->open();
79 int ret = target_cache_file->read_object_from_file(read_data, offset, length);
80 diff --git a/src/librbd/cache/SharedPersistentObjectCacher.h b/src/librbd/cache/SharedPersistentObjectCacher.h
81 index d108a05..af04e63 100644
82 --- a/src/librbd/cache/SharedPersistentObjectCacher.h
83 +++ b/src/librbd/cache/SharedPersistentObjectCacher.h
86 #include "include/buffer_fwd.h"
87 #include "include/int_types.h"
88 -#include "os/CacheStore/SyncFile.h"
89 +#include "SharedPersistentObjectCacherFile.h"
90 #include "common/Mutex.h"
93 @@ -31,9 +31,9 @@ public:
96 ImageCtxT *m_image_ctx;
97 - std::map<std::string, os::CacheStore::SyncFile*> file_map;
98 - Mutex m_file_map_lock;
99 std::string m_cache_path;
100 + Mutex m_file_map_lock;
101 + std::map<std::string, SyncFile*> file_map;
105 diff --git a/src/librbd/cache/SharedPersistentObjectCacherFile.cc b/src/librbd/cache/SharedPersistentObjectCacherFile.cc
107 index 0000000..75a3053
109 +++ b/src/librbd/cache/SharedPersistentObjectCacherFile.cc
111 +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
112 +// vim: ts=8 sw=2 smarttab
114 +#include "SharedPersistentObjectCacherFile.h"
115 +#include "include/Context.h"
116 +#include "common/dout.h"
117 +#include "common/WorkQueue.h"
118 +#include "librbd/ImageCtx.h"
119 +#include <sys/types.h>
120 +#include <sys/stat.h>
126 +#define dout_subsys ceph_subsys_rbd
128 +#define dout_prefix *_dout << "librbd::cache::SyncFile: " << this << " " \
129 + << __func__ << ": "
134 +SyncFile::SyncFile(CephContext *cct, const std::string &name)
136 + m_name = cct->_conf->get_val<std::string>("rbd_shared_cache_path") + "/rbd_cache." + name;
137 + ldout(cct, 20) << "file path=" << m_name << dendl;
140 +SyncFile::~SyncFile() {
141 + // TODO force proper cleanup
147 +void SyncFile::open(Context *on_finish) {
149 + m_fd = ::open(m_name.c_str(), O_CREAT | O_DIRECT | O_NOATIME | O_RDWR | O_SYNC,
150 + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
156 + on_finish->complete(r);
162 + on_finish->complete(0);
165 +void SyncFile::open() {
168 + m_fd = ::open(m_name.c_str(), O_CREAT | O_NOATIME | O_RDWR | O_SYNC,
169 + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
182 +void SyncFile::read(uint64_t offset, uint64_t length, ceph::bufferlist *bl, Context *on_finish) {
183 + on_finish->complete(read_object_from_file(bl, offset, length));
186 +void SyncFile::write(uint64_t offset, ceph::bufferlist &&bl, bool fdatasync, Context *on_finish) {
187 + on_finish->complete(write_object_to_file(bl, bl.length()));
190 +int SyncFile::write_object_to_file(ceph::bufferlist read_buf, uint64_t object_len) {
192 + ldout(cct, 20) << "cache file name:" << m_name
193 + << ", length:" << object_len << dendl;
196 + int ret = pwrite(m_fd, read_buf.c_str(), object_len, 0);
198 + lderr(cct)<<"write file fail:" << std::strerror(errno) << dendl;
205 +int SyncFile::read_object_from_file(ceph::bufferlist* read_buf, uint64_t object_off, uint64_t object_len) {
207 + ldout(cct, 20) << "offset:" << object_off
208 + << ", length:" << object_len << dendl;
210 + bufferptr buf(object_len);
213 + int ret = pread(m_fd, buf.c_str(), object_len, object_off);
215 + lderr(cct)<<"read file fail:" << std::strerror(errno) << dendl;
218 + read_buf->append(std::move(buf));
223 +} // namespace cache
224 +} // namespace librbd
225 diff --git a/src/librbd/cache/SharedPersistentObjectCacherFile.h b/src/librbd/cache/SharedPersistentObjectCacherFile.h
227 index 0000000..ccbe730
229 +++ b/src/librbd/cache/SharedPersistentObjectCacherFile.h
231 +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
232 +// vim: ts=8 sw=2 smarttab
234 +#ifndef CEPH_LIBRBD_CACHE_STORE_SYNC_FILE
235 +#define CEPH_LIBRBD_CACHE_STORE_SYNC_FILE
237 +#include "include/buffer_fwd.h"
238 +#include <sys/mman.h>
251 + SyncFile(CephContext *cct, const std::string &name);
254 + // TODO use IO queue instead of individual commands so operations can be
255 + // submitted in batch
257 + // TODO use scatter/gather API
259 + void open(Context *on_finish);
264 + void close(Context *on_finish);
265 + void remove(Context *on_finish);
267 + void read(uint64_t offset, uint64_t length, ceph::bufferlist *bl, Context *on_finish);
269 + void write(uint64_t offset, ceph::bufferlist &&bl, bool fdatasync, Context *on_finish);
271 + void discard(uint64_t offset, uint64_t length, bool fdatasync, Context *on_finish);
273 + void truncate(uint64_t length, bool fdatasync, Context *on_finish);
275 + void fsync(Context *on_finish);
277 + void fdatasync(Context *on_finish);
279 + uint64_t filesize();
281 + int load(void** dest, uint64_t filesize);
286 + int write_object_to_file(ceph::bufferlist read_buf, uint64_t object_len);
287 + int read_object_from_file(ceph::bufferlist* read_buf, uint64_t object_off, uint64_t object_len);
291 + std::string m_name;
294 + int write(uint64_t offset, const ceph::bufferlist &bl, bool fdatasync);
295 + int read(uint64_t offset, uint64_t length, ceph::bufferlist *bl);
296 + int discard(uint64_t offset, uint64_t length, bool fdatasync);
297 + int truncate(uint64_t length, bool fdatasync);
301 +} // namespace cache
302 +} // namespace librbd
304 +#endif // CEPH_LIBRBD_CACHE_STORE_SYNC_FILE
305 diff --git a/src/librbd/cache/SharedPersistentObjectCacherObjectDispatch.cc b/src/librbd/cache/SharedPersistentObjectCacherObjectDispatch.cc
306 index 90d886c..2aa5cad 100644
307 --- a/src/librbd/cache/SharedPersistentObjectCacherObjectDispatch.cc
308 +++ b/src/librbd/cache/SharedPersistentObjectCacherObjectDispatch.cc
309 @@ -52,7 +52,7 @@ void SharedPersistentObjectCacherObjectDispatch<I>::init() {
310 ldout(cct, 20) << "parent image: setup SRO cache client = " << dendl;
312 std::string controller_path = "/tmp/rbd_shared_readonly_cache_demo";
313 - m_cache_client = new CacheClient(io_service, controller_path.c_str(),
314 + m_cache_client = new rbd::cache::CacheClient(io_service, controller_path.c_str(),
315 ([&](std::string s){client_handle_request(s);}));
317 int ret = m_cache_client->connect();
318 @@ -120,7 +120,7 @@ void SharedPersistentObjectCacherObjectDispatch<I>::client_handle_request(std::s
319 auto cct = m_image_ctx->cct;
320 ldout(cct, 20) << dendl;
322 - rbdsc_req_type_t *io_ctx = (rbdsc_req_type_t*)(msg.c_str());
323 + rbd::cache::rbdsc_req_type_t *io_ctx = (rbd::cache::rbdsc_req_type_t*)(msg.c_str());
325 switch (io_ctx->type) {
326 case RBDSC_REGISTER_REPLY: {
327 diff --git a/src/librbd/cache/SharedPersistentObjectCacherObjectDispatch.h b/src/librbd/cache/SharedPersistentObjectCacherObjectDispatch.h
328 index 1ede804..200688f 100644
329 --- a/src/librbd/cache/SharedPersistentObjectCacherObjectDispatch.h
330 +++ b/src/librbd/cache/SharedPersistentObjectCacherObjectDispatch.h
331 @@ -115,7 +115,7 @@ private:
332 ImageCtxT* m_image_ctx;
334 void client_handle_request(std::string msg);
335 - CacheClient *m_cache_client = nullptr;
336 + rbd::cache::CacheClient *m_cache_client = nullptr;
337 boost::asio::io_service io_service;
340 diff --git a/src/os/CacheStore/SyncFile.cc b/src/os/CacheStore/SyncFile.cc
341 deleted file mode 100644
342 index 5352bde..0000000
343 --- a/src/os/CacheStore/SyncFile.cc
346 -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
347 -// vim: ts=8 sw=2 smarttab
349 -#include "os/CacheStore/SyncFile.h"
350 -#include "include/Context.h"
351 -#include "common/dout.h"
352 -#include "common/WorkQueue.h"
353 -#include "librbd/ImageCtx.h"
354 -#include <sys/types.h>
355 -#include <sys/stat.h>
361 -#define dout_subsys ceph_subsys_rbd
363 -#define dout_prefix *_dout << "librbd::file::SyncFile: " << this << " " \
364 - << __func__ << ": "
367 -namespace CacheStore {
369 -SyncFile::SyncFile(CephContext *cct, const std::string &name)
372 - m_name = cct->_conf->get_val<std::string>("rbd_shared_cache_path") + "/rbd_cache." + name;
373 - ldout(cct, 20) << "file path=" << m_name << dendl;
376 -SyncFile::~SyncFile()
378 - // TODO force proper cleanup
384 -void SyncFile::open(Context *on_finish)
387 - m_fd = ::open(m_name.c_str(), O_CREAT | O_DIRECT | O_NOATIME | O_RDWR | O_SYNC,
388 - S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
394 - on_finish->complete(r);
400 - on_finish->complete(0);
403 -void SyncFile::open()
407 - m_fd = ::open(m_name.c_str(), O_CREAT | O_NOATIME | O_RDWR | O_SYNC,
408 - S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
421 -int SyncFile::write_object_to_file(ceph::bufferlist read_buf, uint64_t object_len) {
423 - ldout(cct, 20) << "cache file name:" << m_name
424 - << ", length:" << object_len << dendl;
427 - int ret = pwrite(m_fd, read_buf.c_str(), object_len, 0);
429 - lderr(cct)<<"write file fail:" << std::strerror(errno) << dendl;
436 -int SyncFile::read_object_from_file(ceph::bufferlist* read_buf, uint64_t object_off, uint64_t object_len) {
438 - ldout(cct, 20) << "offset:" << object_off
439 - << ", length:" << object_len << dendl;
441 - bufferptr buf(object_len);
444 - int ret = pread(m_fd, buf.c_str(), object_len, object_off);
446 - lderr(cct)<<"read file fail:" << std::strerror(errno) << dendl;
449 - read_buf->append(std::move(buf));
454 -} // namespace CacheStore
456 diff --git a/src/os/CacheStore/SyncFile.h b/src/os/CacheStore/SyncFile.h
457 deleted file mode 100644
458 index 81602ce..0000000
459 --- a/src/os/CacheStore/SyncFile.h
462 -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
463 -// vim: ts=8 sw=2 smarttab
465 -#ifndef CEPH_LIBOS_CACHE_STORE_SYNC_FILE
466 -#define CEPH_LIBOS_CACHE_STORE_SYNC_FILE
468 -#include "include/buffer_fwd.h"
469 -#include <sys/mman.h>
478 -namespace CacheStore {
482 - SyncFile(CephContext *cct, const std::string &name);
485 - // TODO use IO queue instead of individual commands so operations can be
486 - // submitted in batch
488 - // TODO use scatter/gather API
490 - void open(Context *on_finish);
495 - void close(Context *on_finish);
496 - void remove(Context *on_finish);
498 - void read(uint64_t offset, uint64_t length, ceph::bufferlist *bl, Context *on_finish);
500 - void write(uint64_t offset, ceph::bufferlist &&bl, bool fdatasync, Context *on_finish);
502 - void discard(uint64_t offset, uint64_t length, bool fdatasync, Context *on_finish);
504 - void truncate(uint64_t length, bool fdatasync, Context *on_finish);
506 - void fsync(Context *on_finish);
508 - void fdatasync(Context *on_finish);
510 - uint64_t filesize();
512 - int load(void** dest, uint64_t filesize);
517 - int write_object_to_file(ceph::bufferlist read_buf, uint64_t object_len);
518 - int read_object_from_file(ceph::bufferlist* read_buf, uint64_t object_off, uint64_t object_len);
522 - std::string m_name;
525 - int write(uint64_t offset, const ceph::bufferlist &bl, bool fdatasync);
526 - int read(uint64_t offset, uint64_t length, ceph::bufferlist *bl);
527 - int discard(uint64_t offset, uint64_t length, bool fdatasync);
528 - int truncate(uint64_t length, bool fdatasync);
532 -} // namespace CacheStore
535 -#endif // CEPH_LIBOS_CACHE_STORE_SYNC_FILE
536 diff --git a/src/tools/rbd_cache/CMakeLists.txt b/src/tools/rbd_cache/CMakeLists.txt
537 index 08eae60..597d802 100644
538 --- a/src/tools/rbd_cache/CMakeLists.txt
539 +++ b/src/tools/rbd_cache/CMakeLists.txt
541 add_executable(rbd-cache
542 - ${CMAKE_SOURCE_DIR}/src/os/CacheStore/SyncFile.cc
543 + ${CMAKE_SOURCE_DIR}/src/librbd/cache/SharedPersistentObjectCacherFile.cc
547 diff --git a/src/tools/rbd_cache/CacheController.cc b/src/tools/rbd_cache/CacheController.cc
548 index c914358..e73ba25 100644
549 --- a/src/tools/rbd_cache/CacheController.cc
550 +++ b/src/tools/rbd_cache/CacheController.cc
552 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
553 // vim: ts=8 sw=2 smarttab
555 -#include "CacheController.hpp"
556 +#include "CacheController.h"
558 #define dout_context g_ceph_context
559 #define dout_subsys ceph_subsys_rbd_cache
561 #define dout_prefix *_dout << "rbd::cache::CacheController: " << this << " " \
567 class ThreadPoolSingleton : public ThreadPool {
569 @@ -103,3 +105,8 @@ void CacheController::handle_request(uint64_t sesstion_id, std::string msg){
575 +} // namespace cache
578 diff --git a/src/tools/rbd_cache/CacheController.h b/src/tools/rbd_cache/CacheController.h
580 index 0000000..0e3abc1
582 +++ b/src/tools/rbd_cache/CacheController.h
584 +#ifndef CACHE_CONTROLLER_H
585 +#define CACHE_CONTROLLER_H
589 +#include "common/Formatter.h"
590 +#include "common/admin_socket.h"
591 +#include "common/debug.h"
592 +#include "common/errno.h"
593 +#include "common/ceph_context.h"
594 +#include "common/Mutex.h"
595 +#include "common/WorkQueue.h"
596 +#include "include/rados/librados.hpp"
597 +#include "include/rbd/librbd.h"
598 +#include "include/assert.h"
599 +#include "librbd/ImageCtx.h"
600 +#include "librbd/ImageState.h"
602 +#include "CacheControllerSocket.hpp"
603 +#include "ObjectCacheStore.h"
606 +using boost::asio::local::stream_protocol;
611 +class CacheController {
613 + CacheController(CephContext *cct, const std::vector<const char*> &args);
614 + ~CacheController();
620 + void handle_signal(int sinnum);
624 + void handle_request(uint64_t sesstion_id, std::string msg);
627 + boost::asio::io_service io_service;
628 + CacheServer *m_cache_server;
629 + std::vector<const char*> m_args;
630 + CephContext *m_cct;
631 + ObjectCacheStore *m_object_cache_store;
632 + ContextWQ* pcache_op_work_queue;
636 +} // namespace cache
639 diff --git a/src/tools/rbd_cache/CacheController.hpp b/src/tools/rbd_cache/CacheController.hpp
640 deleted file mode 100644
641 index 97113e4..0000000
642 --- a/src/tools/rbd_cache/CacheController.hpp
645 -#ifndef CACHE_CONTROLLER_H
646 -#define CACHE_CONTROLLER_H
650 -#include "common/Formatter.h"
651 -#include "common/admin_socket.h"
652 -#include "common/debug.h"
653 -#include "common/errno.h"
654 -#include "common/ceph_context.h"
655 -#include "common/Mutex.h"
656 -#include "common/WorkQueue.h"
657 -#include "include/rados/librados.hpp"
658 -#include "include/rbd/librbd.h"
659 -#include "include/assert.h"
660 -#include "librbd/ImageCtx.h"
661 -#include "librbd/ImageState.h"
663 -#include "CacheControllerSocket.hpp"
664 -#include "ObjectCacheStore.h"
667 -using boost::asio::local::stream_protocol;
669 -class CacheController {
671 - CacheController(CephContext *cct, const std::vector<const char*> &args);
672 - ~CacheController();
678 - void handle_signal(int sinnum);
682 - void handle_request(uint64_t sesstion_id, std::string msg);
685 - boost::asio::io_service io_service;
686 - CacheServer *m_cache_server;
687 - std::vector<const char*> m_args;
688 - CephContext *m_cct;
689 - ObjectCacheStore *m_object_cache_store;
690 - ContextWQ* pcache_op_work_queue;
694 diff --git a/src/tools/rbd_cache/CacheControllerSocket.hpp b/src/tools/rbd_cache/CacheControllerSocket.hpp
695 index 6e1a743..967af1d 100644
696 --- a/src/tools/rbd_cache/CacheControllerSocket.hpp
697 +++ b/src/tools/rbd_cache/CacheControllerSocket.hpp
700 using boost::asio::local::stream_protocol;
705 class session : public std::enable_shared_from_this<session> {
707 session(uint64_t session_id, boost::asio::io_service& io_service, ProcessMsg processmsg)
708 @@ -122,4 +125,7 @@ private:
709 std::map<uint64_t, session_ptr> session_map;
712 +} // namespace cache
716 diff --git a/src/tools/rbd_cache/CacheControllerSocketClient.hpp b/src/tools/rbd_cache/CacheControllerSocketClient.hpp
717 index 8e61aa9..57be78e 100644
718 --- a/src/tools/rbd_cache/CacheControllerSocketClient.hpp
719 +++ b/src/tools/rbd_cache/CacheControllerSocketClient.hpp
722 using boost::asio::local::stream_protocol;
729 CacheClient(boost::asio::io_service& io_service,
730 @@ -128,4 +131,6 @@ public:
731 bool connected = false;
734 +} // namespace cache
737 diff --git a/src/tools/rbd_cache/CacheControllerSocketCommon.h b/src/tools/rbd_cache/CacheControllerSocketCommon.h
738 index e253bb1..ab89155 100644
739 --- a/src/tools/rbd_cache/CacheControllerSocketCommon.h
740 +++ b/src/tools/rbd_cache/CacheControllerSocketCommon.h
742 #define RBDSC_LOOKUP_REPLY 0X16
743 #define RBDSC_READ_RADOS 0X16
748 typedef std::function<void(uint64_t, std::string)> ProcessMsg;
749 typedef std::function<void(std::string)> ClientProcessMsg;
750 typedef uint8_t rbdsc_req_type;
751 @@ -40,4 +43,6 @@ struct rbdsc_req_type_t {
755 +} // namespace cache
758 diff --git a/src/tools/rbd_cache/ObjectCacheStore.cc b/src/tools/rbd_cache/ObjectCacheStore.cc
759 index 90b407c..9572a1a 100644
760 --- a/src/tools/rbd_cache/ObjectCacheStore.cc
761 +++ b/src/tools/rbd_cache/ObjectCacheStore.cc
763 #define dout_prefix *_dout << "rbd::cache::ObjectCacheStore: " << this << " " \
769 ObjectCacheStore::ObjectCacheStore(CephContext *cct, ContextWQ* work_queue)
770 : m_cct(cct), m_work_queue(work_queue),
771 @@ -77,7 +79,7 @@ int ObjectCacheStore::do_promote(std::string pool_name, std::string object_name)
774 // persistent to cache
775 - os::CacheStore::SyncFile cache_file(m_cct, cache_file_name);
776 + librbd::cache::SyncFile cache_file(m_cct, cache_file_name);
778 ret = cache_file.write_object_to_file(read_buf, object_size);
780 @@ -145,3 +147,6 @@ int ObjectCacheStore::promote_object(librados::IoCtx* ioctx, std::string object_
785 +} // namespace cache
787 diff --git a/src/tools/rbd_cache/ObjectCacheStore.h b/src/tools/rbd_cache/ObjectCacheStore.h
788 index 12f8399..a81beea 100644
789 --- a/src/tools/rbd_cache/ObjectCacheStore.h
790 +++ b/src/tools/rbd_cache/ObjectCacheStore.h
792 #include "include/rbd/librbd.h"
793 #include "librbd/ImageCtx.h"
794 #include "librbd/ImageState.h"
795 -#include "os/CacheStore/SyncFile.h"
796 +#include "librbd/cache/SharedPersistentObjectCacherFile.h"
798 using librados::Rados;
799 using librados::IoCtx;
804 typedef shared_ptr<librados::Rados> RadosRef;
805 typedef shared_ptr<librados::IoCtx> IoCtxRef;
807 @@ -59,7 +62,9 @@ class ObjectCacheStore
809 std::map<std::string, librados::IoCtx*> m_ioctxs;
811 - os::CacheStore::SyncFile *m_cache_file;
812 + librbd::cache::SyncFile *m_cache_file;
816 +} // namespace cache
818 diff --git a/src/tools/rbd_cache/main.cc b/src/tools/rbd_cache/main.cc
819 index 336a581..a7c5b64 100644
820 --- a/src/tools/rbd_cache/main.cc
821 +++ b/src/tools/rbd_cache/main.cc
823 #include "common/errno.h"
824 #include "global/global_init.h"
825 #include "global/signal_handler.h"
826 -#include "CacheController.hpp"
827 +#include "CacheController.h"
831 -CacheController *cachectl = nullptr;
832 +rbd::cache::CacheController *cachectl = nullptr;
835 std::cout << "usage: cache controller [options...]" << std::endl;
836 @@ -64,7 +64,7 @@ int main(int argc, const char **argv)
837 // disable unnecessary librbd cache
838 g_ceph_context->_conf->set_val_or_die("rbd_cache", "false");
840 - cachectl = new CacheController(g_ceph_context, cmd_args);
841 + cachectl = new rbd::cache::CacheController(g_ceph_context, cmd_args);
842 int r = cachectl->init();
844 std::cerr << "failed to initialize: " << cpp_strerror(r) << std::endl;