Currently, bdrv_close_all() force-closes all BDSs with a BlockBackend,
which can lead to data corruption (see the iotest added in the final
patch of this series) and is most certainly very ugly.
This series reworks bdrv_close_all() to instead eject the BDS trees from
all BlockBackends and then close the monitor-owned BDS trees, which are
the only BDSs without a BB. In effect, all BDSs are closed just by
getting closed automatically due to their reference count becoming 0.
Note that the approach taken here leaks all BlockBackends. This does not
really matter, however, since qemu is about to exit anyway.
v7:
- Patch 3:
- Put common functionality of bdrv_release_*dirty_bitmap*() into a new
function bdrv_do_release_matching_dirty_bitmap() [John]
- Keep assertion against any bitmap being frozen in
bdrv_release_all_dirty_bitmaps() [John]
- Patches 4, 5, 6, 7, 8:
- Split off from old patch 4 [Kevin]
- Also: More code style changes ("() {" -> "()\n{")
- Also: Support for nbd+unix URLs
- Patch 10: Use nbd+unix [Fam for v5]
- Patches 11, 12, 13, 14, 15: Split off from old patch 7 [Kevin]
- Patch 24: Added [Paolo]
git-backport-diff against v6:
Key:
[] : patches are identical
[] : number of functional differences between upstream/downstream patch
[down] : patch is downstream-only
The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively
001/24:[] [--] 'blockdev: Add missing bdrv_unref() in drive-backup'
002/24:[] [--] 'blockjob: Call bdrv_unref() on creation error'
003/24:[0035] [FC] 'block: Release dirty bitmaps in bdrv_close()'
004/24:[down] 'iotests: Rename filter_nbd to _filter_nbd in 083'
005/24:[down] 'iotests: Change coding style of _filter_nbd in 083'
006/24:[0035] [FC] 'iotests: Move _filter_nbd into common.filter'
007/24:[down] 'iotests: Make _filter_nbd drop log lines'
008/24:[down] 'iotests: Make _filter_nbd support more URL types'
009/24:[] [--] 'iotests: Make redirecting qemu's stderr optional'
010/24:[0016] [FC] 'iotests: Add test for eject under NBD server'
011/24:[down] 'block: Add BB-BDS remove/insert notifiers'
012/24:[down] 'virtio-blk: Functions for op blocker management'
013/24:[down] 'virtio-scsi: Catch BDS-BB removal/insertion'
014/24:[down] 'nbd: Switch from close to eject notifier'
015/24:[down] 'block: Remove BDS close notifier'
016/24:[] [-C] 'block: Use blk_remove_bs() in blk_delete()'
017/24:[] [--] 'blockdev: Use blk_remove_bs() in do_drive_del()'
018/24:[] [--] 'block: Make bdrv_close() static'
019/24:[] [--] 'block: Add list of all BlockDriverStates'
020/24:[] [--] 'blockdev: Keep track of monitor-owned BDS'
021/24:[] [--] 'block: Add blk_remove_all_bs()'
022/24:[] [-C] 'block: Rewrite bdrv_close_all()'
023/24:[] [--] 'iotests: Add test for multiple BB on BDS tree'
024/24:[down] 'iotests: Add test for block jobs and BDS ejection'
Max Reitz (24):
blockdev: Add missing bdrv_unref() in drive-backup
blockjob: Call bdrv_unref() on creation error
block: Release dirty bitmaps in bdrv_close()
iotests: Rename filter_nbd to _filter_nbd in 083
iotests: Change coding style of _filter_nbd in 083
iotests: Move _filter_nbd into common.filter
iotests: Make _filter_nbd drop log lines
iotests: Make _filter_nbd support more URL types
iotests: Make redirecting qemu's stderr optional
iotests: Add test for eject under NBD server
block: Add BB-BDS remove/insert notifiers
virtio-blk: Functions for op blocker management
virtio-scsi: Catch BDS-BB removal/insertion
nbd: Switch from close to eject notifier
block: Remove BDS close notifier
block: Use blk_remove_bs() in blk_delete()
blockdev: Use blk_remove_bs() in do_drive_del()
block: Make bdrv_close() static
block: Add list of all BlockDriverStates
blockdev: Keep track of monitor-owned BDS
block: Add blk_remove_all_bs()
block: Rewrite bdrv_close_all()
iotests: Add test for multiple BB on BDS tree
iotests: Add test for block jobs and BDS ejection
block.c| 100 +++-
block/block-backend.c | 43 +++--
blockdev-nbd.c | 37 +---
blockdev.c | 28 +-
blockjob.c | 1 +
hw/block/dataplane/virtio-blk.c| 77 +++
hw/scsi/virtio-scsi.c | 59
include/block/block.h | 2 -
include/block/block_int.h | 8 +-
include/hw/virtio/virtio-scsi.h| 10 ++
include/sysemu/block-backend.h | 4 +-
nbd.c | 13 +++
stubs/Makefile.objs| 1 +
stubs/blockdev-close-all-bdrv-states.c | 5 +
tests/qemu-iotests/083 | 13 +--
tests/qemu-iotests/083.out | 10 --
tests/qemu-iotests/117 | 86 +
tests/qemu-iotests/117.out | 14 +++
tests/qemu-iotests/140