summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2014-06-26 13:23:19 +0200
committerKevin Wolf <kwolf@redhat.com>2014-08-15 15:07:13 +0200
commit4049082c4b489959850743ec22d1fec125752038 (patch)
tree35e579980703bd8b675b110a891ff90b2a39be23
parentd32f7c101b37c03f222008331db3b1d09493a4a3 (diff)
downloadqemu-4049082c4b489959850743ec22d1fec125752038.tar.gz
block: Use bdrv_nb_sectors() in bdrv_aligned_preadv()
Instead of bdrv_getlength(). Eliminate variable len. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Benoit Canet <benoit@irqsave.net> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
-rw-r--r--block.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/block.c b/block.c
index 75553fb2b6..5b7e05385c 100644
--- a/block.c
+++ b/block.c
@@ -3055,15 +3055,14 @@ static int coroutine_fn bdrv_aligned_preadv(BlockDriverState *bs,
ret = drv->bdrv_co_readv(bs, sector_num, nb_sectors, qiov);
} else {
/* Read zeros after EOF of growable BDSes */
- int64_t len, total_sectors, max_nb_sectors;
+ int64_t total_sectors, max_nb_sectors;
- len = bdrv_getlength(bs);
- if (len < 0) {
- ret = len;
+ total_sectors = bdrv_nb_sectors(bs);
+ if (total_sectors < 0) {
+ ret = total_sectors;
goto out;
}
- total_sectors = DIV_ROUND_UP(len, BDRV_SECTOR_SIZE);
max_nb_sectors = ROUND_UP(MAX(0, total_sectors - sector_num),
align >> BDRV_SECTOR_BITS);
if (max_nb_sectors > 0) {