[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL v2 28/50] block: Add blk_remove_all_bs()
From: |
Max Reitz |
Subject: |
[Qemu-block] [PULL v2 28/50] block: Add blk_remove_all_bs() |
Date: |
Tue, 2 Feb 2016 18:35:21 +0100 |
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);
--
2.7.0
- [Qemu-block] [PULL v2 19/50] virtio-blk: Functions for op blocker management, (continued)
- [Qemu-block] [PULL v2 19/50] virtio-blk: Functions for op blocker management, Max Reitz, 2016/02/02
- [Qemu-block] [PULL v2 20/50] virtio-scsi: Catch BDS-BB removal/insertion, Max Reitz, 2016/02/02
- [Qemu-block] [PULL v2 21/50] nbd: Switch from close to eject notifier, Max Reitz, 2016/02/02
- [Qemu-block] [PULL v2 22/50] block: Remove BDS close notifier, Max Reitz, 2016/02/02
- [Qemu-block] [PULL v2 24/50] blockdev: Use blk_remove_bs() in do_drive_del(), Max Reitz, 2016/02/02
- [Qemu-block] [PULL v2 23/50] block: Use blk_remove_bs() in blk_delete(), Max Reitz, 2016/02/02
- [Qemu-block] [PULL v2 26/50] block: Add list of all BlockDriverStates, Max Reitz, 2016/02/02
- [Qemu-block] [PULL v2 27/50] blockdev: Keep track of monitor-owned BDS, Max Reitz, 2016/02/02
- [Qemu-block] [PULL v2 25/50] block: Make bdrv_close() static, Max Reitz, 2016/02/02
- [Qemu-block] [PULL v2 29/50] block: Rewrite bdrv_close_all(), Max Reitz, 2016/02/02
- [Qemu-block] [PULL v2 28/50] block: Add blk_remove_all_bs(),
Max Reitz <=
- [Qemu-block] [PULL v2 30/50] iotests: Add test for multiple BB on BDS tree, Max Reitz, 2016/02/02
- [Qemu-block] [PULL v2 31/50] iotests: Add test for block jobs and BDS ejection, Max Reitz, 2016/02/02
- [Qemu-block] [PULL v2 32/50] block: acquire in bdrv_query_image_info, Max Reitz, 2016/02/02
- [Qemu-block] [PULL v2 34/50] qcow: Assign bs->file->bs to file in qcow_co_get_block_status, Max Reitz, 2016/02/02
- [Qemu-block] [PULL v2 33/50] block: Add "file" output parameter to block status query functions, Max Reitz, 2016/02/02
- [Qemu-block] [PULL v2 35/50] qcow2: Assign bs->file->bs to file in qcow2_co_get_block_status, Max Reitz, 2016/02/02
- [Qemu-block] [PULL v2 36/50] raw: Assign bs to file in raw_co_get_block_status, Max Reitz, 2016/02/02
- [Qemu-block] [PULL v2 38/50] parallels: Assign bs->file->bs to file in parallels_co_get_block_status, Max Reitz, 2016/02/02
- [Qemu-block] [PULL v2 37/50] iscsi: Assign bs to file in iscsi_co_get_block_status, Max Reitz, 2016/02/02
- [Qemu-block] [PULL v2 39/50] qed: Assign bs->file->bs to file in bdrv_qed_co_get_block_status, Max Reitz, 2016/02/02