block: Make various formats' block_status recurse again
cover block: Make various formats' block_status recurse again
Hi,
69f47505ee66afaa513305de0c1895a224e52c45 changed block_status so that it would only go down to the protocol layer if the format layer returned BDRV_BLOCK_RECURSE, thus indicating that it has no sufficient information whether a given range in the image is zero or not. Generally, this is because the image is preallocated and thus all ranges appear as zeroes.
However, it only implemented this preallocation detection for qcow2. There are more formats that support preallocation, though: vdi, vhdx, vmdk, vpc. (Funny how they all start with “v”.)
For vdi, vmdk, and vpc, the fix is rather simple, because they really have different subformats depending on whether an image is preallocated or not. This makes the check very simple.
vhdx is more like qcow2, where after the image has been created, it isn’t clear whether it’s been preallocated or everything is allocated because everything was already written to. 69f47505ee added a heuristic to qcow2 to get around this, but I think that’s too much for vhdx. I just left it unfixed, because I don’t care that much, honestly (and I don’t think anyone else does).
Max Reitz (3):
vdi: Make block_status recurse for fixed images
vmdk: Make block_status recurse for flat extents
vpc: Do not return RAW from block_status
block/vdi.c | 3 ++- block/vmdk.c | 3 +++ block/vpc.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-)
Signature · 1 line
2.21.0
PATCH 1/3 vdi: Make block_status recurse for fixed images
--- block/vdi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
block/vdi.c +2 -1
@@ -542,7 +542,8 @@ static int coroutine_fn vdi_co_block_status(BlockDriverState *bs, *map = s->header.offset_data + (uint64_t )bmap_entry * s->block_size + index_in_block; *file = bs->file->bs; -return BDRV_BLOCK_DATA |BDRV_BLOCK_OFFSET_VALID ; +return BDRV_BLOCK_DATA |BDRV_BLOCK_OFFSET_VALID | + (s->header.image_type ==VDI_TYPE_STATIC ?BDRV_BLOCK_RECURSE :0 ); }static int coroutine_fn
Signature · 1 line
2.21.0
Re: [Qemu-devel] [PATCH 1/3] vdi: Make block_status recurse for fixed images
Quoted 3 lines · Max Reitz
Suggested-by Vladimir Sementsov-Ogievskiy <[email protected]>Fixes 69f47505ee66afaa513305de0c1895a224e52c45Signed-off-by Max Reitz <[email protected]>
Sorry for a delay, I thought that maintainers of the formats will approve these patches ;)
Don't know vdi code, but it is what I suggested and seems to be the right thing to do:
Quoted 19 lines
--- block/vdi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)block/vdi.c +2
-1@@ -542,7 +542,8 @@ static int coroutine_fn vdi_co_block_status(BlockDriverState *bs, *map = s->header.offset_data + (uint64_t )bmap_entry * s->block_size + index_in_block; *file = bs->file->bs; -return BDRV_BLOCK_DATA |BDRV_BLOCK_OFFSET_VALID ; +return BDRV_BLOCK_DATA |BDRV_BLOCK_OFFSET_VALID | + (s->header.image_type ==VDI_TYPE_STATIC ?BDRV_BLOCK_RECURSE :0 ); }static int coroutine_fn
Signature · 2 lines
Best regards, Vladimir
PATCH 2/3 vmdk: Make block_status recurse for flat extents
In reply to Max Reitz--- block/vmdk.c | 3 +++ 1 file changed, 3 insertions(+)
block/vmdk.c +3 -0
@@ -1692,6 +1692,9 @@ static int coroutine_fn vmdk_co_block_status(BlockDriverState *bs,if (!extent->compressed) { ret |=BDRV_BLOCK_OFFSET_VALID ; *map = cluster_offset + index_in_cluster; +if (extent->flat) { + ret |=BDRV_BLOCK_RECURSE ; + } } *file = extent->file->bs;break ;
Signature · 1 line
2.21.0
Re: [Qemu-devel] [PATCH 2/3] vmdk: Make block_status recurse for flat extents
Quoted 2 lines · Max Reitz
Fixes 69f47505ee66afaa513305de0c1895a224e52c45Signed-off-by Max Reitz <[email protected]>
Again, don't know vmdk code, but briefly looking at it (and at vmdk spec) I see that "extents" are files, and flat extent is a raw file without any special format. And it is allocated by blk_truncate(.. PREALLOC_MODE_OFF ..), so really looks like metadata preallocation.
And, any way, there should not be real damage, as patch simply brings back old behavior for one case.
Quoted 19 lines
--- block/vmdk.c | 3 +++ 1 file changed, 3 insertions(+)block/vmdk.c +3
-0@@ -1692,6 +1692,9 @@ static int coroutine_fn vmdk_co_block_status(BlockDriverState *bs,if (!extent->compressed) { ret |=BDRV_BLOCK_OFFSET_VALID ; *map = cluster_offset + index_in_cluster; +if (extent->flat) { + ret |=BDRV_BLOCK_RECURSE ; + } } *file = extent->file->bs;break ;
Signature · 2 lines
Best regards, Vladimir
PATCH 3/3 vpc: Do not return RAW from block_status
In reply to Max Reitzvpc is not really a passthrough driver, even when using the fixed subformat (where host and guest offsets are equal). It should handle preallocation like all other drivers do, namely by returning DATA | RECURSE instead of RAW.
There is no tangible difference but the fact that bdrv_is_allocated() no longer falls through to the protocol layer.
--- block/vpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/vpc.c +1 -1
@@ -737,7 +737,7 @@ static int coroutine_fn vpc_co_block_status(BlockDriverState *bs, *pnum = bytes; *map = offset; *file = bs->file->bs; -return BDRV_BLOCK_RAW |BDRV_BLOCK_OFFSET_VALID ; +return BDRV_BLOCK_DATA |BDRV_BLOCK_OFFSET_VALID |BDRV_BLOCK_RECURSE ; }qemu_co_mutex_lock (&s->lock);
Signature · 1 line
2.21.0
Re: [Qemu-devel] [PATCH 3/3] vpc: Do not return RAW from block_status
Quoted 7 lines · Max Reitz
vpc is not really a passthrough driver, even when using the fixed subformat (where host and guest offsets are equal). It should handle preallocation like all other drivers do, namely by returning DATA | RECURSE instead of RAW.
There is no tangible difference but the fact that
bdrv_is_allocated()no longer falls through to the protocol layer.
Hmm. Isn't a real bug (fixed by this patch) ?
Assume vpc->file is qcow2 with backing, which have "unallocated" region, which is backed by actual data in backing file.
So, this region will be reported as not allocated and will be skipped by any copying loop using block-status? Is it a bug of BDRV_BLOCK_RAW itself? Or I don't understand something..
Quoted 20 lines
Signed-off-by Max Reitz <[email protected]>--- block/vpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)block/vpc.c +1
-1@@ -737,7 +737,7 @@ static int coroutine_fn vpc_co_block_status(BlockDriverState *bs, *pnum = bytes; *map = offset; *file = bs->file->bs; -return BDRV_BLOCK_RAW |BDRV_BLOCK_OFFSET_VALID ; +return BDRV_BLOCK_DATA |BDRV_BLOCK_OFFSET_VALID |BDRV_BLOCK_RECURSE ; }qemu_co_mutex_lock (&s->lock);
Signature · 2 lines
Best regards, Vladimir
Re: [Qemu-devel] [PATCH 3/3] vpc: Do not return RAW from block_status
Quoted 6 lines · Vladimir Sementsov-Ogievskiy
Quoted 5 lines · Max Reitz
vpc is not really a passthrough driver, even when using the fixed subformat (where host and guest offsets are equal). It should handle preallocation like all other drivers do, namely by returning DATA | RECURSE instead of RAW.
Quoted 7 lines
Quoted 2 lines
There is no tangible difference but the fact that
bdrv_is_allocated()no longer falls through to the protocol layer.Hmm. Isn't a real bug (fixed by this patch) ?
Assume
vpc->fileis qcow2 with backing, which have "unallocated" region, which is backed by actual data in backing file.
Come on now.
Quoted 3 lines
So, this region will be reported as not allocated and will be skipped by any copying loop using block-status? Is it a bug of
BDRV_BLOCK_RAWitself? Or I don't understand something..
I think what you don’t understand is that if you have a vpc file inside of a qcow2 file, you’re doing basically everything wrong. ;-)
But maybe we should drop BDRV_BLOCK_RAW... Does it do anything good for us in the raw driver? Shouldn’t it too just return DATA | RECURSE?
Max
Re: [Qemu-devel] [PATCH 3/3] vpc: Do not return RAW from block_status
Quoted 21 lines · Max Reitz
Quoted 6 lines · Vladimir Sementsov-Ogievskiy
Quoted 5 lines · Max Reitz
vpc is not really a passthrough driver, even when using the fixed subformat (where host and guest offsets are equal). It should handle preallocation like all other drivers do, namely by returning DATA | RECURSE instead of RAW.
Quoted 7 lines
Quoted 2 lines
There is no tangible difference but the fact that
bdrv_is_allocated()no longer falls through to the protocol layer.Hmm. Isn't a real bug (fixed by this patch) ?
Assume
vpc->fileis qcow2 with backing, which have "unallocated" region, which is backed by actual data in backing file.Come on now.
Quoted 3 lines
So, this region will be reported as not allocated and will be skipped by any copying loop using block-status? Is it a bug of
BDRV_BLOCK_RAWitself? Or I don't understand something..
Quoted 6 lines
I think what you don’t understand is that if you have a vpc file inside of a qcow2 file, you’re doing basically everything wrong. ;-)
But maybe we should drop
BDRV_BLOCK_RAW... Does it do anything good for us in the raw driver? Shouldn’t it too just return DATA | RECURSE?
And if I have raw driver above qcow2, it will not work, like I've described above..
Signature · 2 lines
Best regards, Vladimir
Re: [Qemu-devel] [PATCH 3/3] vpc: Do not return RAW from block_status
Quoted 22 lines · Vladimir Sementsov-Ogievskiy
Quoted 21 lines · Max Reitz
Quoted 6 lines · Vladimir Sementsov-Ogievskiy
Quoted 5 lines · Max Reitz
vpc is not really a passthrough driver, even when using the fixed subformat (where host and guest offsets are equal). It should handle preallocation like all other drivers do, namely by returning DATA | RECURSE instead of RAW.
Quoted 7 lines
Quoted 2 lines
There is no tangible difference but the fact that
bdrv_is_allocated()no longer falls through to the protocol layer.Hmm. Isn't a real bug (fixed by this patch) ?
Assume
vpc->fileis qcow2 with backing, which have "unallocated" region, which is backed by actual data in backing file.Come on now.
Quoted 3 lines
So, this region will be reported as not allocated and will be skipped by any copying loop using block-status? Is it a bug of
BDRV_BLOCK_RAWitself? Or I don't understand something..
Quoted 8 lines
Quoted 6 lines
I think what you don’t understand is that if you have a vpc file inside of a qcow2 file, you’re doing basically everything wrong. ;-)
But maybe we should drop
BDRV_BLOCK_RAW... Does it do anything good for us in the raw driver? Shouldn’t it too just return DATA | RECURSE?And if I have raw driver above qcow2, it will not work, like I've described above..
Yep. That’s why I was wondering. (This is a more likely case, because maybe you really want to use raw’s offset capability on top of qcow2.)
Max
Re: [Qemu-devel] [PATCH 3/3] vpc: Do not return RAW from block_status
In reply to Max ReitzAm 12.08.2019 um 17:56 hat Max Reitz geschrieben:
Quoted 21 lines · Vladimir Sementsov-Ogievskiy
Quoted 6 lines
Quoted 5 lines · Max Reitz
vpc is not really a passthrough driver, even when using the fixed subformat (where host and guest offsets are equal). It should handle preallocation like all other drivers do, namely by returning DATA | RECURSE instead of RAW.
Quoted 7 lines
Quoted 2 lines
There is no tangible difference but the fact that
bdrv_is_allocated()no longer falls through to the protocol layer.Hmm. Isn't a real bug (fixed by this patch) ?
Assume
vpc->fileis qcow2 with backing, which have "unallocated" region, which is backed by actual data in backing file.Come on now.
Quoted 3 lines
So, this region will be reported as not allocated and will be skipped by any copying loop using block-status? Is it a bug of
BDRV_BLOCK_RAWitself? Or I don't understand something..
Quoted 5 lines
I think what you don’t understand is that if you have a vpc file inside of a qcow2 file, you’re doing basically everything wrong. ;-)
But maybe we should drop
BDRV_BLOCK_RAW... Does it do anything good for us in the raw driver? Shouldn’t it too just return DATA | RECURSE?
DATA | RECURSE is still DATA, i.e. marks the block as allocated. If you do that unconditionally, we will never consider a block unallocated. RECURSE doesn't undo this, the only thing it might do is settting ZERO additionally.
So I would say unconditionally returning DATA | RECURSE is almost always wrong.
Kevin
Re: [Qemu-devel] [PATCH 3/3] vpc: Do not return RAW from block_status
Quoted 22 lines · Kevin Wolf
Am 12.08.2019 um 17:56 hat Max Reitz geschrieben:
Quoted 21 lines · Vladimir Sementsov-Ogievskiy
Quoted 6 lines
Quoted 5 lines · Max Reitz
vpc is not really a passthrough driver, even when using the fixed subformat (where host and guest offsets are equal). It should handle preallocation like all other drivers do, namely by returning DATA | RECURSE instead of RAW.
Quoted 7 lines
Quoted 2 lines
There is no tangible difference but the fact that
bdrv_is_allocated()no longer falls through to the protocol layer.Hmm. Isn't a real bug (fixed by this patch) ?
Assume
vpc->fileis qcow2 with backing, which have "unallocated" region, which is backed by actual data in backing file.Come on now.
Quoted 3 lines
So, this region will be reported as not allocated and will be skipped by any copying loop using block-status? Is it a bug of
BDRV_BLOCK_RAWitself? Or I don't understand something..
Quoted 8 lines
Quoted 5 lines
I think what you don’t understand is that if you have a vpc file inside of a qcow2 file, you’re doing basically everything wrong. ;-)
But maybe we should drop
BDRV_BLOCK_RAW... Does it do anything good for us in the raw driver? Shouldn’t it too just return DATA | RECURSE?DATA | RECURSE is still DATA, i.e. marks the block as allocated. If you do that unconditionally, we will never consider a block unallocated.
Which is correct for formats that do not have backing files.
Quoted 5 lines
RECURSE doesn't undo this, the only thing it might do is settting ZERO additionally.
So I would say unconditionally returning DATA | RECURSE is almost always wrong.
I would say it’s always right when it is a format driver and there is no backing file.
Max
Quoted 17 lines · Max Reitz
Hi,
69f47505ee66afaa513305de0c1895a224e52c45changedblock_statusso that it would only go down to the protocol layer if the format layer returnedBDRV_BLOCK_RECURSE, thus indicating that it has no sufficient information whether a given range in the image is zero or not. Generally, this is because the image is preallocated and thus all ranges appear as zeroes.However, it only implemented this preallocation detection for qcow2. There are more formats that support preallocation, though: vdi, vhdx, vmdk, vpc. (Funny how they all start with “v”.)
For vdi, vmdk, and vpc, the fix is rather simple, because they really have different subformats depending on whether an image is preallocated or not. This makes the check very simple.
Quoted 7 lines
vhdx is more like qcow2, where after the image has been created, it isn’t clear whether it’s been preallocated or everything is allocated because everything was already written to.
69f47505eeadded a heuristic to qcow2 to get around this, but I think that’s too much for vhdx. I just left it unfixed, because I don’t care that much, honestly (and I don’t think anyone else does).
What's the practical outcome of that, and is the limitation documented somewhere?
(I'm fine with not fixing it, I just want it documented somehow.)
Quoted 11 lines
Max Reitz (3):
vdi: Makeblock_statusrecurse for fixed images
vmdk: Makeblock_statusrecurse for flat extents
vpc: Do not return RAW fromblock_statusblock/vdi.c | 3 ++- block/vmdk.c | 3 +++ block/vpc.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-)
Quoted 28 lines · John Snow
Quoted 17 lines · Max Reitz
Hi,
69f47505ee66afaa513305de0c1895a224e52c45changedblock_statusso that it would only go down to the protocol layer if the format layer returnedBDRV_BLOCK_RECURSE, thus indicating that it has no sufficient information whether a given range in the image is zero or not. Generally, this is because the image is preallocated and thus all ranges appear as zeroes.However, it only implemented this preallocation detection for qcow2. There are more formats that support preallocation, though: vdi, vhdx, vmdk, vpc. (Funny how they all start with “v”.)
For vdi, vmdk, and vpc, the fix is rather simple, because they really have different subformats depending on whether an image is preallocated or not. This makes the check very simple.
Quoted 7 lines
vhdx is more like qcow2, where after the image has been created, it isn’t clear whether it’s been preallocated or everything is allocated because everything was already written to.
69f47505eeadded a heuristic to qcow2 to get around this, but I think that’s too much for vhdx. I just left it unfixed, because I don’t care that much, honestly (and I don’t think anyone else does).
Quoted 2 lines
What's the practical outcome of that, and is the limitation documented somewhere?
The outcome is that it if you preallocate a vhdx image (subformat=fixed), you’ll see that all sectors contain data, even if they may be zero sectors on the filesystem level.
I don’t think it’s user-visible whatsoever.
Quoted 1 line
(I'm fine with not fixing it, I just want it documented somehow.)
I am really not inclined to start any documentation on the particularities with which qemu handles vhdx images.
(Especially so considering we don’t even have any documentation on the qcow2 case. The stress in my paragraph was “heuristic”. If you preallocate a qcow2 image, but then discard enough sectors that the heuristic thinks you didn’t, you’ll have the same effect. Or if you grow a preallocated image without preallocating the new area.)
Max
Quoted 11 lines
Quoted 11 lines
Max Reitz (3):
vdi: Makeblock_statusrecurse for fixed images
vmdk: Makeblock_statusrecurse for flat extents
vpc: Do not return RAW fromblock_statusblock/vdi.c | 3 ++- block/vmdk.c | 3 +++ block/vpc.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-)
Quoted 29 lines · Max Reitz
Quoted 28 lines · John Snow
Quoted 24 lines · Max Reitz
Hi,
69f47505ee66afaa513305de0c1895a224e52c45changedblock_statusso that it would only go down to the protocol layer if the format layer returnedBDRV_BLOCK_RECURSE, thus indicating that it has no sufficient information whether a given range in the image is zero or not. Generally, this is because the image is preallocated and thus all ranges appear as zeroes.However, it only implemented this preallocation detection for qcow2. There are more formats that support preallocation, though: vdi, vhdx, vmdk, vpc. (Funny how they all start with “v”.)
For vdi, vmdk, and vpc, the fix is rather simple, because they really have different subformats depending on whether an image is preallocated or not. This makes the check very simple.
vhdx is more like qcow2, where after the image has been created, it isn’t clear whether it’s been preallocated or everything is allocated because everything was already written to.
69f47505eeadded a heuristic to qcow2 to get around this, but I think that’s too much for vhdx. I just left it unfixed, because I don’t care that much, honestly (and I don’t think anyone else does).
Quoted 9 lines
Quoted 2 lines
What's the practical outcome of that, and is the limitation documented somewhere?
The outcome is that it if you preallocate a vhdx image (subformat=fixed), you’ll see that all sectors contain data, even if they may be zero sectors on the filesystem level.
I don’t think it’s user-visible whatsoever.
But it might mean that doing things with sync=top might over-allocate data depending on the destination, wouldn't it?
That's not crucial, but it's possibly visible, no?
Quoted 5 lines
Quoted 1 line
(I'm fine with not fixing it, I just want it documented somehow.)
I am really not inclined to start any documentation on the particularities with which qemu handles vhdx images.
Quoted 8 lines
(Especially so considering we don’t even have any documentation on the qcow2 case. The stress in my paragraph was “heuristic”. If you preallocate a qcow2 image, but then discard enough sectors that the heuristic thinks you didn’t, you’ll have the same effect. Or if you grow a preallocated image without preallocating the new area.)
Max
"But our qcow2 docs are also bad" is the kind of argument I can't *really* disagree with, but...
(I wish we did have a documentation manual per-format that mentioned some gotchas and general info about each format, but I can't really ask you to do that now: I just worry when I see patches like this that the knowledge or memory that there ever was a quirk will vanish immediately.)
--js
Quoted 39 lines · John Snow
Quoted 36 lines · Max Reitz
Quoted 28 lines · John Snow
Quoted 17 lines · Max Reitz
Hi,
69f47505ee66afaa513305de0c1895a224e52c45changedblock_statusso that it would only go down to the protocol layer if the format layer returnedBDRV_BLOCK_RECURSE, thus indicating that it has no sufficient information whether a given range in the image is zero or not. Generally, this is because the image is preallocated and thus all ranges appear as zeroes.However, it only implemented this preallocation detection for qcow2. There are more formats that support preallocation, though: vdi, vhdx, vmdk, vpc. (Funny how they all start with “v”.)
For vdi, vmdk, and vpc, the fix is rather simple, because they really have different subformats depending on whether an image is preallocated or not. This makes the check very simple.
Quoted 7 lines
vhdx is more like qcow2, where after the image has been created, it isn’t clear whether it’s been preallocated or everything is allocated because everything was already written to.
69f47505eeadded a heuristic to qcow2 to get around this, but I think that’s too much for vhdx. I just left it unfixed, because I don’t care that much, honestly (and I don’t think anyone else does).Quoted 2 lines
What's the practical outcome of that, and is the limitation documented somewhere?
The outcome is that it if you preallocate a vhdx image (subformat=fixed), you’ll see that all sectors contain data, even if they may be zero sectors on the filesystem level.
Quoted 7 lines
Quoted 2 lines
I don’t think it’s user-visible whatsoever.
But it might mean that doing things with sync=top might over-allocate data depending on the destination, wouldn't it?
That's not crucial, but it's possibly visible, no?
I don’t think it has anything to do with sync=top because whether a block is zero on the protocol level has nothing to do with whether it is allocated on the format level.
It may make a difference for convert which uses block_status to inquire the zero status. However, it also does zero-detection, so...
Quoted 11 lines
Quoted 11 lines
Quoted 1 line
(I'm fine with not fixing it, I just want it documented somehow.)
I am really not inclined to start any documentation on the particularities with which qemu handles vhdx images.
(Especially so considering we don’t even have any documentation on the qcow2 case. The stress in my paragraph was “heuristic”. If you preallocate a qcow2 image, but then discard enough sectors that the heuristic thinks you didn’t, you’ll have the same effect. Or if you grow a preallocated image without preallocating the new area.)
Quoted 5 lines
Quoted 2 lines
Max
"But our qcow2 docs are also bad" is the kind of argument I can't *really* disagree with, but...
My main argument is that nobody would read the vhdx docs anyway.
Max
Quoted 7 lines
(I wish we did have a documentation manual per-format that mentioned some gotchas and general info about each format, but I can't really ask you to do that now: I just worry when I see patches like this that the knowledge or memory that there ever was a quirk will vanish immediately.)
--js
John Snow
Reviewed-byQuoted 46 lines · Max Reitz
Quoted 45 lines · John Snow
Quoted 29 lines · Max Reitz
Quoted 28 lines · John Snow
Quoted 24 lines · Max Reitz
Hi,
69f47505ee66afaa513305de0c1895a224e52c45changedblock_statusso that it would only go down to the protocol layer if the format layer returnedBDRV_BLOCK_RECURSE, thus indicating that it has no sufficient information whether a given range in the image is zero or not. Generally, this is because the image is preallocated and thus all ranges appear as zeroes.However, it only implemented this preallocation detection for qcow2. There are more formats that support preallocation, though: vdi, vhdx, vmdk, vpc. (Funny how they all start with “v”.)
For vdi, vmdk, and vpc, the fix is rather simple, because they really have different subformats depending on whether an image is preallocated or not. This makes the check very simple.
vhdx is more like qcow2, where after the image has been created, it isn’t clear whether it’s been preallocated or everything is allocated because everything was already written to.
69f47505eeadded a heuristic to qcow2 to get around this, but I think that’s too much for vhdx. I just left it unfixed, because I don’t care that much, honestly (and I don’t think anyone else does).Quoted 9 lines
Quoted 2 lines
What's the practical outcome of that, and is the limitation documented somewhere?
The outcome is that it if you preallocate a vhdx image (subformat=fixed), you’ll see that all sectors contain data, even if they may be zero sectors on the filesystem level.
I don’t think it’s user-visible whatsoever.
But it might mean that doing things with sync=top might over-allocate data depending on the destination, wouldn't it?
Quoted 9 lines
Quoted 1 line
That's not crucial, but it's possibly visible, no?
I don’t think it has anything to do with sync=top because whether a block is zero on the protocol level has nothing to do with whether it is allocated on the format level.
It may make a difference for convert which uses
block_statusto inquire the zero status. However, it also does zero-detection, so...
Oh, okay then. Probably... fine, but I have a nagging doubt relating to some of the fallbacks in e.g. qcow2 that tend to inflate zeroes in some cases (or used to. Maybe it's been fixed since.)
...but I can't point to anything, so it's fine, and I'm just drawing things out for no reason.
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 1 line
(I'm fine with not fixing it, I just want it documented somehow.)
I am really not inclined to start any documentation on the particularities with which qemu handles vhdx images.
(Especially so considering we don’t even have any documentation on the qcow2 case. The stress in my paragraph was “heuristic”. If you preallocate a qcow2 image, but then discard enough sectors that the heuristic thinks you didn’t, you’ll have the same effect. Or if you grow a preallocated image without preallocating the new area.)
Max
Quoted 7 lines
Quoted 2 lines
"But our qcow2 docs are also bad" is the kind of argument I can't *really* disagree with, but...
My main argument is that nobody would read the vhdx docs anyway.
Max
That's the sort of thing I'd like to change, but I guess I haven't really made good on that desire in any way, so what good is that?
--js
Quoted 30 lines · Max Reitz
Hi,
69f47505ee66afaa513305de0c1895a224e52c45changedblock_statusso that it would only go down to the protocol layer if the format layer returnedBDRV_BLOCK_RECURSE, thus indicating that it has no sufficient information whether a given range in the image is zero or not. Generally, this is because the image is preallocated and thus all ranges appear as zeroes.However, it only implemented this preallocation detection for qcow2. There are more formats that support preallocation, though: vdi, vhdx, vmdk, vpc. (Funny how they all start with “v”.)
For vdi, vmdk, and vpc, the fix is rather simple, because they really have different subformats depending on whether an image is preallocated or not. This makes the check very simple.
vhdx is more like qcow2, where after the image has been created, it isn’t clear whether it’s been preallocated or everything is allocated because everything was already written to.
69f47505eeadded a heuristic to qcow2 to get around this, but I think that’s too much for vhdx. I just left it unfixed, because I don’t care that much, honestly (and I don’t think anyone else does).Max Reitz (3):
vdi: Makeblock_statusrecurse for fixed images
vmdk: Makeblock_statusrecurse for flat extents
vpc: Do not return RAW fromblock_status
Quoted 4 lines
block/vdi.c | 3 ++- block/vmdk.c | 3 +++ block/vpc.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-)
Thanks for the reviews, applied to my block-next branch:
https://git.xanclic.moe/XanClic/qemu/commits/branch/block-next
Max