librbd: avoid second close attempt of invalid parent image

Fixes: http://tracker.ceph.com/issues/15574
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
Jason Dillaman 2016-04-27 15:45:25 -04:00
parent 27b467bad5
commit e91e7f8d9c
2 changed files with 22 additions and 17 deletions

View 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();

View 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
*/