]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: fix diff_iterate arithmetic for non-standard striping
authorSage Weil <sage@inktank.com>
Thu, 28 Mar 2013 21:13:03 +0000 (14:13 -0700)
committerJosh Durgin <josh.durgin@inktank.com>
Mon, 1 Apr 2013 06:32:41 +0000 (23:32 -0700)
This code is confusing because we are moving back and forth between
image offsets, "buffer" offsets (image offsets relative to off), and
object offsets.  Fix the math.

Signed-off-by: Sage Weil <sage@inktank.com>
src/librbd/internal.cc

index 1340ba26f9424bb4d55e70cd1562578415ff74f8..b4594832c436d446b5888f805a234ac4095bd5de 100644 (file)
@@ -2400,7 +2400,7 @@ reprotect_and_return_err:
          for (vector<pair<uint64_t,uint64_t> >::iterator r = q->buffer_extents.begin();
               r != q->buffer_extents.end();
               ++r) {
-           interval_set<uint64_t> overlap;
+           interval_set<uint64_t> overlap;  // object extents
            overlap.insert(opos, r->second);
            overlap.intersection_of(diff);
            ldout(ictx->cct, 20) << " opos " << opos
@@ -2410,7 +2410,8 @@ reprotect_and_return_err:
            for (interval_set<uint64_t>::iterator s = overlap.begin();
                 s != overlap.end();
                 ++s) {
-             uint64_t logical_off = off + s.get_start();
+             uint64_t su_off = s.get_start() - opos;
+             uint64_t logical_off = off + r->first + su_off;
              ldout(ictx->cct, 20) << "   overlap extent " << s.get_start() << "~" << s.get_len()
                                   << " logical "
                                   << logical_off << "~" << s.get_len()