]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: avoid second close attempt of invalid parent image
authorJason Dillaman <dillaman@redhat.com>
Wed, 27 Apr 2016 19:45:25 +0000 (15:45 -0400)
committerAbhishek Varshney <abhishek.varshney@flipkart.com>
Mon, 2 May 2016 06:31:59 +0000 (12:01 +0530)
Fixes: http://tracker.ceph.com/issues/15574
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit e91e7f8d9ce10f0d19c48facfb6318d6b49798e8)

src/librbd/image/RefreshParentRequest.cc
src/librbd/image/RefreshParentRequest.h

index f9ce4f18a891c6c8bee8c2ff7a533aee282c47b1..a44124f391366202d41ba879d639d718ffad9dbd 100644 (file)
@@ -117,8 +117,9 @@ void RefreshParentRequest<I>::send_open_parent() {
   }
 
   using klass = RefreshParentRequest<I>;
-  Context *ctx = create_context_callback<
-    klass, &klass::handle_open_parent, false>(this);
+  Context *ctx = create_async_context_callback(
+    m_child_image_ctx, create_context_callback<
+      klass, &klass::handle_open_parent, false>(this));
   OpenRequest<I> *req = OpenRequest<I>::create(m_parent_image_ctx, ctx);
   req->send();
 }
@@ -132,8 +133,12 @@ Context *RefreshParentRequest<I>::handle_open_parent(int *result) {
   if (*result < 0) {
     lderr(cct) << "failed to open parent image: " << cpp_strerror(*result)
                << dendl;
-    send_close_parent();
-    return nullptr;
+
+    // image already closed by open state machine
+    delete m_parent_image_ctx;
+    m_parent_image_ctx = nullptr;
+
+    return m_on_finish;
   }
 
   send_set_parent_snap();
index e51d24f48b629c7ff4b645521f70e645585e3348..3fe653952c9d8ca7eb56a85f41598bc49e0f9c81 100644 (file)
@@ -38,19 +38,19 @@ private:
    * <start>
    *    |
    *    | (open required)
-   *    |----------------> OPEN_PARENT * * * * * * * *
-   *    |                     |                      *
-   *    |                     v                      * (on error)
-   *    |                  SET_PARENT_SNAP * * * * * *
-   *    |                     |                      *
-   *    |                     v                      *
-   *    \----------------> <apply>                   *
-   *                          |                      *
-   *                          | (close required)     v
-   *                          |-----------------> CLOSE_PARENT
-   *                          |                      |
-   *                          |                      v
-   *                          \-----------------> <finish>
+   *    |----------------> OPEN_PARENT * * * * * * * * * * * * * * *
+   *    |                     |                                    *
+   *    |                     v                                    *
+   *    |                  SET_PARENT_SNAP * * * * * *             *
+   *    |                     |                      *             *
+   *    |                     v                      * (on error)  *
+   *    \----------------> <apply>                   *             *
+   *                          |                      *             *
+   *                          | (close required)     v             *
+   *                          |-----------------> CLOSE_PARENT     *
+   *                          |                      |             *
+   *                          |                      v             *
+   *                          \-----------------> <finish> < * * * *
    *
    * @endverbatim
    */