]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: use image size and parent overlap from active shrink op
authorJason Dillaman <dillaman@redhat.com>
Tue, 10 Mar 2015 15:17:49 +0000 (11:17 -0400)
committerJosh Durgin <jdurgin@redhat.com>
Tue, 10 Mar 2015 22:41:46 +0000 (15:41 -0700)
If a shrink operation is in progress, all operations should use
the new size and new parent overlap for IO operations.

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

index de6a49b0ee9894372a9bad3894a0f437e28b177e..655b2135a9c66305c8a93ed65115f1f1d1333d36 100644 (file)
@@ -22,6 +22,18 @@ public:
 
   virtual void send();
 
+  inline bool shrinking() const {
+    return m_new_size < m_original_size;
+  }
+
+  inline uint64_t get_image_size() const {
+    return m_new_size;
+  }
+
+  inline uint64_t get_parent_overlap() const {
+    return m_new_parent_overlap;
+  }
+
 private:
   /**
    * Resize goes through the following state machine to resize the image
index 0b8d3e6c37dd95469f0e6cdd76795f00c7050b19..10b0231c0714b8ae84f767ed05eb22ab853ed704 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "librbd/AsyncOperation.h"
 #include "librbd/AsyncRequest.h"
+#include "librbd/AsyncResizeRequest.h"
 #include "librbd/internal.h"
 #include "librbd/ImageCtx.h"
 #include "librbd/ImageWatcher.h"
@@ -433,6 +434,10 @@ namespace librbd {
   {
     assert(snap_lock.is_locked());
     if (in_snap_id == CEPH_NOSNAP) {
+      if (!async_resize_reqs.empty() &&
+          async_resize_reqs.front()->shrinking()) {
+        return async_resize_reqs.front()->get_image_size();
+      }
       return size;
     }
 
@@ -527,6 +532,13 @@ namespace librbd {
 
   int ImageCtx::get_parent_overlap(snap_t in_snap_id, uint64_t *overlap) const
   {
+    assert(snap_lock.is_locked());
+    if (in_snap_id == CEPH_NOSNAP && !async_resize_reqs.empty() &&
+        async_resize_reqs.front()->shrinking()) {
+      *overlap = async_resize_reqs.front()->get_parent_overlap();
+      return 0;
+    }
+
     const parent_info *info = get_parent_info(in_snap_id);
     if (info) {
       *overlap = info->overlap;