[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 01/18] block: Add BdrvDeletedStatus
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH 01/18] block: Add BdrvDeletedStatus |
Date: |
Wed, 13 Sep 2017 20:18:53 +0200 |
Sometimes an operation may delete a BDS. It may then not be trivial to
determine this because the BDS object itself cannot be accessed
afterwards. With this patch, one can attach a BdrvDeletedStatus object
to a BDS which can be used to safely query whether the BDS still exists
even after it has been deleted.
Signed-off-by: Max Reitz <address@hidden>
---
include/block/block_int.h | 12 ++++++++++++
block.c | 6 ++++++
2 files changed, 18 insertions(+)
diff --git a/include/block/block_int.h b/include/block/block_int.h
index ba4c383393..eaeaad9428 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -498,6 +498,13 @@ typedef struct BdrvAioNotifier {
QLIST_ENTRY(BdrvAioNotifier) list;
} BdrvAioNotifier;
+typedef struct BdrvDeletedStatus {
+ /* Set to true by bdrv_delete() */
+ bool deleted;
+
+ QLIST_ENTRY(BdrvDeletedStatus) next;
+} BdrvDeletedStatus;
+
struct BdrvChildRole {
/* If true, bdrv_replace_node() doesn't change the node this BdrvChild
* points to. */
@@ -706,6 +713,11 @@ struct BlockDriverState {
/* Only read/written by whoever has set active_flush_req to true. */
unsigned int flushed_gen; /* Flushed write generation */
+
+ /* When bdrv_delete() is invoked, it will walk through this list
+ * and set every entry's @deleted field to true. The entries will
+ * not be freed automatically. */
+ QLIST_HEAD(, BdrvDeletedStatus) deleted_status;
};
struct BlockBackendRootState {
diff --git a/block.c b/block.c
index 6dd47e414e..0b55c5a41c 100644
--- a/block.c
+++ b/block.c
@@ -3246,10 +3246,16 @@ out:
static void bdrv_delete(BlockDriverState *bs)
{
+ BdrvDeletedStatus *del_stat;
+
assert(!bs->job);
assert(bdrv_op_blocker_is_empty(bs));
assert(!bs->refcnt);
+ QLIST_FOREACH(del_stat, &bs->deleted_status, next) {
+ del_stat->deleted = true;
+ }
+
bdrv_close(bs);
/* remove from list, if necessary */
--
2.13.5
- [Qemu-devel] [PATCH 00/18] block/mirror: Add active-sync mirroring, Max Reitz, 2017/09/13
- [Qemu-devel] [PATCH 01/18] block: Add BdrvDeletedStatus,
Max Reitz <=
- [Qemu-devel] [PATCH 02/18] block: BDS deletion during bdrv_drain_recurse, Max Reitz, 2017/09/13
- [Qemu-devel] [PATCH 03/18] blockjob: Make drained_{begin, end} public, Max Reitz, 2017/09/13
- [Qemu-devel] [PATCH 04/18] block/mirror: Pull out mirror_perform(), Max Reitz, 2017/09/13
- [Qemu-devel] [PATCH 05/18] block/mirror: Convert to coroutines, Max Reitz, 2017/09/13