xemu/block
Max Reitz 5cb2737e92 block/io: Delay decrementing the quiesce_counter
When ending a drained section, bdrv_do_drained_end() currently first
decrements the quiesce_counter, and only then actually ends the drain.

The bdrv_drain_invoke(bs, false) call may cause graph changes.  Say the
graph change involves replacing an existing BB's ("blk") BDS
(blk_bs(blk)) by @bs.  Let us introducing the following values:
- bs_oqc = old_quiesce_counter
  (so bs->quiesce_counter == bs_oqc - 1)
- obs_qc = blk_bs(blk)->quiesce_counter (before bdrv_drain_invoke())

Let us assume there is no blk_pread_unthrottled() involved, so
blk->quiesce_counter == obs_qc (before bdrv_drain_invoke()).

Now replacing blk_bs(blk) by @bs will reduce blk->quiesce_counter by
obs_qc (making it 0) and increase it by bs_oqc-1 (making it bs_oqc-1).

bdrv_drain_invoke() returns and we invoke bdrv_parent_drained_end().
This will decrement blk->quiesce_counter by one, so it would be -1 --
were there not an assertion against that in blk_root_drained_end().

We therefore have to keep the quiesce_counter up at least until
bdrv_drain_invoke() returns, so that bdrv_parent_drained_end() does the
right thing for the parents @bs got during bdrv_drain_invoke().

