[PATCH 0/2] Fix data corruption within preallocation

Andrey Drobyshev posted 2 patches 4 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20240711133242.251061-1-andrey.drobyshev@virtuozzo.com
Maintainers: Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>
There is a newer version of this series
block/preallocate.c        | 11 +++++++++++
tests/qemu-iotests/298     | 34 ++++++++++++++++++++++++++++++++++
tests/qemu-iotests/298.out |  4 ++--
3 files changed, 47 insertions(+), 2 deletions(-)
[PATCH 0/2] Fix data corruption within preallocation
Posted by Andrey Drobyshev 4 months, 2 weeks ago
When there's an image with preallocation filter on top of it, there
might be a race where 2 async write requests try to simultaneously do
preallocation at the end of the file.  And this results into data being
zeroed after the actual write operation is performed.

Here we introduce a coroutine context lock within the preallocation
filter to protect file_end field, and the test which does fail without
the locking.

Note: the lock is only added to the operations which run in the
coroutine context and it seems to make the problem with async write
requests go away.  However there're other operations which are run
outside of the coroutine context and which also modify the file_end
field, e.g. preallocate_set_perm() and preallocate_child_perm().
Comments on how to protect the field properly regardless of the context
are welcome.

Andrey Drobyshev (1):
  iotests/298: add testcase for async writes with preallocation filter

Denis V. Lunev (1):
  block: zero data data corruption using prealloc-filter

 block/preallocate.c        | 11 +++++++++++
 tests/qemu-iotests/298     | 34 ++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/298.out |  4 ++--
 3 files changed, 47 insertions(+), 2 deletions(-)

--
2.39.3