]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: init asok_hook on open so name is always known 7736/head
authorMykola Golub <mgolub@mirantis.com>
Tue, 23 Feb 2016 20:20:51 +0000 (22:20 +0200)
committerMykola Golub <mgolub@mirantis.com>
Wed, 24 Feb 2016 14:28:05 +0000 (16:28 +0200)
Signed-off-by: Mykola Golub <mgolub@mirantis.com>
src/librbd/ImageCtx.cc
src/librbd/ImageCtx.h
src/librbd/image/CloseRequest.cc

index 762d637421e2f6ccf6baecf9fd39da6528db203d..fa7c5a52e306ca64c617af8c26e76dd91edaa0c9 100644 (file)
@@ -175,8 +175,6 @@ struct C_InvalidateCache : public Context {
     if (snap)
       snap_name = snap;
 
-    asok_hook = new LibrbdAdminSocketHook(this);
-
     memset(&header, 0, sizeof(header));
     memset(&layout, 0, sizeof(layout));
 
@@ -196,6 +194,7 @@ struct C_InvalidateCache : public Context {
     assert(exclusive_lock == NULL);
     assert(object_map == NULL);
     assert(journal == NULL);
+    assert(asok_hook == NULL);
 
     if (perfcounter) {
       perf_stop();
@@ -221,7 +220,6 @@ struct C_InvalidateCache : public Context {
 
     delete op_work_queue;
     delete aio_work_queue;
-    delete asok_hook;
     delete operations;
     delete state;
   }
@@ -234,6 +232,8 @@ struct C_InvalidateCache : public Context {
     }
     apply_metadata_confs();
 
+    asok_hook = new LibrbdAdminSocketHook(this);
+
     string pname = string("librbd-") + id + string("-") +
       data_ctx.get_pool_name() + string("-") + name;
     if (!snap_name.empty()) {
@@ -286,6 +286,15 @@ struct C_InvalidateCache : public Context {
     readahead.set_max_readahead_size(readahead_max_bytes);
   }
 
+  void ImageCtx::shutdown() {
+    if (image_watcher != nullptr) {
+      unregister_watch();
+    }
+
+    delete asok_hook;
+    asok_hook = nullptr;
+  }
+
   void ImageCtx::init_layout()
   {
     if (stripe_unit == 0 || stripe_count == 0) {
index caf9bdc9bec340910ba9c628e549cc439f472359..0d84f0caad3709e5459bbbfd4b85638eeaeeb600 100644 (file)
@@ -197,6 +197,7 @@ namespace librbd {
             const char *snap, IoCtx& p, bool read_only);
     ~ImageCtx();
     void init();
+    void shutdown();
     void init_layout();
     void perf_start(std::string name);
     void perf_stop();
index 145a998dbf6cf279f51b5a6374f0ffbfe19dda4f..19916396a071510b0526539b95366e4fbf33974a 100644 (file)
@@ -248,10 +248,7 @@ void CloseRequest<I>::handle_flush_image_watcher(int r) {
 
 template <typename I>
 void CloseRequest<I>::finish() {
-  if (m_image_ctx->image_watcher != nullptr) {
-    m_image_ctx->unregister_watch();
-  }
-
+  m_image_ctx->shutdown();
   m_on_finish->complete(m_error_result);
   delete this;
 }