From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, asias@redhat.com, famz@redhat.com, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH 1/2] block: don't lose data from last incomplete sector
Date: Wed, 18 Sep 2013 19:14:14 +0800 [thread overview]
Message-ID: <1379502855-27759-2-git-send-email-famz@redhat.com> (raw)
In-Reply-To: <1379502855-27759-1-git-send-email-famz@redhat.com>
To read the last sector that is not aligned to sector boundary, current
code for growable backends, since commit 893a8f6 "block: Produce zeros
when protocols reading beyond end of file", drops the data and directly
returns zeroes. That is incorrect.
Signed-off-by: Fam Zheng <famz@redhat.com>
---
block.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block.c b/block.c
index a325efc..9b28ef9 100644
--- a/block.c
+++ b/block.c
@@ -2613,7 +2613,7 @@ static int coroutine_fn bdrv_co_do_readv(BlockDriverState *bs,
goto out;
}
- total_sectors = len >> BDRV_SECTOR_BITS;
+ total_sectors = (len + BDRV_SECTOR_SIZE - 1) >> BDRV_SECTOR_BITS;
max_nb_sectors = MAX(0, total_sectors - sector_num);
if (max_nb_sectors > 0) {
ret = drv->bdrv_co_readv(bs, sector_num,
--
1.8.3.1
next prev parent reply other threads:[~2013-09-18 11:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-18 11:14 [Qemu-devel] [PATCH 0/2] block: two fixes for image opening Fam Zheng
2013-09-18 11:14 ` Fam Zheng [this message]
2013-09-20 14:41 ` [Qemu-devel] [PATCH 1/2] block: don't lose data from last incomplete sector Stefan Hajnoczi
2013-09-18 11:14 ` [Qemu-devel] [PATCH 2/2] vmdk: fix cluster size check for flat extents Fam Zheng
2013-09-19 11:31 ` Stefan Hajnoczi
2013-09-20 15:04 ` Paolo Bonzini
2013-09-22 0:53 ` Fam Zheng
2013-09-19 11:31 ` [Qemu-devel] [PATCH 0/2] block: two fixes for image opening Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1379502855-27759-2-git-send-email-famz@redhat.com \
--to=famz@redhat.com \
--cc=asias@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).