util/Makefile.objs | 1 + block/qcow2.h | 17 +- include/block/block-copy.h | 5 +- include/block/block.h | 6 +- include/block/block_int.h | 17 +- include/block/nvme.h | 19 +- include/hw/virtio/virtio.h | 7 - include/qemu/co-shared-resource.h | 71 ++++ include/qemu/compiler.h | 7 + include/sysemu/block-backend.h | 8 +- block/block-backend.c | 23 +- block/block-copy.c | 182 ++++++----- block/commit.c | 5 +- block/copy-on-read.c | 8 - block/crypto.c | 8 +- block/file-posix.c | 11 +- block/file-win32.c | 3 +- block/gluster.c | 1 + block/io.c | 29 +- block/iscsi.c | 10 +- block/mirror.c | 198 +++++------ block/nfs.c | 2 +- block/nvme.c | 155 ++++++++- block/parallels.c | 18 +- block/qcow.c | 9 +- block/qcow2-refcount.c | 2 +- block/qcow2-snapshot.c | 323 +++++++++++++++++- block/qcow2.c | 200 +++++++++--- block/qed.c | 8 +- block/raw-format.c | 5 +- block/rbd.c | 1 + block/sheepdog.c | 5 +- block/ssh.c | 3 +- block/vdi.c | 2 +- block/vhdx-log.c | 4 +- block/vhdx.c | 7 +- block/vmdk.c | 8 +- block/vpc.c | 2 +- blockdev.c | 2 +- hw/block/virtio-blk.c | 4 +- hw/net/virtio-net.c | 10 +- qemu-img.c | 46 +-- qemu-io-cmds.c | 7 +- tests/test-block-iothread.c | 8 +- util/hbitmap.c | 8 + util/qemu-co-shared-resource.c | 76 +++++ block/trace-events | 9 +- python/qemu/machine.py | 15 +- python/qemu/qtest.py | 9 +- tests/qemu-iotests/083 | 6 +- tests/qemu-iotests/083.out | 34 +- tests/qemu-iotests/093 | 19 +- tests/qemu-iotests/136 | 14 +- tests/qemu-iotests/140 | 8 +- tests/qemu-iotests/140.out | 2 +- tests/qemu-iotests/143 | 6 +- tests/qemu-iotests/143.out | 2 +- tests/qemu-iotests/147 | 2 +- tests/qemu-iotests/181 | 2 +- tests/qemu-iotests/182 | 4 +- tests/qemu-iotests/183 | 2 +- tests/qemu-iotests/192 | 4 +- tests/qemu-iotests/192.out | 2 +- tests/qemu-iotests/194 | 4 +- tests/qemu-iotests/201 | 2 +- tests/qemu-iotests/205 | 2 +- tests/qemu-iotests/208 | 2 +- tests/qemu-iotests/209 | 3 +- tests/qemu-iotests/222 | 2 +- tests/qemu-iotests/223 | 14 +- tests/qemu-iotests/240 | 4 +- tests/qemu-iotests/241 | 2 - tests/qemu-iotests/245 | 2 +- tests/qemu-iotests/261 | 523 ++++++++++++++++++++++++++++++ tests/qemu-iotests/261.out | 346 ++++++++++++++++++++ tests/qemu-iotests/264 | 2 + tests/qemu-iotests/267 | 4 +- tests/qemu-iotests/267.out | 2 +- tests/qemu-iotests/check | 15 +- tests/qemu-iotests/common.filter | 7 +- tests/qemu-iotests/common.nbd | 2 +- tests/qemu-iotests/common.rc | 20 ++ tests/qemu-iotests/group | 1 + tests/qemu-iotests/iotests.py | 68 ++-- 84 files changed, 2232 insertions(+), 486 deletions(-) create mode 100644 include/qemu/co-shared-resource.h create mode 100644 util/qemu-co-shared-resource.c create mode 100755 tests/qemu-iotests/261 create mode 100644 tests/qemu-iotests/261.out