From ea6c9bde0437cc163a0f6a52b3ef1f45eaa6f88b Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Mon, 27 Jul 2020 16:29:05 -0400 Subject: [PATCH] librbd: initialize/shut down config watcher during image open/close Signed-off-by: Jason Dillaman --- src/librbd/ImageCtx.cc | 1 + src/librbd/ImageCtx.h | 2 ++ src/librbd/image/CloseRequest.cc | 8 ++++++++ src/librbd/image/OpenRequest.cc | 4 ++++ 4 files changed, 15 insertions(+) diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index e780cea9635b7..6c4f3f574826f 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -147,6 +147,7 @@ librados::IoCtx duplicate_io_ctx(librados::IoCtx& io_ctx) { } ImageCtx::~ImageCtx() { + ceph_assert(config_watcher == nullptr); ceph_assert(image_watcher == NULL); ceph_assert(exclusive_lock == NULL); ceph_assert(object_map == NULL); diff --git a/src/librbd/ImageCtx.h b/src/librbd/ImageCtx.h index de783e0fb3c68..f81e5a661af40 100644 --- a/src/librbd/ImageCtx.h +++ b/src/librbd/ImageCtx.h @@ -46,6 +46,7 @@ class RADOS; namespace librbd { struct AsioEngine; + template class ConfigWatcher; template class ExclusiveLock; template class ImageState; template class ImageWatcher; @@ -122,6 +123,7 @@ namespace librbd { librados::IoCtx data_ctx; librados::IoCtx md_ctx; + ConfigWatcher *config_watcher = nullptr; ImageWatcher *image_watcher; Journal *journal; diff --git a/src/librbd/image/CloseRequest.cc b/src/librbd/image/CloseRequest.cc index 95460268251e1..f9187910f0ab9 100644 --- a/src/librbd/image/CloseRequest.cc +++ b/src/librbd/image/CloseRequest.cc @@ -4,6 +4,7 @@ #include "librbd/image/CloseRequest.h" #include "common/dout.h" #include "common/errno.h" +#include "librbd/ConfigWatcher.h" #include "librbd/ExclusiveLock.h" #include "librbd/ImageCtx.h" #include "librbd/ImageState.h" @@ -35,6 +36,13 @@ CloseRequest::CloseRequest(I *image_ctx, Context *on_finish) template void CloseRequest::send() { + if (m_image_ctx->config_watcher != nullptr) { + m_image_ctx->config_watcher->shut_down(); + + delete m_image_ctx->config_watcher; + m_image_ctx->config_watcher = nullptr; + } + send_block_image_watcher(); } diff --git a/src/librbd/image/OpenRequest.cc b/src/librbd/image/OpenRequest.cc index 227fadff2d397..2c19d5b930edc 100644 --- a/src/librbd/image/OpenRequest.cc +++ b/src/librbd/image/OpenRequest.cc @@ -5,6 +5,7 @@ #include "common/dout.h" #include "common/errno.h" #include "cls/rbd/cls_rbd_client.h" +#include "librbd/ConfigWatcher.h" #include "librbd/ImageCtx.h" #include "librbd/PluginRegistry.h" #include "librbd/Utils.h" @@ -501,6 +502,9 @@ void OpenRequest::send_refresh() { CephContext *cct = m_image_ctx->cct; ldout(cct, 10) << this << " " << __func__ << dendl; + m_image_ctx->config_watcher = ConfigWatcher::create(*m_image_ctx); + m_image_ctx->config_watcher->init(); + using klass = OpenRequest; RefreshRequest *req = RefreshRequest::create( *m_image_ctx, false, m_skip_open_parent_image, -- 2.39.5