mbox series

[0/2] Fix data corruption within preallocation

Message ID 20240711133242.251061-1-andrey.drobyshev@virtuozzo.com
Headers show
Series Fix data corruption within preallocation | expand

Message

Andrey Drobyshev July 11, 2024, 1:32 p.m. UTC
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