]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: track block_ofs instead of ofs in aio_sparse_read callback
authorYehuda Sadeh <yehuda@hq.newdream.net>
Wed, 22 Jun 2011 19:37:24 +0000 (12:37 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Wed, 22 Jun 2011 19:37:24 +0000 (12:37 -0700)
src/librbd.cc

index 12674d26babc8bfc3ee23a83df186e8e5ee0f968..73dba632c943040fa83462e8f76f6eec3e4af01f 100644 (file)
@@ -1242,24 +1242,27 @@ void AioBlockCompletion::complete(ssize_t r)
     map<uint64_t, uint64_t>::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;
@@ -1267,6 +1270,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 */