There are a few problems with transactional job completion right now. First, if jobs complete so quickly they complete before remaining jobs get a chance to join the transaction, the completion mode can leave well known state and the QLIST can get corrupted and the transactional jobs can complete in batches or phases instead of all together.
Second, if two or more jobs defer to the main loop at roughly the same time, it's possible for one job's cleanup to directly invoke the other job's cleanup from within the same thread, leading to a situation that will deadlock the entire transaction. Thanks to Vladimir for pointing out these modes of failure. This series also does a little digging into refactoring Jobs into public and private interfaces. It's somewhat unrelated, but it was easier to include this with this series than separate it out and send it later. This comprises patches 2-6. The actual fixes here are in patches 1 and 7-10. A new test to catch Vladimir's failure scenario is in patch 11. v2: - Lots of differences in patches 2-9. - Cancel should now work on an "unstarted" blockjob. - New refactoring patches. - Added "start" property for BlockJob Drivers. ________________________________________________________________________________ For convenience, this branch is available at: https://github.com/jnsnow/qemu.git branch job-manual-start https://github.com/jnsnow/qemu/tree/job-manual-start This version is tagged job-manual-start-v2: https://github.com/jnsnow/qemu/releases/tag/job-manual-start-v2 John Snow (10): blockjob: centralize QMP event emissions Blockjobs: Internalize user_pause logic blockjobs: Always use block_job_get_aio_context blockjobs: split interface into public/private blockjobs: fix documentation blockjob: add .clean property blockjob: add .start field blockjob: add block_job_start blockjob: refactor backup_start as backup_job_create iotests: add transactional failure race test Vladimir Sementsov-Ogievskiy (1): blockjob: fix dead pointer in txn list block/backup.c | 59 ++++--- block/commit.c | 6 +- block/io.c | 6 +- block/mirror.c | 7 +- block/replication.c | 13 +- block/stream.c | 6 +- blockdev.c | 128 +++++++-------- blockjob.c | 72 +++++++-- include/block/block.h | 3 +- include/block/block_int.h | 29 ++-- include/block/blockjob.h | 345 +++------------------------------------- include/block/blockjob_int.h | 366 +++++++++++++++++++++++++++++++++++++++++++ qemu-img.c | 4 +- tests/qemu-iotests/124 | 91 +++++++++++ tests/qemu-iotests/124.out | 4 +- tests/test-blockjob-txn.c | 14 +- tests/test-blockjob.c | 2 +- 17 files changed, 688 insertions(+), 467 deletions(-) create mode 100644 include/block/blockjob_int.h -- 2.7.4