#include "common/errno.h"
#include "common/perf_counters.h"
#include "common/WorkQueue.h"
+#include "common/Timer.h"
#include "librbd/AioImageRequestWQ.h"
#include "librbd/AioCompletion.h"
}
};
+class SafeTimerSingleton : public SafeTimer {
+public:
+ Mutex lock;
+
+ explicit SafeTimerSingleton(CephContext *cct)
+ : SafeTimer(cct, lock, true),
+ lock("librbd::Journal::SafeTimerSingleton::lock") {
+ init();
+ }
+ virtual ~SafeTimerSingleton() {
+ Mutex::Locker locker(lock);
+ shutdown();
+ }
+};
+
struct C_FlushCache : public Context {
ImageCtx *image_ctx;
Context *on_safe;
thread_pool_singleton, "librbd::thread_pool");
return thread_pool_singleton;
}
+
+ void ImageCtx::get_timer_instance(CephContext *cct, SafeTimer **timer,
+ Mutex **timer_lock) {
+ SafeTimerSingleton *safe_timer_singleton;
+ cct->lookup_or_create_singleton_object<SafeTimerSingleton>(
+ safe_timer_singleton, "librbd::journal::safe_timer");
+ *timer = safe_timer_singleton;
+ *timer_lock = &safe_timer_singleton->lock;
+ }
}
class Finisher;
class PerfCounters;
class ThreadPool;
+class SafeTimer;
namespace librbd {
void set_journal_policy(journal::Policy *policy);
static ThreadPool *get_thread_pool_instance(CephContext *cct);
+ static void get_timer_instance(CephContext *cct, SafeTimer **timer,
+ Mutex **timer_lock);
};
}
}
};
-class SafeTimerSingleton : public SafeTimer {
-public:
- Mutex lock;
-
- explicit SafeTimerSingleton(CephContext *cct)
- : SafeTimer(cct, lock, true),
- lock("librbd::Journal::SafeTimerSingleton::lock") {
- init();
- }
- virtual ~SafeTimerSingleton() {
- Mutex::Locker locker(lock);
- shutdown();
- }
-};
-
template <typename J>
int open_journaler(CephContext *cct, J *journaler,
cls::journal::Client *client,
m_work_queue = new ContextWQ("librbd::journal::work_queue",
cct->_conf->rbd_op_thread_timeout,
thread_pool_singleton);
-
- SafeTimerSingleton *safe_timer_singleton;
- cct->lookup_or_create_singleton_object<SafeTimerSingleton>(
- safe_timer_singleton, "librbd::journal::safe_timer");
- m_timer = safe_timer_singleton;
- m_timer_lock = &safe_timer_singleton->lock;
+ ImageCtx::get_timer_instance(cct, &m_timer, &m_timer_lock);
}
template <typename I>