]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: retrieve image size at start of resize op
authorJason Dillaman <dillaman@redhat.com>
Tue, 10 Mar 2015 18:51:51 +0000 (14:51 -0400)
committerJosh Durgin <jdurgin@redhat.com>
Tue, 10 Mar 2015 22:41:46 +0000 (15:41 -0700)
For the case where multiple resize requests were pending,
queued resizes should use the most recent value for the
current image size -- not the image size when the resize
was queued.

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

index ac64ef6516e0f7d773710cf8adbd2556c35387ed..621d59d967d328799bc9343c78d0e3bc4038b81c 100644 (file)
@@ -17,16 +17,16 @@ namespace librbd
 {
 
 AsyncResizeRequest::AsyncResizeRequest(ImageCtx &image_ctx, Context *on_finish,
-                                      uint64_t original_size,
                                        uint64_t new_size,
-                                      ProgressContext &prog_ctx)
+                                       ProgressContext &prog_ctx)
   : AsyncRequest(image_ctx, on_finish),
-    m_original_size(original_size), m_new_size(new_size),
+    m_original_size(0), m_new_size(new_size),
     m_prog_ctx(prog_ctx), m_new_parent_overlap(0),
     m_xlist_item(this)
 {
   RWLock::WLocker l(m_image_ctx.snap_lock);
   m_image_ctx.async_resize_reqs.push_back(&m_xlist_item);
+  m_original_size = m_image_ctx.size;
   compute_parent_overlap();
 }
 
@@ -37,6 +37,7 @@ AsyncResizeRequest::~AsyncResizeRequest() {
     assert(m_xlist_item.remove_myself());
     if (!m_image_ctx.async_resize_reqs.empty()) {
       next_req = m_image_ctx.async_resize_reqs.front();
+      next_req->m_original_size = m_image_ctx.size;
       next_req->compute_parent_overlap();
     }
   }
index ef806a8d266f7024a4fea05086e1e7bdab4c6947..a719c9d59c4c5a6810d570c6b84b9ee508c4c77b 100644 (file)
@@ -15,9 +15,8 @@ class ProgressContext;
 class AsyncResizeRequest : public AsyncRequest
 {
 public:
-  AsyncResizeRequest(ImageCtx &image_ctx, Context *on_finish,
-                    uint64_t original_size, uint64_t new_size,
-                    ProgressContext &prog_ctx);
+  AsyncResizeRequest(ImageCtx &image_ctx, Context *on_finish, uint64_t new_size,
+                     ProgressContext &prog_ctx);
   virtual ~AsyncResizeRequest();
 
   virtual void send();
index f37835a8a7cbfbebcd861364ad856983d13d36b7..8f5f040f52a9940098ac6e355f2c123f20509a87 100644 (file)
@@ -1695,25 +1695,23 @@ reprotect_and_return_err:
       return r;
     }
 
-    uint64_t original_size;
     {
       RWLock::RLocker snap_locker(ictx->snap_lock);
       if (ictx->snap_id != CEPH_NOSNAP || ictx->read_only) {
         return -EROFS;
       }
-      original_size = ictx->size;
     }
 
-    async_resize_helper(ictx, ctx, original_size, size, prog_ctx);
+    async_resize_helper(ictx, ctx, size, prog_ctx);
     return 0;
   }
 
-  void async_resize_helper(ImageCtx *ictx, Context *ctx, uint64_t original_size,
-                          uint64_t new_size, ProgressContext& prog_ctx)
+  void async_resize_helper(ImageCtx *ictx, Context *ctx, uint64_t new_size,
+                           ProgressContext& prog_ctx)
   {
     assert(ictx->owner_lock.is_locked());
-    AsyncResizeRequest *req = new AsyncResizeRequest(*ictx, ctx, original_size,
-                                                    new_size, prog_ctx);
+    AsyncResizeRequest *req = new AsyncResizeRequest(*ictx, ctx, new_size,
+                                                     prog_ctx);
     req->send();
   }
 
@@ -2080,7 +2078,6 @@ reprotect_and_return_err:
 
     RWLock::RLocker l(ictx->owner_lock);
     snap_t snap_id;
-    uint64_t original_size;
     uint64_t new_size;
     {
       RWLock::WLocker l2(ictx->md_lock);
@@ -2112,7 +2109,6 @@ reprotect_and_return_err:
       }
 
       ictx->snap_lock.get_read();
-      original_size = ictx->size;
       new_size = ictx->get_image_size(snap_id);
       ictx->snap_lock.put_read();
 
@@ -2129,7 +2125,7 @@ reprotect_and_return_err:
     ldout(cct, 2) << "resizing to snapshot size..." << dendl;
     NoOpProgressContext no_op;
     C_SaferCond ctx;
-    async_resize_helper(ictx, &ctx, original_size, new_size, no_op);
+    async_resize_helper(ictx, &ctx, new_size, no_op);
 
     r = ctx.wait();
     if (r < 0) {
index d164f02ff439a7100f7102947084d5f063120f9a..64395ca5ea0fea43e5d736959ff74e415fd01163 100644 (file)
@@ -193,8 +193,8 @@ namespace librbd {
   int async_flatten(ImageCtx *ictx, Context *ctx, ProgressContext &prog_ctx);
   int async_resize(ImageCtx *ictx, Context *ctx, uint64_t size,
                   ProgressContext &prog_ctx);
-  void async_resize_helper(ImageCtx *ictx, Context *ctx, uint64_t original_size,
-                          uint64_t new_size, ProgressContext& prog_ctx);
+  void async_resize_helper(ImageCtx *ictx, Context *ctx, uint64_t new_size,
+                           ProgressContext& prog_ctx);
 
   int aio_write(ImageCtx *ictx, uint64_t off, size_t len, const char *buf,
                AioCompletion *c, int op_flags);