Merge remote branch 'origin/stable' into next

Conflicts:
	src/librbd.cc
This commit is contained in:
Sage Weil 2011-06-22 10:09:48 -07:00
commit 0fe6a15d7b

View File

@ -1126,6 +1126,7 @@ int64_t read_iterate(ImageCtx *ictx, uint64_t off, size_t len,
uint64_t start_block = get_block_num(ictx->header, off);
uint64_t end_block = get_block_num(ictx->header, off + len);
uint64_t block_size = get_block_size(ictx->header);
uint64_t base = off - get_block_ofs(ictx->header, off);
ictx->lock.Unlock();
uint64_t left = len;
@ -1139,7 +1140,7 @@ int64_t read_iterate(ImageCtx *ictx, uint64_t off, size_t len,
map<uint64_t, uint64_t> m;
map<uint64_t, uint64_t>::iterator iter;
uint64_t bl_ofs = 0, buf_bl_pos = 0;
uint64_t bl_ofs = 0;
r = ictx->data_ctx.sparse_read(oid, m, bl, read_len, block_ofs);
if (r < 0 && r == -ENOENT)
r = 0;
@ -1150,29 +1151,30 @@ int64_t read_iterate(ImageCtx *ictx, uint64_t off, size_t len,
for (iter = m.begin(); iter != m.end(); ++iter) {
uint64_t extent_ofs = iter->first;
size_t extent_len = iter->second;
dout(0) << "extent_ofs=" << extent_ofs << " extent_len=" << extent_len << dendl;
/* a hole? */
if (extent_ofs - block_ofs) {
r = cb(total_read + buf_bl_pos, extent_ofs - block_ofs, NULL, arg);
if (extent_ofs - block_ofs > 0) {
r = cb(base + total_read + block_ofs, extent_ofs - block_ofs, NULL, arg);
if (r < 0)
return r;
}
if (bl_ofs + extent_len > bl.length())
return -EIO;
buf_bl_pos += extent_ofs - block_ofs;
block_ofs = extent_ofs;
/* data */
r = cb(total_read + buf_bl_pos, extent_len, bl.c_str() + bl_ofs, arg);
r = cb(base + total_read + block_ofs, extent_len, bl.c_str() + bl_ofs, arg);
if (r < 0)
return r;
bl_ofs += extent_len;
buf_bl_pos += extent_len;
block_ofs += extent_len;
}
/* last hole */
if (read_len - buf_bl_pos) {
r = cb(total_read + buf_bl_pos, read_len - buf_bl_pos, NULL, arg);
if (read_len - block_ofs) {
r = cb(base + total_read + block_ofs, read_len - block_ofs, NULL, arg);
if (r < 0)
return r;
}