From 8be1718f734eafa51b7c78cc07b7968e68e00cb2 Mon Sep 17 00:00:00 2001 From: lixiaoy1 Date: Fri, 20 Nov 2020 06:06:15 -0500 Subject: [PATCH] librbd/plugin: delete field m_image_ctx librbd::plugin::ParentCache may be shared by more than one images. Signed-off-by: Li, Xiaoyan --- src/librbd/plugin/ParentCache.cc | 12 +++++------- src/librbd/plugin/ParentCache.h | 3 +-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/librbd/plugin/ParentCache.cc b/src/librbd/plugin/ParentCache.cc index 0c50c8e719705..cdbe8ff9b3cda 100644 --- a/src/librbd/plugin/ParentCache.cc +++ b/src/librbd/plugin/ParentCache.cc @@ -35,20 +35,19 @@ namespace plugin { template void ParentCache::init(I* image_ctx, Api& api, HookPoints* hook_points, Context* on_finish) { - m_image_ctx = image_ctx; - bool parent_cache_enabled = m_image_ctx->config.template get_val( + bool parent_cache_enabled = image_ctx->config.template get_val( "rbd_parent_cache_enabled"); - if (m_image_ctx->child == nullptr || !parent_cache_enabled || - !m_image_ctx->data_ctx.is_valid()) { + if (image_ctx->child == nullptr || !parent_cache_enabled || + !image_ctx->data_ctx.is_valid()) { on_finish->complete(0); return; } - auto cct = m_image_ctx->cct; + auto cct = image_ctx->cct; ldout(cct, 5) << dendl; auto parent_cache = cache::ParentCacheObjectDispatch::create( - m_image_ctx, api); + image_ctx, api); on_finish = new LambdaContext([this, on_finish, parent_cache](int r) { if (r < 0) { // the object dispatcher will handle cleanup if successfully initialized @@ -62,7 +61,6 @@ void ParentCache::init(I* image_ctx, Api& api, HookPoints* hook_points, template void ParentCache::handle_init_parent_cache(int r, Context* on_finish) { - auto cct = m_image_ctx->cct; ldout(cct, 5) << "r=" << r << dendl; if (r < 0) { diff --git a/src/librbd/plugin/ParentCache.h b/src/librbd/plugin/ParentCache.h index e456c5ac3d806..276170b258cbc 100644 --- a/src/librbd/plugin/ParentCache.h +++ b/src/librbd/plugin/ParentCache.h @@ -23,9 +23,8 @@ public: Context* on_finish) override; private: - ImageCtxT* m_image_ctx = nullptr; - void handle_init_parent_cache(int r, Context* on_finish); + using ceph::Plugin::cct; }; -- 2.39.5