]> git.proxmox.com Git - mirror_qemu.git/commit - block.c
block: Rewrite bdrv_close_all()
authorMax Reitz <mreitz@redhat.com>
Fri, 29 Jan 2016 15:36:14 +0000 (16:36 +0100)
committerMax Reitz <mreitz@redhat.com>
Tue, 2 Feb 2016 16:50:46 +0000 (17:50 +0100)
commitca9bd24cf1d53775169ba9adc17e265554d1afed
treec8eda481f153bb8086cc2f59642564943efa136b
parentd8da3cef3bc649492d190e029343293df1386027
block: Rewrite bdrv_close_all()

This patch rewrites bdrv_close_all(): Until now, all root BDSs have been
force-closed. This is bad because it can lead to cached data not being
flushed to disk.

Instead, try to make all reference holders relinquish their reference
voluntarily:

1. All BlockBackend users are handled by making all BBs simply eject
   their BDS tree. Since a BDS can never be on top of a BB, this will
   not cause any of the issues as seen with the force-closing of BDSs.
   The references will be relinquished and any further access to the BB
   will fail gracefully.
2. All BDSs which are owned by the monitor itself (because they do not
   have a BB) are relinquished next.
3. Besides BBs and the monitor, block jobs and other BDSs are the only
   things left that can hold a reference to BDSs. After every remaining
   block job has been canceled, there should not be any BDSs left (and
   the loop added here will always terminate (as long as NDEBUG is not
   defined), because either all_bdrv_states will be empty or there will
   not be any block job left to cancel, failing the assertion).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c