Am 22.11.2019 um 17:05 hat Kevin Wolf geschrieben: > See patch 4 for the description of the bug fixed.
I'm applying patches 3 and 5-7 to the block branch because they make sense on their own. The real fix will need another approach because the error handling is broken in this one: If zeroing out fails (either because of NO_FALLBACK or because of some other I/O error), bdrv_co_truncate() will return failure, but the image size has already been increased, with potentially incorrect data in the new area. To fix this, we need to make sure that zeros will be read before we commit the new image size to the image file (e.g. qcow2 header) and to bs->total_sectors. In other words, it must become the responsibility of the block driver. To this effect, I'm planning to introduce a PREALLOC_MODE_ZERO_INIT flag that can be or'ed to the preallocation mode. This will fail by default because it looks like just another unimplemented preallocation mode to block drivers. It will be requested explicitly by commit jobs and automatically added by bdrv_co_truncate() if the backing file would become visible (like in this series, but now for all preallocation modes). I'm planning to implement it for qcow2 and file-posix for now, which should cover most interesting cases. Does this make sense to you? Kevin