[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/18] sheepdog: fix dynamic grow for running qcow2 f
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 01/18] sheepdog: fix dynamic grow for running qcow2 format |
Date: |
Fri, 20 Dec 2013 16:46:39 +0100 |
From: Liu Yuan <address@hidden>
When running qcow2 over sheepdog, we might meet following problem
qemu-system-x86_64: shrinking is not supported
And cause IO errors to Guest. This is because we abuse bs->total_sectors, which
is manipulated by generic block layer and race with sheepdog code.
We should directly check if offset > vdi_size to dynamically enlarge the volume
instead of 'offset > bs->total_sectors', which will cause problem when following
case happens:
vdi_size > offset > bs->total_sectors
# then trigger sd_truncate() to shrink the volume wrongly.
Cc: address@hidden
Cc: Kevin Wolf <address@hidden>
Cc: Stefan Hajnoczi <address@hidden>
Reported-by: Hadrien KOHL <address@hidden>
Signed-off-by: Liu Yuan <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block/sheepdog.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index d1c812d..ba451a9 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -2048,13 +2048,14 @@ static coroutine_fn int sd_co_writev(BlockDriverState
*bs, int64_t sector_num,
{
SheepdogAIOCB *acb;
int ret;
+ int64_t offset = (sector_num + nb_sectors) * BDRV_SECTOR_SIZE;
+ BDRVSheepdogState *s = bs->opaque;
- if (bs->growable && sector_num + nb_sectors > bs->total_sectors) {
- ret = sd_truncate(bs, (sector_num + nb_sectors) * BDRV_SECTOR_SIZE);
+ if (bs->growable && offset > s->inode.vdi_size) {
+ ret = sd_truncate(bs, offset);
if (ret < 0) {
return ret;
}
- bs->total_sectors = sector_num + nb_sectors;
}
acb = sd_aio_setup(bs, qiov, sector_num, nb_sectors);
--
1.8.4.2
- [Qemu-devel] [PULL 00/18] Block patches, Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 01/18] sheepdog: fix dynamic grow for running qcow2 format,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 02/18] vring: create a common function to parse descriptors, Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 03/18] vring: factor common code for error exits, Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 04/18] dataplane: change vring API to use VirtQueueElement, Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 05/18] dataplane: replace hostmem with memory_region_find, Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 07/18] block/iscsi: Fix compilation for libiscsi 1.4.0 (API change), Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 06/18] qapi-schema: fix QEMU 1.8 references, Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 08/18] block: vhdx - improve error message, and .bdrv_check implementation, Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 09/18] docs: updated qemu-img man page and qemu-doc to reflect VHDX support., Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 10/18] vmdk: Check VMFS extent line field number, Stefan Hajnoczi, 2013/12/20
- [Qemu-devel] [PULL 11/18] vmdk: Allow vmdk_create to work with protocol, Stefan Hajnoczi, 2013/12/20