]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: fix check_io for snap
authorSage Weil <sage@newdream.net>
Mon, 22 Aug 2011 23:52:45 +0000 (16:52 -0700)
committerSage Weil <sage@newdream.net>
Mon, 22 Aug 2011 23:53:55 +0000 (16:53 -0700)
Need to look at image size for snapshot, not the head version.

Signed-off-by: Sage Weil <sage@newdream.net>
src/librbd.cc

index 4751d36fbb19aac00772aaa7c08c0445b7270d9d..f0e35505b1511ae7ff6d6e2e90181202d6092656 100644 (file)
@@ -104,6 +104,16 @@ namespace librbd {
     {
       return name + RBD_SUFFIX;
     }
+
+    uint64_t get_image_size() {
+      if (snapname.length() == 0) {
+       return header.image_size;
+      } else {
+       map<std::string,SnapInfo>::iterator p = snaps_by_name.find(snapname);
+       assert(p != snaps_by_name.end());
+       return p->second.size;
+      }
+    }
   };
 
   class WatchCtx : public librados::WatchCtx {
@@ -1333,7 +1343,7 @@ void rados_cb(rados_completion_t c, void *arg)
 int check_io(ImageCtx *ictx, uint64_t off, uint64_t len)
 {
   ictx->lock.Lock();
-  uint64_t image_size = ictx->header.image_size;
+  uint64_t image_size = ictx->get_image_size();
   ictx->lock.Unlock();
 
   if ((uint64_t)(off + len) > image_size)