[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v4 10/11] block: Eject BDS tree from BB at bdrv_clos
From: |
Max Reitz |
Subject: |
[Qemu-block] [PATCH v4 10/11] block: Eject BDS tree from BB at bdrv_close_all() |
Date: |
Fri, 27 Feb 2015 11:43:59 -0500 |
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.
Signed-off-by: Max Reitz <address@hidden>
---
block.c | 11 +----------
block/block-backend.c | 13 +++++++++++++
include/sysemu/block-backend.h | 1 +
3 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/block.c b/block.c
index 0b0792c..a2637b6 100644
--- a/block.c
+++ b/block.c
@@ -1941,17 +1941,8 @@ static void bdrv_close(BlockDriverState *bs)
void bdrv_close_all(void)
{
- BlockDriverState *bs;
-
blockdev_close_all_bdrv_states();
-
- QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
- AioContext *aio_context = bdrv_get_aio_context(bs);
-
- aio_context_acquire(aio_context);
- bdrv_close(bs);
- aio_context_release(aio_context);
- }
+ blk_remove_all_bs();
}
/* Check if any requests are in-flight (including throttled requests) */
diff --git a/block/block-backend.c b/block/block-backend.c
index 7e9d53a..2e820fe 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -207,6 +207,19 @@ 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);
+ 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 e0a2749..ab765a7 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -67,6 +67,7 @@ BlockBackend *blk_new_open(const char *name, const char
*filename,
Error **errp);
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);
--
2.1.0
- [Qemu-block] [PATCH v4 00/11] block: Rework bdrv_close_all(), Max Reitz, 2015/02/27
- [Qemu-block] [PATCH v4 02/11] iotests: Make redirecting qemu's stderr optional, Max Reitz, 2015/02/27
- [Qemu-block] [PATCH v4 01/11] iotests: Move _filter_nbd into common.filter, Max Reitz, 2015/02/27
- [Qemu-block] [PATCH v4 05/11] block: Move BDS close notifiers into BB, Max Reitz, 2015/02/27
- [Qemu-block] [PATCH v4 03/11] iotests: Add test for eject under NBD server, Max Reitz, 2015/02/27
- [Qemu-block] [PATCH v4 07/11] blockdev: Use blk_remove_bs() in do_drive_del(), Max Reitz, 2015/02/27
- [Qemu-block] [PATCH v4 09/11] blockdev: Keep track of monitor-owned BDS, Max Reitz, 2015/02/27
- [Qemu-block] [PATCH v4 04/11] quorum: Fix close path, Max Reitz, 2015/02/27
- [Qemu-block] [PATCH v4 10/11] block: Eject BDS tree from BB at bdrv_close_all(),
Max Reitz <=
- [Qemu-block] [PATCH v4 06/11] block: Use blk_remove_bs() in blk_delete(), Max Reitz, 2015/02/27
- [Qemu-block] [PATCH v4 08/11] block: Make bdrv_close() static, Max Reitz, 2015/02/27
- [Qemu-block] [PATCH v4 11/11] iotests: Add test for multiple BB on BDS tree, Max Reitz, 2015/02/27