Skip to content

Commit ff812c5

Browse files
Vladimir Sementsov-OgievskiyXanClic
authored andcommitted
qcow2: handle_dependencies(): relax conflict detection
There is no conflict and no dependency if we have parallel writes to different subclusters of one cluster when the cluster itself is already allocated. So, relax extra dependency. Measure performance: First, prepare build/qemu-img-old and build/qemu-img-new images. cd scripts/simplebench ./img_bench_templater.py Paste the following to stdin of running script: qemu_img=../../build/qemu-img-{old|new} $qemu_img create -f qcow2 -o extended_l2=on /ssd/x.qcow2 1G $qemu_img bench -c 100000 -d 8 [-s 2K|-s 2K -o 512|-s $((1024*2+512))] \ -w -t none -n /ssd/x.qcow2 The result: All results are in seconds ------------------ --------- --------- old new -s 2K 6.7 ± 15% 6.2 ± 12% -7% -s 2K -o 512 13 ± 3% 11 ± 5% -16% -s $((1024*2+512)) 9.5 ± 4% 8.4 -12% ------------------ --------- --------- So small writes are more independent now and that helps to keep deeper io queue which improves performance. 271 iotest output becomes racy for three allocation in one cluster. Second and third writes may finish in different order. Second and third requests don't depend on each other any more. Still they both depend on first request anyway. Filter out second and third write offsets to cover both possible outputs. Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]> Message-Id: <[email protected]> Reviewed-by: Eric Blake <[email protected]> Reviewed-by: Hanna Reitz <[email protected]> [hreitz: s/ an / and /] Signed-off-by: Hanna Reitz <[email protected]>
1 parent 6d207d3 commit ff812c5

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

block/qcow2-cluster.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,17 @@ static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset,
14031403
continue;
14041404
}
14051405

1406+
if (old_alloc->keep_old_clusters &&
1407+
(end <= l2meta_cow_start(old_alloc) ||
1408+
start >= l2meta_cow_end(old_alloc)))
1409+
{
1410+
/*
1411+
* Clusters intersect but COW areas don't. And cluster itself is
1412+
* already allocated. So, there is no actual conflict.
1413+
*/
1414+
continue;
1415+
}
1416+
14061417
/* Conflict */
14071418

14081419
if (start < old_start) {

tests/qemu-iotests/271

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,10 @@ EOF
893893
}
894894

895895
_make_test_img -o extended_l2=on 1M
896-
_concurrent_io | $QEMU_IO | _filter_qemu_io
896+
# Second and third writes in _concurrent_io() are independent and may finish in
897+
# different order. So, filter offset out to match both possible variants.
898+
_concurrent_io | $QEMU_IO | _filter_qemu_io | \
899+
$SED -e 's/\(20480\|40960\)/OFFSET/'
897900
_concurrent_verify | $QEMU_IO | _filter_qemu_io
898901

899902
# success, all done

tests/qemu-iotests/271.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,8 +719,8 @@ blkdebug: Suspended request 'A'
719719
blkdebug: Resuming request 'A'
720720
wrote 2048/2048 bytes at offset 30720
721721
2 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
722-
wrote 2048/2048 bytes at offset 20480
722+
wrote 2048/2048 bytes at offset OFFSET
723723
2 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
724-
wrote 2048/2048 bytes at offset 40960
724+
wrote 2048/2048 bytes at offset OFFSET
725725
2 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
726726
*** done

0 commit comments

Comments
 (0)