]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: close object map when dynamically disabled
authorJason Dillaman <dillaman@redhat.com>
Wed, 20 Jan 2016 19:00:22 +0000 (14:00 -0500)
committerJason Dillaman <dillaman@redhat.com>
Wed, 20 Jan 2016 19:00:22 +0000 (14:00 -0500)
This will handle the case where the object map lock needs to be
released.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/image/RefreshRequest.cc
src/librbd/image/RefreshRequest.h

index b247c1ff96af13423c0437ab56b3e68977402e20..013b1d6baa62bc6da83474cbb46a3fd7fbcc34b8 100644 (file)
@@ -33,10 +33,9 @@ RefreshRequest<I>::RefreshRequest(I &image_ctx, Context *on_finish)
 
 template <typename I>
 RefreshRequest<I>::~RefreshRequest() {
-  delete m_object_map;
-
   // these require state machine to close
   assert(m_exclusive_lock == nullptr);
+  assert(m_object_map == nullptr);
   assert(m_journal == nullptr);
   assert(m_refresh_parent == nullptr);
 }
@@ -600,7 +599,7 @@ Context *RefreshRequest<I>::handle_v2_shut_down_exclusive_lock(int *result) {
 template <typename I>
 Context *RefreshRequest<I>::send_v2_close_journal() {
   if (m_journal == nullptr) {
-    return send_flush_aio();
+    return send_v2_close_object_map();
   }
 
   CephContext *cct = m_image_ctx.cct;
@@ -629,6 +628,36 @@ Context *RefreshRequest<I>::handle_v2_close_journal(int *result) {
   delete m_journal;
   m_journal = nullptr;
 
+  return send_v2_close_object_map();
+}
+
+template <typename I>
+Context *RefreshRequest<I>::send_v2_close_object_map() {
+  if (m_object_map == nullptr) {
+    return send_flush_aio();
+  }
+
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 10) << this << " " << __func__ << dendl;
+
+  // object map was dynamically disabled
+  using klass = RefreshRequest<I>;
+  Context *ctx = create_context_callback<
+    klass, &klass::handle_v2_close_object_map>(this);
+  m_object_map->close(ctx);
+  return nullptr;
+}
+
+template <typename I>
+Context *RefreshRequest<I>::handle_v2_close_object_map(int *result) {
+  CephContext *cct = m_image_ctx.cct;
+  ldout(cct, 10) << this << " " << __func__ << ": r=" << *result << dendl;
+
+  assert(*result == 0);
+  assert(m_object_map != nullptr);
+  delete m_object_map;
+  m_object_map = nullptr;
+
   return send_flush_aio();
 }
 
index 7fb891b0a9fb65fa69e075b044432cd169a97691..8a08696461d5184513f8845bc4a32278d214f51b 100644 (file)
@@ -164,6 +164,9 @@ private:
   Context *send_v2_close_journal();
   Context *handle_v2_close_journal(int *result);
 
+  Context *send_v2_close_object_map();
+  Context *handle_v2_close_object_map(int *result);
+
   Context *send_flush_aio();
   Context *handle_flush_aio(int *result);