[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 27/29] vmdk: Use bdrv_nb_sectors() where sectors, not
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 27/29] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted |
Date: |
Fri, 22 Aug 2014 16:51:51 +0200 |
From: Markus Armbruster <address@hidden>
Instead of bdrv_getlength().
Commit 57322b7 did this all over block, but one more bdrv_getlength()
has crept in since.
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Reviewed-by: BenoƮt Canet <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/vmdk.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/block/vmdk.c b/block/vmdk.c
index f000d2a..07cb62c 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -397,7 +397,7 @@ static int vmdk_add_extent(BlockDriverState *bs,
{
VmdkExtent *extent;
BDRVVmdkState *s = bs->opaque;
- int64_t length;
+ int64_t nb_sectors;
if (cluster_sectors > 0x200000) {
/* 0x200000 * 512Bytes = 1GB for one cluster is unrealistic */
@@ -413,9 +413,9 @@ static int vmdk_add_extent(BlockDriverState *bs,
return -EFBIG;
}
- length = bdrv_getlength(file);
- if (length < 0) {
- return length;
+ nb_sectors = bdrv_nb_sectors(file);
+ if (nb_sectors < 0) {
+ return nb_sectors;
}
s->extents = g_renew(VmdkExtent, s->extents, s->num_extents + 1);
@@ -432,8 +432,7 @@ static int vmdk_add_extent(BlockDriverState *bs,
extent->l1_entry_sectors = l2_size * cluster_sectors;
extent->l2_size = l2_size;
extent->cluster_sectors = flat ? sectors : cluster_sectors;
- extent->next_cluster_sector =
- ROUND_UP(DIV_ROUND_UP(length, BDRV_SECTOR_SIZE), cluster_sectors);
+ extent->next_cluster_sector = ROUND_UP(nb_sectors, cluster_sectors);
if (s->num_extents > 1) {
extent->end_sector = (*(extent - 1)).end_sector + extent->sectors;
--
1.8.3.1
- [Qemu-devel] [PULL 16/29] block: Add bdrv_refresh_filename(), (continued)
- [Qemu-devel] [PULL 16/29] block: Add bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 18/29] blkverify: Implement bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 19/29] nbd: Implement bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 21/29] iotests: Add test for image filename construction, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 22/29] block/vvfat.c: remove debugging code to reinit stderr if NULL, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 20/29] quorum: Implement bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 24/29] raw-posix: fix O_DIRECT short reads, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 23/29] block/iscsi: fix memory corruption on iscsi resize, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 25/29] qemu-iotests: add test case 101 for short file I/O, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 26/29] blkdebug: Delete BH in bdrv_aio_cancel, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 27/29] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted,
Kevin Wolf <=
- [Qemu-devel] [PULL 28/29] qemu-img: Allow source cache mode specification, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 29/29] qemu-img: Allow cache mode specification for amend, Kevin Wolf, 2014/08/22
- Re: [Qemu-devel] [PULL 00/29] Block patches, Daniel H Barboza, 2014/08/22
- Re: [Qemu-devel] [PULL 00/29] Block patches, Peter Maydell, 2014/08/22