From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zvv6F-0002Rq-I2 for qemu-devel@nongnu.org; Mon, 09 Nov 2015 17:39:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zvv6E-0004n3-DO for qemu-devel@nongnu.org; Mon, 09 Nov 2015 17:39:43 -0500 From: Max Reitz Date: Mon, 9 Nov 2015 23:39:09 +0100 Message-Id: <1447108773-6836-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH v7 for-2.6 00/24] block: Rework bdrv_close_all() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: Kevin Wolf , Alberto Garcia , John Snow , Markus Armbruster , qemu-devel@nongnu.org, Stefan Hajnoczi , Paolo Bonzini , Max Reitz 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 | 92 ++++++++++++++++++ tests/qemu-iotests/140.out | 16 ++++ tests/qemu-iotests/141 | 166 +++++++++++++++++++++++++++++++++ tests/qemu-iotests/141.out | 47 ++++++++++ tests/qemu-iotests/common.filter | 13 +++ tests/qemu-iotests/common.qemu | 15 ++- tests/qemu-iotests/group | 3 + 25 files changed, 747 insertions(+), 116 deletions(-) create mode 100644 stubs/blockdev-close-all-bdrv-states.c create mode 100755 tests/qemu-iotests/117 create mode 100644 tests/qemu-iotests/117.out create mode 100755 tests/qemu-iotests/140 create mode 100644 tests/qemu-iotests/140.out create mode 100755 tests/qemu-iotests/141 create mode 100644 tests/qemu-iotests/141.out -- 2.6.2