]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: avoid canceling object map / header updates
authorJason Dillaman <dillaman@redhat.com>
Tue, 10 Mar 2015 05:04:15 +0000 (01:04 -0400)
committerJosh Durgin <jdurgin@redhat.com>
Tue, 10 Mar 2015 22:41:46 +0000 (15:41 -0700)
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 <dillaman@redhat.com>
src/librbd/AsyncRequest.h
src/librbd/AsyncResizeRequest.cc
src/librbd/AsyncResizeRequest.h

index 25be0ed6d29d2caa0b8cbe8c0b39aba2b404eeac..f81840a0f772db094662b9b5bc6e6a45a3aa8c2e 100644 (file)
@@ -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:
index 914e85f60e07103ef96fd805ed72c479dc16de88..ac64ef6516e0f7d773710cf8adbd2556c35387ed 100644 (file)
@@ -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;
index 5ac83512fb475020b8b1706b08ef5ebdd9b18a50..ef806a8d266f7024a4fea05086e1e7bdab4c6947 100644 (file)
@@ -83,6 +83,7 @@ private:
 
   xlist<AsyncResizeRequest *>::item m_xlist_item;
 
+  virtual bool safely_cancel(int r);
   virtual bool should_complete(int r);
 
   void send_flush();