Skip to content

Commit

Permalink
librbd: use image size and parent overlap from active shrink op
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Jason Dillaman authored and jdurgin committed Mar 10, 2015
1 parent 9c5c665 commit 1d29890
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/librbd/AsyncResizeRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ class AsyncResizeRequest : public AsyncRequest

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
Expand Down
12 changes: 12 additions & 0 deletions src/librbd/ImageCtx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1d29890

Please sign in to comment.