From: Yehuda Sadeh Date: Wed, 22 Jun 2011 19:37:24 +0000 (-0700) Subject: librbd: track block_ofs instead of ofs in aio_sparse_read callback X-Git-Tag: v0.30~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=44759452d4504c4c641814266c616b39fb7279b3;p=ceph.git librbd: track block_ofs instead of ofs in aio_sparse_read callback --- diff --git a/src/librbd.cc b/src/librbd.cc index 69852cd482e..070f10a10e8 100644 --- a/src/librbd.cc +++ b/src/librbd.cc @@ -1257,24 +1257,27 @@ void AioBlockCompletion::complete(ssize_t r) map::iterator iter; uint64_t bl_ofs = 0, buf_bl_pos = 0; dout(10) << "ofs=" << ofs << " len=" << len << dendl; + uint64_t block_ofs = ofs; for (iter = m.begin(); iter != m.end(); ++iter) { uint64_t extent_ofs = iter->first; size_t extent_len = iter->second; dout(10) << "extent_ofs=" << extent_ofs << " extent_len=" << extent_len << dendl; + dout(10) << "block_ofs=" << block_ofs << dendl; /* a hole? */ - if (extent_ofs - ofs) { + if (extent_ofs - block_ofs) { dout(10) << "<1>zeroing " << buf_bl_pos << "~" << extent_ofs << dendl; dout(10) << "buf=" << (void *)(buf + buf_bl_pos) << "~" << (void *)(buf + extent_ofs - ofs - 1) << dendl; - memset(buf + buf_bl_pos, 0, extent_ofs - ofs); + memset(buf + buf_bl_pos, 0, extent_ofs - block_ofs); } if (bl_ofs + extent_len > len) { r = -EIO; break; } - buf_bl_pos += extent_ofs - ofs; + buf_bl_pos += extent_ofs - block_ofs; + block_ofs = extent_ofs; /* data */ dout(10) << "<2>copying " << buf_bl_pos << "~" << extent_len << " from ofs=" << bl_ofs << dendl; @@ -1282,6 +1285,7 @@ void AioBlockCompletion::complete(ssize_t r) memcpy(buf + buf_bl_pos, data_bl.c_str() + bl_ofs, extent_len); bl_ofs += extent_len; buf_bl_pos += extent_len; + block_ofs += extent_len; } /* last hole */