From: Jason Dillaman Date: Mon, 27 Jul 2020 20:29:05 +0000 (-0400) Subject: librbd: initialize/shut down config watcher during image open/close X-Git-Tag: v15.2.5~58^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ada201d460d37d68275ed4b35f6e3ec293f247fc;p=ceph.git librbd: initialize/shut down config watcher during image open/close Signed-off-by: Jason Dillaman (cherry picked from commit ea6c9bde0437cc163a0f6a52b3ef1f45eaa6f88b) Conflicts: src/librbd/ImageCtx.h - AsioEngine has not been backported yet --- diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index d83c3753062..70c40650d00 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -158,6 +158,7 @@ public: } 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 79908cf18dc..ff6faad6a46 100644 --- a/src/librbd/ImageCtx.h +++ b/src/librbd/ImageCtx.h @@ -42,6 +42,7 @@ class SafeTimer; namespace librbd { + template class ConfigWatcher; template class ExclusiveLock; template class ImageState; template class ImageWatcher; @@ -109,6 +110,8 @@ namespace librbd { cls::rbd::SnapshotNamespace snap_namespace; std::string snap_name; IoCtx data_ctx, 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 feae4160e52..ec8b7fa7e04 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" @@ -34,6 +35,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 88d5d62e0e5..2e30242e8f4 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/Utils.h" #include "librbd/cache/ObjectCacherObjectDispatch.h" @@ -500,6 +501,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,