]> git.apps.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, 29 Jul 2020 12:45:51 +0000 (08:45 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/ImageCtx.cc
src/librbd/ImageCtx.h
src/librbd/image/CloseRequest.cc
src/librbd/image/OpenRequest.cc

index e780cea9635b78811439235704035209b2577608..6c4f3f574826f06e856cef6f76261514cf6e89b4 100644 (file)
@@ -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);
index de783e0fb3c68ceae2d0d5ac121bacda2d1adc2f..f81e5a661af40cd80f183fdab2ea5449af52bd91 100644 (file)
@@ -46,6 +46,7 @@ class RADOS;
 namespace librbd {
 
   struct AsioEngine;
+  template <typename> class ConfigWatcher;
   template <typename> class ExclusiveLock;
   template <typename> class ImageState;
   template <typename> class ImageWatcher;
@@ -122,6 +123,7 @@ namespace librbd {
     librados::IoCtx data_ctx;
     librados::IoCtx md_ctx;
 
+    ConfigWatcher<ImageCtx> *config_watcher = nullptr;
     ImageWatcher<ImageCtx> *image_watcher;
     Journal<ImageCtx> *journal;
 
index 95460268251e1cfdb1b679d8e00496ee9c20d11c..f9187910f0ab9bb88d74fc08984dc5d71a4770f7 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"
@@ -35,6 +36,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 227fadff2d39770d427f3b49b09eba3ed1a89440..2c19d5b930edca549cd08f66abda4d41249ac1b1 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/PluginRegistry.h"
 #include "librbd/Utils.h"
@@ -501,6 +502,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,