From: Sage Weil Date: Mon, 22 Aug 2011 23:52:45 +0000 (-0700) Subject: rbd: fix check_io for snap X-Git-Tag: v0.35~275 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f19e6131c3762898b5e13d99c34d7d75afce90be;p=ceph.git rbd: fix check_io for snap Need to look at image size for snapshot, not the head version. Signed-off-by: Sage Weil --- diff --git a/src/librbd.cc b/src/librbd.cc index 4751d36fbb1..f0e35505b15 100644 --- a/src/librbd.cc +++ b/src/librbd.cc @@ -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::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)