Skip to contentSkip to conversation

Fix VHDX qemu-iotests 033 failure

PATCH In review Kevin Wolf 2 participants 5 messages Apr 15, 2015 Block layer

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

cover Fix VHDX qemu-iotests 033 failure

Kevin Wolf (2):
blkdebug: Add bdrv_truncate()
vhdx: Fix zero-fill iov length

 block/blkdebug.c | 6 ++++++
 block/vhdx.c     | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 1/2 blkdebug: Add bdrv_truncate()

This is, amongst others, required for qemu-iotests 033 to run as intended on VHDX, which uses explicit bdrv_truncate() calls to bs->file when allocating new blocks.

---
 block/blkdebug.c | 6 ++++++
 1 file changed, 6 insertions(+)
block/blkdebug.c +6 -0
index 63611e0..3c30edb 100644
@@ -721,6 +721,11 @@ static int64_t blkdebug_getlength(BlockDriverState *bs)
     return bdrv_getlength(bs->file);
 }
 
+static int blkdebug_truncate(BlockDriverState *bs, int64_t offset)
+{
+    return bdrv_truncate(bs->file, offset);
+}
+
 static void blkdebug_refresh_filename(BlockDriverState *bs)
 {
     QDict *opts;
@@ -779,6 +784,7 @@ static BlockDriver bdrv_blkdebug = {
     .bdrv_file_open         = blkdebug_open,
     .bdrv_close             = blkdebug_close,
     .bdrv_getlength         = blkdebug_getlength,
+    .bdrv_truncate          = blkdebug_truncate,
     .bdrv_refresh_filename  = blkdebug_refresh_filename,
 
     .bdrv_aio_readv         = blkdebug_aio_readv,
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] blkdebug: Add bdrv_truncate()

Quoted 36 lines · Kevin Wolf

This is, amongst others, required for qemu-iotests 033 to run as intended on VHDX, which uses explicit bdrv_truncate() calls to bs->file when allocating new blocks.

---
 block/blkdebug.c | 6 ++++++
 1 file changed, 6 insertions(+)
block/blkdebug.c +6 -0
index 63611e0..3c30edb 100644
@@ -721,6 +721,11 @@ static int64_t blkdebug_getlength(BlockDriverState *bs)
     return bdrv_getlength(bs->file);
 }
 
+static int blkdebug_truncate(BlockDriverState *bs, int64_t offset)
+{
+    return bdrv_truncate(bs->file, offset);
+}
+
 static void blkdebug_refresh_filename(BlockDriverState *bs)
 {
     QDict *opts;
@@ -779,6 +784,7 @@ static BlockDriver bdrv_blkdebug = {
     .bdrv_file_open         = blkdebug_open,
     .bdrv_close             = blkdebug_close,
     .bdrv_getlength         = blkdebug_getlength,
+    .bdrv_truncate          = blkdebug_truncate,
     .bdrv_refresh_filename  = blkdebug_refresh_filename,
 
     .bdrv_aio_readv         = blkdebug_aio_readv,
Signature · 1 line
1.8.3.1
author
#3 lore raw

PATCH 2/2 vhdx: Fix zero-fill iov length

In reply to Kevin Wolf

Fix the length of the zero-fill for the back, which was accidentally using the same value as for the front. This is caught by qemu-iotests 033.

For consistency, change the code for the front as well to use the length stored in the iov (it is the same value, copied four lines above).

---
 block/vhdx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
block/vhdx.c +2 -2
index bb3ed45..e24062f 100644
@@ -1269,7 +1269,7 @@ static coroutine_fn int vhdx_co_writev(BlockDriverState *bs, int64_t sector_num,
                         iov1.iov_base = qemu_blockalign(bs, iov1.iov_len);
                         memset(iov1.iov_base, 0, iov1.iov_len);
                         qemu_iovec_concat_iov(&hd_qiov, &iov1, 1, 0,
-                                              sinfo.block_offset);
+                                              iov1.iov_len);
                         sectors_to_write += iov1.iov_len >> BDRV_SECTOR_BITS;
                     }
 
@@ -1285,7 +1285,7 @@ static coroutine_fn int vhdx_co_writev(BlockDriverState *bs, int64_t sector_num,
                         iov2.iov_base = qemu_blockalign(bs, iov2.iov_len);
                         memset(iov2.iov_base, 0, iov2.iov_len);
                         qemu_iovec_concat_iov(&hd_qiov, &iov2, 1, 0,
-                                              sinfo.block_offset);
+                                              iov2.iov_len);
                         sectors_to_write += iov2.iov_len >> BDRV_SECTOR_BITS;
                     }
                 }
Signature · 1 line
1.8.3.1
Acked-by on v1 2/2
#4 lore raw

Re: [Qemu-devel] [PATCH 2/2] vhdx: Fix zero-fill iov length

Quoted 17 lines · Kevin Wolf

Fix the length of the zero-fill for the back, which was accidentally using the same value as for the front. This is caught by qemu-iotests 033.

For consistency, change the code for the front as well to use the length stored in the iov (it is the same value, copied four lines above).

---
 block/vhdx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
block/vhdx.c +0 -0
index bb3ed45..e24062f 100644

block/vhdx.c static coroutine_fn int vhdx_co_writev(BlockDriverState *bs, int64_t sector_num, · line 1272

Quoted 5 lines
block/vhdx.c +1 -1
@@ -1269,7 +1269,7 @@ static coroutine_fn int vhdx_co_writev(BlockDriverState *bs, int64_t sector_num,
                         iov1.iov_base = qemu_blockalign(bs, iov1.iov_len);
                         memset(iov1.iov_base, 0, iov1.iov_len);
                         qemu_iovec_concat_iov(&hd_qiov, &iov1, 1, 0,
-                                              sinfo.block_offset);
+                                              iov1.iov_len);

Better form here, although should be identical

block/vhdx.c static coroutine_fn int vhdx_co_writev(BlockDriverState *bs, int64_t sector_num, · line 1288

Quoted 9 lines
block/vhdx.c +1 -1
                         sectors_to_write += iov1.iov_len >> BDRV_SECTOR_BITS;
                     }
 
@@ -1285,7 +1285,7 @@ static coroutine_fn int vhdx_co_writev(BlockDriverState *bs, int64_t sector_num,
                         iov2.iov_base = qemu_blockalign(bs, iov2.iov_len);
                         memset(iov2.iov_base, 0, iov2.iov_len);
                         qemu_iovec_concat_iov(&hd_qiov, &iov2, 1, 0,
-                                              sinfo.block_offset);
+                                              iov2.iov_len);

Definite bug fix here

Quoted 6 lines
block/vhdx.c +0 -0
                         sectors_to_write += iov2.iov_len >> BDRV_SECTOR_BITS;
                     }
                 }
Signature · 1 line
1.8.3.1