[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 28/48] block: Add blk_remove_all_bs()
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 28/48] block: Add blk_remove_all_bs() |
Date: |
Fri, 29 Jan 2016 18:37:34 +0100 |
From: Max Reitz <address@hidden>
When bdrv_close_all() is called, instead of force-closing all root
BlockDriverStates, it is better to just drop the reference from all
BlockBackends and let them be closed automatically. This prevents BDS
from getting closed that are still referenced by other BDS, which may
result in loss of cached data.
This patch adds a function for doing that, but does not yet incorporate
it in bdrv_close_all().
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/block-backend.c | 15 +++++++++++++++
include/sysemu/block-backend.h | 1 +
2 files changed, 16 insertions(+)
diff --git a/block/block-backend.c b/block/block-backend.c
index 7f5ad59..ebdf78a 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -223,6 +223,21 @@ void blk_unref(BlockBackend *blk)
}
}
+void blk_remove_all_bs(void)
+{
+ BlockBackend *blk;
+
+ QTAILQ_FOREACH(blk, &blk_backends, link) {
+ AioContext *ctx = blk_get_aio_context(blk);
+
+ aio_context_acquire(ctx);
+ if (blk->bs) {
+ blk_remove_bs(blk);
+ }
+ aio_context_release(ctx);
+ }
+}
+
/*
* Return the BlockBackend after @blk.
* If @blk is null, return the first one.
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index ae4efb4..ec30331 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -68,6 +68,7 @@ BlockBackend *blk_new_open(const char *name, const char
*filename,
int blk_get_refcnt(BlockBackend *blk);
void blk_ref(BlockBackend *blk);
void blk_unref(BlockBackend *blk);
+void blk_remove_all_bs(void);
const char *blk_name(BlockBackend *blk);
BlockBackend *blk_by_name(const char *name);
BlockBackend *blk_next(BlockBackend *blk);
--
1.8.3.1
- [Qemu-block] [PULL 19/48] virtio-blk: Functions for op blocker management, (continued)
- [Qemu-block] [PULL 19/48] virtio-blk: Functions for op blocker management, Kevin Wolf, 2016/01/29
- [Qemu-block] [PULL 20/48] virtio-scsi: Catch BDS-BB removal/insertion, Kevin Wolf, 2016/01/29
- [Qemu-block] [PULL 13/48] iotests: Make redirecting qemu's stderr optional, Kevin Wolf, 2016/01/29
- [Qemu-block] [PULL 18/48] block: Add BB-BDS remove/insert notifiers, Kevin Wolf, 2016/01/29
- [Qemu-block] [PULL 17/48] iotests: Add test for eject under NBD server, Kevin Wolf, 2016/01/29
- [Qemu-block] [PULL 21/48] nbd: Switch from close to eject notifier, Kevin Wolf, 2016/01/29
- [Qemu-block] [PULL 23/48] block: Use blk_remove_bs() in blk_delete(), Kevin Wolf, 2016/01/29
- [Qemu-block] [PULL 24/48] blockdev: Use blk_remove_bs() in do_drive_del(), Kevin Wolf, 2016/01/29
- [Qemu-block] [PULL 25/48] block: Make bdrv_close() static, Kevin Wolf, 2016/01/29
- [Qemu-block] [PULL 26/48] block: Add list of all BlockDriverStates, Kevin Wolf, 2016/01/29
- [Qemu-block] [PULL 28/48] block: Add blk_remove_all_bs(),
Kevin Wolf <=
- [Qemu-block] [PULL 22/48] block: Remove BDS close notifier, Kevin Wolf, 2016/01/29
- [Qemu-block] [PULL 30/48] iotests: Add test for multiple BB on BDS tree, Kevin Wolf, 2016/01/29
- [Qemu-block] [PULL 27/48] blockdev: Keep track of monitor-owned BDS, Kevin Wolf, 2016/01/29
- [Qemu-block] [PULL 31/48] iotests: Add test for block jobs and BDS ejection, Kevin Wolf, 2016/01/29
- [Qemu-block] [PULL 32/48] block: acquire in bdrv_query_image_info, Kevin Wolf, 2016/01/29
- [Qemu-block] [PULL 29/48] block: Rewrite bdrv_close_all(), Kevin Wolf, 2016/01/29
- [Qemu-block] [PULL 33/48] block: Add "file" output parameter to block status query functions, Kevin Wolf, 2016/01/29
- [Qemu-block] [PULL 35/48] qcow2: Assign bs->file->bs to file in qcow2_co_get_block_status, Kevin Wolf, 2016/01/29
- [Qemu-block] [PULL 34/48] qcow: Assign bs->file->bs to file in qcow_co_get_block_status, Kevin Wolf, 2016/01/29
- [Qemu-block] [PULL 38/48] parallels: Assign bs->file->bs to file in parallels_co_get_block_status, Kevin Wolf, 2016/01/29