template <typename I>
ParentCacheObjectDispatch<I>::ParentCacheObjectDispatch(
I* image_ctx) : m_image_ctx(image_ctx), m_cache_client(nullptr),
- m_initialized(false), m_re_connecting(false),
+ m_initialized(false), m_connecting(false),
m_lock("librbd::cache::ParentCacheObjectDispatch::m_lock") {
std::string controller_path =
((CephContext*)(m_image_ctx->cct))->_conf.get_val<std::string>("immutable_object_cache_sock");
return;
}
- C_SaferCond* cond = new C_SaferCond();
- Context* create_session_ctx = new FunctionContext([cond](int ret) {
- cond->complete(0);
+ ceph_assert(m_connecting.load() == false);
+ m_connecting.store(true);
+ Context* create_session_ctx = new FunctionContext([this](int ret) {
+ Mutex::Locker locker(m_lock);
+ m_connecting.store(false);
});
create_cache_session(create_session_ctx, false);
- cond->wait();
m_image_ctx->io_object_dispatcher->register_object_dispatch(this);
m_initialized = true;
if (!m_cache_client->is_session_work()) {
{
Mutex::Locker locker(m_lock);
- if (m_re_connecting.load()) {
+ if (m_connecting.load()) {
ldout(cct, 5) << "Parent cache is re-connecting RO daemon, "
<< "dispatch current request to lower object layer " << dendl;
return false;
}
- m_re_connecting.store(true);
+ m_connecting.store(true);
}
- ceph_assert(m_re_connecting.load());
+ ceph_assert(m_connecting.load());
Context* on_finish = new FunctionContext([this](int ret) {
- m_re_connecting.store(false);
+ m_connecting.store(false);
});
create_cache_session(on_finish, true);
CephContext *cct = m_image_ctx->cct;
if (!m_image_ctx->cache || m_image_ctx->child != nullptr) {
- // enable Shared Read-only cache for parent image
+ // enable Parent cache for parent image
bool parent_cache_enabled = m_image_ctx->config.template get_val<bool>(
"rbd_parent_cache_enabled");
+
if (m_image_ctx->child != nullptr && parent_cache_enabled ) {
ldout(cct, 10) << this << " " << "setting up parent cache"<< dendl;
- auto sro_cache = cache::ParentCacheObjectDispatch<I>::create(m_image_ctx);
- sro_cache->init();
+ auto parent_cache = cache::ParentCacheObjectDispatch<I>::create(m_image_ctx);
+ parent_cache->init();
}
return send_register_watch(result);
}