iotests/046: Test that discard/write_zeroes wait for dependencies
This is a regression test for the bug fixed in the previous commit where discard and write_zeroes operations wouldn't consider their dependencies in s->cluster_allocs. Without the fix, this results in a corrupted image. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-ID: <20260427170520.101242-5-kwolf@redhat.com> Reviewed-by: Denis V. Lunev <den@openvz.org> Tested-by: Denis V. Lunev <den@openvz.org> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Kevin Wolf committed
Apr 27, 2026 at 19:05 UTC
389f5bcc744d3ddc127d550a57261aed9bbba1f3
2 files changed
+82
tests/qemu-iotests/046
+46
@@ -184,6 +184,48 @@ aio_write -P 160 0x104000 0x18000
184
resume A
185
aio_flush
186
EOF
187
+
188
+# Create a pre-allocated zero cluster, then start a write on it and discard it
189
+# before the L2 update is made
190
+cat <<EOF
191
+write -P 181 0x120000 0x10000
192
+write -z 0x120000 0x10000
193
+
194
+break write_aio A
195
+aio_write -P 180 0x120000 0x10000
196
+wait_break A
197
+aio_discard 0x120000 0x10000
198
+resume A
199
+aio_flush
200
+EOF
201
+
202
+# Create a pre-allocated zero cluster, then start a write on it and a
203
+# concurrent zero write with MAY_UNMAP before the L2 update is made
204
+cat <<EOF
205
+write -P 181 0x130000 0x10000
206
+write -z 0x130000 0x10000
207
+
208
+break write_aio A
209
+aio_write -P 180 0x130000 0x10000
210
+wait_break A
211
+aio_write -z -u 0x130000 0x10000
212
+resume A
213
+aio_flush
214
+EOF
215
+
216
+# Create a pre-allocated zero cluster, then start a write on it and a
217
+# concurrent zero write without MAY_UNMAP before the L2 update is made
218
+cat <<EOF
219
+write -P 181 0x140000 0x10000
220
+write -z 0x140000 0x10000
221
+
222
+break write_aio A
223
+aio_write -P 180 0x140000 0x10000
224
+wait_break A
225
+aio_write -z 0x140000 0x10000
226
+resume A
227
+aio_flush
228
+EOF
229
}
230
231
overlay_io | $QEMU_IO blkdebug::"$TEST_IMG" | _filter_qemu_io |\
@@ -264,6 +306,10 @@ verify_io()
306
# Undefined content for 0x10c000 0x8000
307
echo read -P 160 0x114000 0x8000
308
echo read -P 17 0x11c000 0x4000
309
+
310
+ echo read -P 0 0x120000 0x10000
311
+ echo read -P 0 0x130000 0x10000
312
+ echo read -P 0 0x140000 0x10000
313
}
314
315
verify_io | $QEMU_IO "$TEST_IMG" | _filter_qemu_io
tests/qemu-iotests/046.out
+36
@@ -139,6 +139,36 @@ wrote XXX/XXX bytes at offset XXX
139
XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
140
wrote XXX/XXX bytes at offset XXX
141
XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
142
+wrote XXX/XXX bytes at offset XXX
143
+XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
144
+wrote XXX/XXX bytes at offset XXX
145
+XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
146
+blkdebug: Suspended request 'A'
147
+blkdebug: Resuming request 'A'
148
+wrote XXX/XXX bytes at offset XXX
149
+XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
150
+discarded XXX/XXX bytes at offset XXX
151
+XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
152
+wrote XXX/XXX bytes at offset XXX
153
+XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
154
+wrote XXX/XXX bytes at offset XXX
155
+XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
156
+blkdebug: Suspended request 'A'
157
+blkdebug: Resuming request 'A'
158
+wrote XXX/XXX bytes at offset XXX
159
+XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
160
+wrote XXX/XXX bytes at offset XXX
161
+XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
162
+wrote XXX/XXX bytes at offset XXX
163
+XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
164
+wrote XXX/XXX bytes at offset XXX
165
+XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
166
+blkdebug: Suspended request 'A'
167
+blkdebug: Resuming request 'A'
168
+wrote XXX/XXX bytes at offset XXX
169
+XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
170
+wrote XXX/XXX bytes at offset XXX
171
+XXX KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
172
173
== Verify image content ==
174
read 65536/65536 bytes at offset 0
@@ -239,5 +269,11 @@ read 32768/32768 bytes at offset 1130496
269
32 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
270
read 16384/16384 bytes at offset 1163264
271
16 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
272
+read 65536/65536 bytes at offset 1179648
273
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
274
+read 65536/65536 bytes at offset 1245184
275
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
276
+read 65536/65536 bytes at offset 1310720
277
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
278
No errors were found on the image.
279
*** done