mbox series

[v3,0/6] block/preallocate: fix image truncation logic

Message ID 20241128183911.837699-1-den@openvz.org (mailing list archive)
Headers show
Series block/preallocate: fix image truncation logic | expand

Message

Denis V. Lunev" via Nov. 28, 2024, 6:25 p.m. UTC
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

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
CC: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Hanna Reitz <hreitz@redhat.com>