diff mbox series

[RFC,v2,16/25] block/backup-top.h: global state API + assertions

Message ID 20211005143215.29500-17-eesposit@redhat.com
State New
Headers show
Series block layer: split block APIs in global state and I/O | expand

Commit Message

Emanuele Giuseppe Esposito Oct. 5, 2021, 2:32 p.m. UTC
backup-top functions always run under BQL lock.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
 block/backup-top.c |  2 ++
 block/backup-top.h | 11 +++++++++++
 2 files changed, 13 insertions(+)

Comments

Paolo Bonzini Oct. 7, 2021, 12:08 p.m. UTC | #1
On 05/10/21 16:32, Emanuele Giuseppe Esposito wrote:
> backup-top functions always run under BQL lock.
> 
> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
> ---
>   block/backup-top.c |  2 ++
>   block/backup-top.h | 11 +++++++++++
>   2 files changed, 13 insertions(+)
> 
> diff --git a/block/backup-top.c b/block/backup-top.c
> index 425e3778be..8b58a909f7 100644
> --- a/block/backup-top.c
> +++ b/block/backup-top.c
> @@ -182,6 +182,7 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source,
>       bool appended = false;
>   
>       assert(source->total_sectors == target->total_sectors);
> +    g_assert(qemu_in_main_thread());
>   
>       top = bdrv_new_open_driver(&bdrv_backup_top_filter, filter_node_name,
>                                  BDRV_O_RDWR, errp);
> @@ -244,6 +245,7 @@ fail:
>   void bdrv_backup_top_drop(BlockDriverState *bs)
>   {
>       BDRVBackupTopState *s = bs->opaque;
> +    g_assert(qemu_in_main_thread());
>   
>       bdrv_drop_filter(bs, &error_abort);
>   
> diff --git a/block/backup-top.h b/block/backup-top.h
> index b28b0031c4..8cb6f62869 100644
> --- a/block/backup-top.h
> +++ b/block/backup-top.h
> @@ -29,6 +29,17 @@
>   #include "block/block_int.h"
>   #include "block/block-copy.h"
>   
> +/*
> + * Graph API. These functions run under the BQL lock.
> + *
> + * If a function modifies the graph, it uses drain and/or
> + * aio_context_acquire/release to be sure it has unique access.
> + *
> + * All functions in this header must use this assertion:
> + * g_assert(qemu_in_main_thread());
> + * to be sure they belong here.
> + */
> +
>   BlockDriverState *bdrv_backup_top_append(BlockDriverState *source,
>                                            BlockDriverState *target,
>                                            const char *filter_node_name,
> 

This is now bdrv_cbw_append, but anyway:

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Stefan Hajnoczi Oct. 7, 2021, 2:32 p.m. UTC | #2
On Tue, Oct 05, 2021 at 10:32:06AM -0400, Emanuele Giuseppe Esposito wrote:
> backup-top functions always run under BQL lock.
> 
> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
> ---
>  block/backup-top.c |  2 ++
>  block/backup-top.h | 11 +++++++++++
>  2 files changed, 13 insertions(+)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
diff mbox series

Patch

diff --git a/block/backup-top.c b/block/backup-top.c
index 425e3778be..8b58a909f7 100644
--- a/block/backup-top.c
+++ b/block/backup-top.c
@@ -182,6 +182,7 @@  BlockDriverState *bdrv_backup_top_append(BlockDriverState *source,
     bool appended = false;
 
     assert(source->total_sectors == target->total_sectors);
+    g_assert(qemu_in_main_thread());
 
     top = bdrv_new_open_driver(&bdrv_backup_top_filter, filter_node_name,
                                BDRV_O_RDWR, errp);
@@ -244,6 +245,7 @@  fail:
 void bdrv_backup_top_drop(BlockDriverState *bs)
 {
     BDRVBackupTopState *s = bs->opaque;
+    g_assert(qemu_in_main_thread());
 
     bdrv_drop_filter(bs, &error_abort);
 
diff --git a/block/backup-top.h b/block/backup-top.h
index b28b0031c4..8cb6f62869 100644
--- a/block/backup-top.h
+++ b/block/backup-top.h
@@ -29,6 +29,17 @@ 
 #include "block/block_int.h"
 #include "block/block-copy.h"
 
+/*
+ * Graph API. These functions run under the BQL lock.
+ *
+ * If a function modifies the graph, it uses drain and/or
+ * aio_context_acquire/release to be sure it has unique access.
+ *
+ * All functions in this header must use this assertion:
+ * g_assert(qemu_in_main_thread());
+ * to be sure they belong here.
+ */
+
 BlockDriverState *bdrv_backup_top_append(BlockDriverState *source,
                                          BlockDriverState *target,
                                          const char *filter_node_name,