mirror of https://github.com/xqemu/xqemu.git
block: Use bdrv_nb_sectors() in bdrv_make_zero()
Instead of bdrv_getlength(). Variable target_size is initially in bytes, then changes meaning to sectors. Ugh. Replace by target_sectors. 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
65a9bb25d6
commit
d32f7c101b
12
block.c
12
block.c
|
@ -2828,18 +2828,16 @@ int bdrv_write_zeroes(BlockDriverState *bs, int64_t sector_num,
|
||||||
*/
|
*/
|
||||||
int bdrv_make_zero(BlockDriverState *bs, BdrvRequestFlags flags)
|
int bdrv_make_zero(BlockDriverState *bs, BdrvRequestFlags flags)
|
||||||
{
|
{
|
||||||
int64_t target_size;
|
int64_t target_sectors, ret, nb_sectors, sector_num = 0;
|
||||||
int64_t ret, nb_sectors, sector_num = 0;
|
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
target_size = bdrv_getlength(bs);
|
target_sectors = bdrv_nb_sectors(bs);
|
||||||
if (target_size < 0) {
|
if (target_sectors < 0) {
|
||||||
return target_size;
|
return target_sectors;
|
||||||
}
|
}
|
||||||
target_size /= BDRV_SECTOR_SIZE;
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
nb_sectors = target_size - sector_num;
|
nb_sectors = target_sectors - sector_num;
|
||||||
if (nb_sectors <= 0) {
|
if (nb_sectors <= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue