block: Fix is_allocated() for truncated images
Status from this message: Thanks, applied to the block branch.
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest3 patches 1 replyApplied
- v23 patches 8 repliesSuperseded
- v13 patches 11 repliesSuperseded
Changes in v3 from the cover letter
- Patch 1:
- %s/backing_pnum/file_pnum/ [Kevin]
- ret |= BDRV_BLOCK_ZERO instead of ret = BDRV_BLOCK_ZERO (and modify the comment accordingly) [Kevin]
- Patch 3: With the latter change in patch 1, the sectors are now marked as allocated instead of not allocated; the qemu-img map output however stays the same (and therefore doesn't require the filter from the qemu-img/QMP commit series), because the sectors are marked as zero and qemu-img only outputs non-zero data clusters.
Patches in v3 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | block: Respect underlying file's EOFblock.c | +13 | 0 replies | |
| 2/3 | qemu-io: Respect early image end for mapqemu-io-cmds.c | +4 | 0 replies | |
| 3/3 | iotests: Add test for map commandstests/ tests/ tests/ | +75 | 0 replies |
Reviews trailers per patch
1 of 3 patches has a Reviewed-by or Acked-by.
| Patch | Eric Blake | Benoît Canet | Kevin Wolf |
|---|---|---|---|
| 1/3 | |||
| 2/3 | R-b | R-b | R-b |
| 3/3 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.
Cover letter [Qemu-devel] [PATCH v3 0/3] block: Fix is_allocated() for truncated images
Patch 2:
The bdrv_is_allocated() functions may return a number of zero sectors e.g. if a sector beyond the image end has been queried. Respect this case in qemu-io's map implementation so it doesn't run into an infinite loop (https://bugs.launchpad.net/qemu/+bug/1356969).
Patch 1:
In that bug report, bdrv_co_get_block_status() fell through to the underlying file to get additional information (whether the sectors are zeroed). However, the offset reported by the image format (qcow2) was beyond the size of the underlying file and so this second query returned only zero clusters which replaced the actual number of sectors queried in the "formatted" (on qcow2 level) image. This replacement is generally fine because it allows bdrv_co_get_block_status() to follow the granularity (holes and non-holes) of the underlying file, but not if only zero clusters could be queried (which indicates a request beyond the image end).
This patch makes bdrv_co_get_block_status() respect the underlying file's EOF and act accordingly.
Patch 3 adds a test for patch 1; a test which depends on patch 2 is included in v3 of my series "raw-posix: Fix raw_co_get_block_status()".
v3:
- Patch 1:
- %s/backing_pnum/file_pnum/ [Kevin]
- ret |= BDRV_BLOCK_ZERO instead of ret = BDRV_BLOCK_ZERO (and modify the comment accordingly) [Kevin]
- Patch 3: With the latter change in patch 1, the sectors are now marked as allocated instead of not allocated; the qemu-img map output however stays the same (and therefore doesn't require the filter from the qemu-img/QMP commit series), because the sectors are marked as zero and qemu-img only outputs non-zero data clusters.
git-backport-diff against v2:
Key:
[----] : patches are identical
[####] : number of functional differences between upstream/downstream patch [down] : patch is downstream-only
The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively
001/3:[0015] [FC] 'block: Respect underlying file's EOF' 002/3:[----] [--] 'qemu-io: Respect early image end for map' 003/3:[0002] [FC] 'iotests: Add test for map commands'
Max Reitz (3):
block: Respect underlying file's EOF
qemu-io: Respect early image end for map
iotests: Add test for map commands
block.c | 15 +++++++++-- qemu-io-cmds.c | 5 +++- tests/qemu-iotests/102 | 64 ++++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/102.out | 10 ++++++++ tests/qemu-iotests/group | 1 + 5 files changed, 92 insertions(+), 3 deletions(-) create mode 100755 tests/qemu-iotests/102 create mode 100644 tests/qemu-iotests/102.out
Signature · 1 line
1.9.3