[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 05/62] block: Use bdrv_nb_sectors() in bdrv_make_zero
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 05/62] block: Use bdrv_nb_sectors() in bdrv_make_zero() |
Date: |
Fri, 8 Aug 2014 19:39:06 +0200 |
From: Markus Armbruster <address@hidden>
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 <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Benoit Canet <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/block.c b/block.c
index 068ec25..5093dfc 100644
--- a/block.c
+++ b/block.c
@@ -2835,18 +2835,16 @@ int bdrv_write_zeroes(BlockDriverState *bs, int64_t
sector_num,
*/
int bdrv_make_zero(BlockDriverState *bs, BdrvRequestFlags flags)
{
- int64_t target_size;
- int64_t ret, nb_sectors, sector_num = 0;
+ int64_t target_sectors, ret, nb_sectors, sector_num = 0;
int n;
- target_size = bdrv_getlength(bs);
- if (target_size < 0) {
- return target_size;
+ target_sectors = bdrv_nb_sectors(bs);
+ if (target_sectors < 0) {
+ return target_sectors;
}
- target_size /= BDRV_SECTOR_SIZE;
for (;;) {
- nb_sectors = target_size - sector_num;
+ nb_sectors = target_sectors - sector_num;
if (nb_sectors <= 0) {
return 0;
}
--
1.8.3.1
- [Qemu-devel] [PULL 00/62] Block patches, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 01/62] nbd: Drop nbd_can_read(), Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 04/62] block: New bdrv_nb_sectors(), Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 02/62] block: Add AIO context notifiers, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 05/62] block: Use bdrv_nb_sectors() in bdrv_make_zero(),
Kevin Wolf <=
- [Qemu-devel] [PULL 06/62] block: Use bdrv_nb_sectors() in bdrv_aligned_preadv(), Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 03/62] nbd: Follow the BDS' AIO context, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 07/62] block: Use bdrv_nb_sectors() in bdrv_co_get_block_status(), Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 08/62] block: Use bdrv_nb_sectors() in img_convert(), Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 09/62] block: Use bdrv_nb_sectors() where sectors, not bytes are wanted, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 10/62] block: Drop superfluous aligning of bdrv_getlength()'s value, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 11/62] qemu-img: Make img_convert() get image size just once per image, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 12/62] block: Avoid bdrv_get_geometry() where errors should be detected, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 14/62] configure: explicitly state version requirements to devel packages, Kevin Wolf, 2014/08/08
- [Qemu-devel] [PULL 15/62] xen_disk: fix possible null-ptr dereference, Kevin Wolf, 2014/08/08