From: Jason Dillaman Date: Tue, 10 Mar 2015 05:04:15 +0000 (-0400) Subject: librbd: avoid canceling object map / header updates X-Git-Tag: v0.94~47^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7f246b8962db8d1ff2f0303db22a2c3997f6720a;p=ceph.git librbd: avoid canceling object map / header updates During a resize, reduce the possibility that the object map and the header will get out-of-sync during a resize operation that is canceled. Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/AsyncRequest.h b/src/librbd/AsyncRequest.h index 25be0ed6d29d..f81840a0f772 100644 --- a/src/librbd/AsyncRequest.h +++ b/src/librbd/AsyncRequest.h @@ -19,7 +19,7 @@ public: virtual ~AsyncRequest(); void complete(int r) { - if (m_canceled) { + if (m_canceled && safely_cancel(r)) { m_on_finish->complete(-ERESTART); delete this; } else if (should_complete(r)) { @@ -44,6 +44,9 @@ protected: librados::AioCompletion *create_callback_completion(); Context *create_callback_context(); + virtual bool safely_cancel(int r) { + return true; + } virtual bool should_complete(int r) = 0; private: diff --git a/src/librbd/AsyncResizeRequest.cc b/src/librbd/AsyncResizeRequest.cc index 914e85f60e07..ac64ef6516e0 100644 --- a/src/librbd/AsyncResizeRequest.cc +++ b/src/librbd/AsyncResizeRequest.cc @@ -46,6 +46,23 @@ AsyncResizeRequest::~AsyncResizeRequest() { } } +bool AsyncResizeRequest::safely_cancel(int r) { + CephContext *cct = m_image_ctx.cct; + ldout(cct, 5) << this << " safely_cancel: " << " r=" << r << dendl; + + // avoid interrupting the object map / header updates + switch (m_state) { + case STATE_GROW_OBJECT_MAP: + case STATE_UPDATE_HEADER: + case STATE_SHRINK_OBJECT_MAP: + ldout(cct, 5) << "delaying cancel request" << dendl; + return false; + default: + break; + } + return true; +} + bool AsyncResizeRequest::should_complete(int r) { CephContext *cct = m_image_ctx.cct; ldout(cct, 5) << this << " should_complete: " << " r=" << r << dendl; diff --git a/src/librbd/AsyncResizeRequest.h b/src/librbd/AsyncResizeRequest.h index 5ac83512fb47..ef806a8d266f 100644 --- a/src/librbd/AsyncResizeRequest.h +++ b/src/librbd/AsyncResizeRequest.h @@ -83,6 +83,7 @@ private: xlist::item m_xlist_item; + virtual bool safely_cancel(int r); virtual bool should_complete(int r); void send_flush();