From 39da107674c0b97113eac263b10426ad41b6bf4e Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Wed, 22 Jun 2011 17:13:22 -0700 Subject: [PATCH] librados: fix end_block calculation for aio_read Conflicts: src/librbd.cc --- src/librbd.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librbd.cc b/src/librbd.cc index 070f10a10e820..16e882fff57b7 100644 --- a/src/librbd.cc +++ b/src/librbd.cc @@ -1266,7 +1266,7 @@ void AioBlockCompletion::complete(ssize_t r) dout(10) << "block_ofs=" << block_ofs << dendl; /* a hole? */ - if (extent_ofs - block_ofs) { + if (extent_ofs - block_ofs > 0) { 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 - block_ofs); @@ -1415,7 +1415,7 @@ int aio_read(ImageCtx *ictx, uint64_t off, size_t len, int total_read = 0; ictx->lock.Lock(); uint64_t start_block = get_block_num(ictx->header, off); - uint64_t end_block = get_block_num(ictx->header, off + len); + uint64_t end_block = get_block_num(ictx->header, off + len - 1); uint64_t block_size = get_block_size(ictx->header); ictx->lock.Unlock(); uint64_t left = len; -- 2.39.5