]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: initialize/shut down config watcher during image open/close
authorJason Dillaman <dillaman@redhat.com>
Mon, 27 Jul 2020 20:29:05 +0000 (16:29 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 19 Aug 2020 20:23:53 +0000 (16:23 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit ea6c9bde0437cc163a0f6a52b3ef1f45eaa6f88b)

Conflicts:
src/librbd/ImageCtx.h
- AsioEngine has not been backported yet

(cherry picked from commit ada201d460d37d68275ed4b35f6e3ec293f247fc)

src/librbd/ImageCtx.cc
src/librbd/ImageCtx.h
src/librbd/image/CloseRequest.cc
src/librbd/image/OpenRequest.cc

index bbe3471d8665de533ab7c22128ceeb5620c5fa4f..ed4bc218b0baad85b94600dbf128a51b95e390f4 100644 (file)
@@ -161,6 +161,7 @@ public:
   }
 
   ImageCtx::~ImageCtx() {
+    ceph_assert(config_watcher == nullptr);
     ceph_assert(image_watcher == NULL);
     ceph_assert(exclusive_lock == NULL);
     ceph_assert(object_map == NULL);
index df5271e8efae7fde70291916129b30feb037caa8..df22a0e871e97aed550a30f815c8de05b4c82f5d 100644 (file)
@@ -39,6 +39,7 @@ class SafeTimer;
 
 namespace librbd {
 
+  template <typename> class ConfigWatcher;
   template <typename> class ExclusiveLock;
   template <typename> class ImageState;
   template <typename> class ImageWatcher;
@@ -91,6 +92,8 @@ namespace librbd {
     cls::rbd::SnapshotNamespace snap_namespace;
     std::string snap_name;
     IoCtx data_ctx, md_ctx;
+
+    ConfigWatcher<ImageCtx> *config_watcher = nullptr;
     ImageWatcher<ImageCtx> *image_watcher;
     Journal<ImageCtx> *journal;
 
index 73d671dca74f9f35fdc9d0b37d21d468648ee4fc..c43e1833b0a5d69f7fe6810c49892e713c04d2b2 100644 (file)
@@ -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<I>::CloseRequest(I *image_ctx, Context *on_finish)
 
 template <typename I>
 void CloseRequest<I>::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();
 }
 
index 7d4625aea1c28081f157725fd26ad1723fc2ff42..6f5f30834c755565e5ba1f3a080255c6f5784bfb 100644 (file)
@@ -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"
@@ -497,6 +498,9 @@ void OpenRequest<I>::send_refresh() {
   CephContext *cct = m_image_ctx->cct;
   ldout(cct, 10) << this << " " << __func__ << dendl;
 
+  m_image_ctx->config_watcher = ConfigWatcher<I>::create(*m_image_ctx);
+  m_image_ctx->config_watcher->init();
+
   using klass = OpenRequest<I>;
   RefreshRequest<I> *req = RefreshRequest<I>::create(
     *m_image_ctx, false, m_skip_open_parent_image,