From: Jason Dillaman Date: Tue, 10 Mar 2015 15:17:49 +0000 (-0400) Subject: librbd: use image size and parent overlap from active shrink op X-Git-Tag: v0.94~47^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1d2989096eee89e1d06a1b42b9b9765bbf287e01;p=ceph.git librbd: use image size and parent overlap from active shrink op 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 --- diff --git a/src/librbd/AsyncResizeRequest.h b/src/librbd/AsyncResizeRequest.h index de6a49b0ee98..655b2135a9c6 100644 --- a/src/librbd/AsyncResizeRequest.h +++ b/src/librbd/AsyncResizeRequest.h @@ -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 diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index 0b8d3e6c37dd..10b0231c0714 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -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;