]> 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)
committerNathan Cutler <ncutler@suse.com>
Fri, 14 Aug 2020 21:24:08 +0000 (23:24 +0200)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit ea6c9bde0437cc163a0f6a52b3ef1f45eaa6f88b)

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

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

index d83c3753062b57f97f2980eaffa3de900a89d46f..70c40650d00ac97980870d960c2aead20428160a 100644 (file)
@@ -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);
index 79908cf18dc43d72067187b9b1dde2e569f2859f..ff6faad6a4698f72b97e2c2457ff99071cd7f4a1 100644 (file)
@@ -42,6 +42,7 @@ class SafeTimer;
 
 namespace librbd {
 
+  template <typename> class ConfigWatcher;
   template <typename> class ExclusiveLock;
   template <typename> class ImageState;
   template <typename> class ImageWatcher;
@@ -109,6 +110,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 feae4160e521015440965cbbc536bb60d1f9811f..ec8b7fa7e04823658297506b10f2c84961811b1e 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 88d5d62e0e5ab27a981a4f7f5a6c4d3355067119..2e30242e8f425faa7924c114c6956e7ed0ceab53 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"
@@ -500,6 +501,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,