mirror of https://gitee.com/openkylin/qemu.git
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>
This commit is contained in:
parent
d32f7c101b
commit
4049082c4b
9
block.c
9
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) {
|
||||
|
|
Loading…
Reference in New Issue