[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 06/14] block: bdrv_delete(): drop unnecessary zeroing
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH 06/14] block: bdrv_delete(): drop unnecessary zeroing |
Date: |
Mon, 7 Feb 2022 17:37:20 +0100 |
No need to zero all these things before g_free(bs). Move memory freeing
to the end of the function to simplify further conversion to
transaction action.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
block.c | 40 ++++++++++++++--------------------------
1 file changed, 14 insertions(+), 26 deletions(-)
diff --git a/block.c b/block.c
index 71a5aec24c..231d1fc3ea 100644
--- a/block.c
+++ b/block.c
@@ -4815,32 +4815,6 @@ static void bdrv_delete(BlockDriverState *bs)
bdrv_unref_child(bs, child);
}
- assert(!bs->backing);
- assert(!bs->file);
- g_free(bs->opaque);
- bs->opaque = NULL;
- qatomic_set(&bs->copy_on_read, 0);
- bs->backing_file[0] = '\0';
- bs->backing_format[0] = '\0';
- bs->total_sectors = 0;
- bs->encrypted = false;
- bs->sg = false;
- qobject_unref(bs->options);
- qobject_unref(bs->explicit_options);
- bs->options = NULL;
- bs->explicit_options = NULL;
- qobject_unref(bs->full_open_options);
- bs->full_open_options = NULL;
- g_free(bs->block_status_cache);
- bs->block_status_cache = NULL;
-
- bdrv_release_named_dirty_bitmaps(bs);
- assert(QLIST_EMPTY(&bs->dirty_bitmaps));
-
- QLIST_FOREACH_SAFE(ban, &bs->aio_notifiers, list, ban_next) {
- g_free(ban);
- }
- QLIST_INIT(&bs->aio_notifiers);
bdrv_drained_end(bs);
/*
@@ -4852,6 +4826,20 @@ static void bdrv_delete(BlockDriverState *bs)
bdrv_drain_all_end_quiesce(bs);
}
+ /* Free memory */
+ g_free(bs->opaque);
+ qobject_unref(bs->options);
+ qobject_unref(bs->explicit_options);
+ qobject_unref(bs->full_open_options);
+ g_free(bs->block_status_cache);
+
+ bdrv_release_named_dirty_bitmaps(bs);
+ assert(QLIST_EMPTY(&bs->dirty_bitmaps));
+
+ QLIST_FOREACH_SAFE(ban, &bs->aio_notifiers, list, ban_next) {
+ g_free(ban);
+ }
+
g_free(bs);
}
--
2.31.1
- [PATCH 00/14] block: blockdev-del force=false, Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 02/14] block: drop bdrv_detach_child(), Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 01/14] block: refactor bdrv_remove_file_or_backing_child to bdrv_remove_child, Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 04/14] block: add bdrv_try_set_aio_context_tran transaction action, Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 10/14] qcow2: qcow2_inactivate(): don't call qcow2_mark_clean() when RO, Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 14/14] iotests: add test for blockdev-del(force=false), Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 06/14] block: bdrv_delete(): drop unnecessary zeroing,
Vladimir Sementsov-Ogievskiy <=
- [PATCH 08/14] qapi/block-core: add 'force' argument to blockdev-del, Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 03/14] block: bdrv_refresh_perms(): allow external tran, Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 05/14] block: merge bdrv_delete and bdrv_close, Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 12/14] qcow2: implement .bdrv_close_safe, Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 13/14] block/file-posix: implement .bdrv_close_safe, Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 09/14] qcow2: qcow2_inactivate(): use qcow2_flush_caches(), Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 07/14] block: implemet bdrv_try_unref(), Vladimir Sementsov-Ogievskiy, 2022/02/07
- [PATCH 11/14] qcow2: refactor qcow2_inactivate, Vladimir Sementsov-Ogievskiy, 2022/02/07