Am 16.07.2024 um 16:41 hat Andrey Drobyshev geschrieben: > The testcase simply creates a 64G image with 1M clusters, generates a list > of 1M aligned offsets and feeds aio_write commands with those offsets to > qemu-io run with '--aio native --nocache'. Then we check the data > written at each of the offsets. Before the previous commit this could > result into a race within the preallocation filter which would zeroize > some clusters after actually writing data to them. > > Note: the test doesn't fail in 100% cases as there's a race involved, > but the failures are pretty consistent so it should be good enough for > detecting the problem. > > Signed-off-by: Andrey Drobyshev <andrey.drobys...@virtuozzo.com>
I left it running in a loop for a while, but couldn't reproduce the bug with this test. > tests/qemu-iotests/298 | 49 ++++++++++++++++++++++++++++++++++++++ > tests/qemu-iotests/298.out | 4 ++-- > 2 files changed, 51 insertions(+), 2 deletions(-) > > diff --git a/tests/qemu-iotests/298 b/tests/qemu-iotests/298 > index 09c9290711..b7126e9e15 100755 > --- a/tests/qemu-iotests/298 > +++ b/tests/qemu-iotests/298 > @@ -20,8 +20,10 @@ > > import os > import iotests > +import random > > MiB = 1024 * 1024 > +GiB = MiB * 1024 > disk = os.path.join(iotests.test_dir, 'disk') > overlay = os.path.join(iotests.test_dir, 'overlay') > refdisk = os.path.join(iotests.test_dir, 'refdisk') > @@ -176,5 +178,52 @@ class TestTruncate(iotests.QMPTestCase): > self.do_test('off', '150M') > > > +class TestPreallocAsyncWrites(iotests.QMPTestCase): > + def setUp(self): > + # Make sure we get reproducible write patterns on each run > + random.seed(42) > + iotests.qemu_img_create('-f', iotests.imgfmt, disk, '-o', > + f'cluster_size={MiB},lazy_refcounts=on', > + str(64 * GiB)) > + > + def tearDown(self): > + os.remove(disk) > + > + def test_prealloc_async_writes(self): > + def gen_write_pattern(): > + n = 0 > + while True: > + yield '-P 0xaa' if n else '-z' > + n = 1 - n This looks like a complicated way to write the following? # Alternate between write_zeroes and writing data def gen_write_pattern(): while True: yield '-z' yield '-P 0xaa' > + def gen_read_pattern(): > + n = 0 > + while True: > + yield '-P 0xaa' if n else '-P 0x00' > + n = 1 - n Same here. Kevin