Skip to content

block/preallocate: fix image truncation logic

Denis V. Lunev via qemu-devel 3 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest6 patches 0 repliesNew
  2. v22 patches 0 repliesSuperseded
  3. v12 patches 3 repliesSuperseded

Changes in v3 from the cover letter

- the series has been completely rethinked

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6preallocate: truncate the image inside bdrv_inactivate()block/preallocate.c+7 -00 replies
2/6preallocate: do not enable filter inside preallocate_co_getlength()block/preallocate.c+1 -80 replies
3/6preallocate: rework preallocate_truncate_to_real_size()block/preallocate.c+7 -140 replies
4/6preallocate: remove bottom half from preallocate filterblock/preallocate.c+0 -390 replies
5/6preallocate: simplify preallocate_drop_resizeblock/preallocate.c+2 -340 replies
6/6iotests: add preallocate filter checkstests/qemu-iotests/tests/prealloc-checks tests/qemu-iotests/tests/prealloc-checks.out+303 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 0/6] block/preallocate: fix image truncation logic

Recent QEMU changes around preallocate_set_perm mandates that it is not possible to poll on aio_context inside this function anymore. Thus truncate operation has been moved inside bottom half. This bottom half is scheduled from preallocate_set_perm() and that is all.

This approach proven to be problematic in a lot of places once additional operations are executed over preallocate filter in production. The code validates that permissions have been really changed just after the call to the set operation.

A lot of time has been spent since the previous series in order to stabilize changes with a whole product regression. This is reflected with some unit tests added. Without this series 2 out of 3 are broken.

In general, the approach has been changed. We should not have image truncate inside permission handling routines. That would be quite incorrect and wrong, f.e. we potentially have truncate() executed once we returned from bdrv_inactivate() and the ownership of the image does not belong to us anymore.

It should be noted that the life cycle of the image length is quite similar to one of the CBT and thus places where CBT is handled should provide a good hint. This is just a guideline note.

Thus the most noticeable change is an addition of preallocate_inactivate() callback and cleanup of all asynchronous stuff.

Changes from v2:
- the series has been completely rethinked

CC Vladimir Sementsov-Ogievskiy <[email protected]>
CC Andrey Drobyshev <[email protected]>
CC Kevin Wolf <[email protected]>
CC Hanna Reitz <[email protected]>