But let us delay it even further, namely until bdrv_parent_drained_end()
returns, because then it mirrors bdrv_do_drained_begin(): There, we
first increment the quiesce_counter, then begin draining the parents,
and then call bdrv_drain_invoke().  It makes sense to let
bdrv_do_drained_end() unravel this exactly in reverse.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2019-06-04 15:20:41 +02:00
..
accounting.c block/accounting: introduce latency histogram 2018-03-19 14:58:37 -05:00
backup.c block/backup: refactor: split out backup_calculate_cluster_size 2019-05-28 20:30:55 +02:00
blkdebug.c block: Advertise BDRV_REQ_NO_FALLBACK in filter drivers 2019-03-26 11:37:51 +01:00
blklogwrites.c block: Purify .bdrv_refresh_filename() 2019-02-25 15:11:27 +01:00
blkreplay.c trivial: Make bios files and source files non-executable 2018-09-25 17:26:18 +02:00
blkverify.c block: Purify .bdrv_refresh_filename() 2019-02-25 15:11:27 +01:00
block-backend.c block: Make bdrv_root_attach_child() unref child_bs on failure 2019-05-28 20:30:55 +02:00
bochs.c avoid TABs in files that only contain a few 2019-01-11 15:46:56 +01:00
cloop.c block: Require auto-read-only for existing fallbacks 2018-11-05 15:09:55 +01:00
commit.c commit: Use bdrv_append() in commit_start() 2019-05-07 17:14:21 +02:00
copy-on-read.c block: Advertise BDRV_REQ_NO_FALLBACK in filter drivers 2019-03-26 11:37:51 +01:00
create.c jobs: utilize job_exit shim 2018-08-31 16:28:33 +02:00
crypto.c block: Make bdrv_{copy_on_read,crypto_luks,replication} static 2019-03-19 15:49:29 +01:00
crypto.h Clean up ill-advised or unusual header guards 2019-05-13 08:58:55 +02:00
curl.c block/curl: Implement bdrv_refresh_filename() 2019-02-25 15:11:27 +01:00
dirty-bitmap.c qapi: support external bitmaps in block-dirty-bitmap-merge 2019-05-28 19:33:31 -04:00
dmg-bz2.c dmg: Move libbz2 code to dmg-bz2.so 2016-10-07 14:14:06 +02:00
dmg-lzfse.c block: adding lzfse decompressing support as a module. 2018-12-14 11:52:40 +01:00
dmg.c dmg: don't skip zero chunk 2019-01-04 11:15:09 +00:00
dmg.h dmg: including dmg-lzfse module inside dmg block driver. 2018-12-14 11:52:40 +01:00
file-posix.c block/file-posix: Unaligned O_DIRECT block-status 2019-05-20 17:08:57 +02:00
file-win32.c avoid TABs in files that only contain a few 2019-01-11 15:46:56 +01:00
gluster.c block/gluster: limit the transfer size to 512 MiB 2019-04-02 12:04:44 +02:00
io.c block/io: Delay decrementing the quiesce_counter 2019-06-04 15:20:41 +02:00
iscsi-opts.c Move include qemu/option.h from qemu-common.h to actual users 2018-02-09 13:52:16 +01:00
iscsi.c block/iscsi: Restrict Linux-specific code 2019-03-11 16:33:49 +01:00
linux-aio.c avoid TABs in files that only contain a few 2019-01-11 15:46:56 +01:00
Makefile.objs qcow2: add separate file for threaded data processing functions 2019-05-28 20:30:55 +02:00
mirror.c blockjob: Propagate AioContext change to all job nodes 2019-05-20 17:08:56 +02:00
nbd-client.c nbd/client: Trace server noncompliance on structured reads 2019-04-01 08:58:04 -05:00
nbd-client.h nbd: Restrict connection_co reentrance 2019-02-25 15:03:19 +01:00
nbd.c nbd/client: Lower min_block for block-status, unaligned size 2019-03-30 20:52:19 -05:00
nfs.c block: Purify .bdrv_refresh_filename() 2019-02-25 15:11:27 +01:00
null.c block/null: Generate filename even with latency-ns 2019-02-25 15:11:27 +01:00
nvme.c block/nvme: Fix bdrv_refresh_filename() 2019-02-25 15:11:27 +01:00
parallels.c block/parallels: use buffer-based io 2019-04-30 15:29:00 +02:00
parallels.h Clean up includes 2018-02-09 05:05:11 +01:00
qapi.c qemu-img: Saner printing of large file sizes 2019-04-30 15:29:00 +02:00
qcow2-bitmap.c qcow2-bitmap: initialize bitmap directory alignment 2019-05-28 20:30:55 +02:00
qcow2-cache.c qcow2.h: add missing include 2019-05-28 20:30:55 +02:00
qcow2-cluster.c qcow2: skip writing zero buffers to empty COW areas 2019-05-28 20:30:55 +02:00
qcow2-refcount.c block: avoid recursive block_status call if possible 2019-06-04 15:20:41 +02:00
qcow2-snapshot.c qcow2.h: add missing include 2019-05-28 20:30:55 +02:00
qcow2-threads.c qcow2: do encryption in threads 2019-05-28 20:30:55 +02:00
qcow2.c block: avoid recursive block_status call if possible 2019-06-04 15:20:41 +02:00
qcow2.h block: avoid recursive block_status call if possible 2019-06-04 15:20:41 +02:00
qcow.c block/qcow: use buffer-based io 2019-04-30 15:29:00 +02:00
qed-check.c block/qed: add missed coroutine_fn markers 2019-04-30 15:29:00 +02:00
qed-cluster.c qed: protect table cache with CoMutex 2017-07-17 11:34:11 +08:00
qed-l2-cache.c qed: protect table cache with CoMutex 2017-07-17 11:34:11 +08:00
qed-table.c block/qed: add missed coroutine_fn markers 2019-04-30 15:29:00 +02:00
qed.c block/qed: add missed coroutine_fn markers 2019-04-30 15:29:00 +02:00
qed.h block/qed: add missed coroutine_fn markers 2019-04-30 15:29:00 +02:00
quorum.c block: Make bdrv_root_attach_child() unref child_bs on failure 2019-05-28 20:30:55 +02:00
raw-format.c block: Advertise BDRV_REQ_NO_FALLBACK in filter drivers 2019-03-26 11:37:51 +01:00
rbd.c block: Add strong_runtime_opts to BlockDriver 2019-02-25 15:11:27 +01:00
replication.c block: Make bdrv_{copy_on_read,crypto_luks,replication} static 2019-03-19 15:49:29 +01:00
sheepdog.c block: Add strong_runtime_opts to BlockDriver 2019-02-25 15:11:27 +01:00
snapshot.c block/snapshot: remove bdrv_snapshot_delete_by_id_or_name 2019-02-25 15:03:18 +01:00
ssh.c block/ssh: Implement .bdrv_dirname() 2019-05-07 17:14:21 +02:00
stream.c block/stream: use buffer-based io 2019-04-30 15:29:00 +02:00
throttle-groups.c throttle-groups: fix restart coroutine iothread race 2019-01-24 10:02:28 +00:00
throttle.c block: Add strong_runtime_opts to BlockDriver 2019-02-25 15:11:27 +01:00
trace-events qcow2: skip writing zero buffers to empty COW areas 2019-05-28 20:30:55 +02:00
vdi.c vdi: Replace bdrv_{read,write}() with bdrv_{pread,pwrite}() 2019-05-10 16:45:40 +02:00
vhdx-endian.c block/vhdx: Don't take address of fields in packed structs 2018-11-05 15:09:54 +01:00
vhdx-log.c block/vhdx: Use IEC binary prefixes for size constants 2019-04-30 15:29:00 +02:00
vhdx.c block/vhdx: Use IEC binary prefixes for size constants 2019-04-30 15:29:00 +02:00
vhdx.h block/vhdx: Use IEC binary prefixes for size constants 2019-04-30 15:29:00 +02:00
vmdk.c vmdk: Set vmdk parent backing_format to vmdk 2019-04-30 15:29:00 +02:00
vpc.c vpc: unlock Coroutine lock to make IO submit Concurrently 2019-04-30 15:29:00 +02:00
vvfat.c vvfat: Replace bdrv_{read,write}() with bdrv_{pread,pwrite}() 2019-05-10 16:45:40 +02:00
vxhs.c block: Add strong_runtime_opts to BlockDriver 2019-02-25 15:11:27 +01:00
win32-aio.c file-win32: Switch to byte-based callbacks 2018-05-15 16:11:41 +02:00
write-threshold.c qapi: Drop qapi_event_send_FOO()'s Error ** argument 2018-08-28 18:21:38 +02:00