diff mbox

[v2,13/25] quorum: implement .bdrv_detach/attach_aio_context()

Message ID 1399458461-3997-14-git-send-email-stefanha@redhat.com
State New
Headers show

Commit Message

Stefan Hajnoczi May 7, 2014, 10:27 a.m. UTC
Implement .bdrv_detach/attach_aio_context() interfaces to propagate
detach/attach to BDRVQuorumState->bs[] children.  The block layer takes
care of ->file and ->backing_hd but doesn't know about our ->bs[]
BlockDriverStates, which is also part of the graph.

Cc: Benoît Canet <benoit.canet@irqsave.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 block/quorum.c | 48 ++++++++++++++++++++++++++++++++++++------------
 1 file changed, 36 insertions(+), 12 deletions(-)

Comments

Benoît Canet May 7, 2014, 11:24 a.m. UTC | #1
The Wednesday 07 May 2014 à 12:27:29 (+0200), Stefan Hajnoczi wrote :
> Implement .bdrv_detach/attach_aio_context() interfaces to propagate
> detach/attach to BDRVQuorumState->bs[] children.  The block layer takes
> care of ->file and ->backing_hd but doesn't know about our ->bs[]
> BlockDriverStates, which is also part of the graph.

V1 seemed sweet and fine.
What has changed since V1 ?

Best regards

Benoît

> 
> Cc: Benoît Canet <benoit.canet@irqsave.net>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  block/quorum.c | 48 ++++++++++++++++++++++++++++++++++++------------
>  1 file changed, 36 insertions(+), 12 deletions(-)
> 
> diff --git a/block/quorum.c b/block/quorum.c
> index ecec3a5..426077a 100644
> --- a/block/quorum.c
> +++ b/block/quorum.c
> @@ -848,25 +848,49 @@ static void quorum_close(BlockDriverState *bs)
>      g_free(s->bs);
>  }
>  
> +static void quorum_detach_aio_context(BlockDriverState *bs)
> +{
> +    BDRVQuorumState *s = bs->opaque;
> +    int i;
> +
> +    for (i = 0; i < s->num_children; i++) {
> +        bdrv_detach_aio_context(s->bs[i]);
> +    }
> +}
> +
> +static void quorum_attach_aio_context(BlockDriverState *bs,
> +                                      AioContext *new_context)
> +{
> +    BDRVQuorumState *s = bs->opaque;
> +    int i;
> +
> +    for (i = 0; i < s->num_children; i++) {
> +        bdrv_attach_aio_context(s->bs[i], new_context);
> +    }
> +}
> +
>  static BlockDriver bdrv_quorum = {
> -    .format_name        = "quorum",
> -    .protocol_name      = "quorum",
> +    .format_name                        = "quorum",
> +    .protocol_name                      = "quorum",
> +
> +    .instance_size                      = sizeof(BDRVQuorumState),
>  
> -    .instance_size      = sizeof(BDRVQuorumState),
> +    .bdrv_file_open                     = quorum_open,
> +    .bdrv_close                         = quorum_close,
>  
> -    .bdrv_file_open     = quorum_open,
> -    .bdrv_close         = quorum_close,
> +    .bdrv_co_flush_to_disk              = quorum_co_flush,
>  
> -    .bdrv_co_flush_to_disk = quorum_co_flush,
> +    .bdrv_getlength                     = quorum_getlength,
>  
> -    .bdrv_getlength     = quorum_getlength,
> +    .bdrv_aio_readv                     = quorum_aio_readv,
> +    .bdrv_aio_writev                    = quorum_aio_writev,
> +    .bdrv_invalidate_cache              = quorum_invalidate_cache,
>  
> -    .bdrv_aio_readv     = quorum_aio_readv,
> -    .bdrv_aio_writev    = quorum_aio_writev,
> -    .bdrv_invalidate_cache = quorum_invalidate_cache,
> +    .bdrv_detach_aio_context            = quorum_detach_aio_context,
> +    .bdrv_attach_aio_context            = quorum_attach_aio_context,
>  
> -    .is_filter           = true,
> -    .bdrv_recurse_is_first_non_filter = quorum_recurse_is_first_non_filter,
> +    .is_filter                          = true,
> +    .bdrv_recurse_is_first_non_filter   = quorum_recurse_is_first_non_filter,
>  };
>  
>  static void bdrv_quorum_init(void)
> -- 
> 1.9.0
>
Stefan Hajnoczi May 8, 2014, 11:24 a.m. UTC | #2
On Wed, May 07, 2014 at 01:24:00PM +0200, Benoît Canet wrote:
> The Wednesday 07 May 2014 à 12:27:29 (+0200), Stefan Hajnoczi wrote :
> > Implement .bdrv_detach/attach_aio_context() interfaces to propagate
> > detach/attach to BDRVQuorumState->bs[] children.  The block layer takes
> > care of ->file and ->backing_hd but doesn't know about our ->bs[]
> > BlockDriverStates, which is also part of the graph.
> 
> V1 seemed sweet and fine.
> What has changed since V1 ?

There are no changes in this patch.  Sorry, I must have missed your
Reviewed-by:.

Stefan
diff mbox

Patch

diff --git a/block/quorum.c b/block/quorum.c
index ecec3a5..426077a 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -848,25 +848,49 @@  static void quorum_close(BlockDriverState *bs)
     g_free(s->bs);
 }
 
+static void quorum_detach_aio_context(BlockDriverState *bs)
+{
+    BDRVQuorumState *s = bs->opaque;
+    int i;
+
+    for (i = 0; i < s->num_children; i++) {
+        bdrv_detach_aio_context(s->bs[i]);
+    }
+}
+
+static void quorum_attach_aio_context(BlockDriverState *bs,
+                                      AioContext *new_context)
+{
+    BDRVQuorumState *s = bs->opaque;
+    int i;
+
+    for (i = 0; i < s->num_children; i++) {
+        bdrv_attach_aio_context(s->bs[i], new_context);
+    }
+}
+
 static BlockDriver bdrv_quorum = {
-    .format_name        = "quorum",
-    .protocol_name      = "quorum",
+    .format_name                        = "quorum",
+    .protocol_name                      = "quorum",
+
+    .instance_size                      = sizeof(BDRVQuorumState),
 
-    .instance_size      = sizeof(BDRVQuorumState),
+    .bdrv_file_open                     = quorum_open,
+    .bdrv_close                         = quorum_close,
 
-    .bdrv_file_open     = quorum_open,
-    .bdrv_close         = quorum_close,
+    .bdrv_co_flush_to_disk              = quorum_co_flush,
 
-    .bdrv_co_flush_to_disk = quorum_co_flush,
+    .bdrv_getlength                     = quorum_getlength,
 
-    .bdrv_getlength     = quorum_getlength,
+    .bdrv_aio_readv                     = quorum_aio_readv,
+    .bdrv_aio_writev                    = quorum_aio_writev,
+    .bdrv_invalidate_cache              = quorum_invalidate_cache,
 
-    .bdrv_aio_readv     = quorum_aio_readv,
-    .bdrv_aio_writev    = quorum_aio_writev,
-    .bdrv_invalidate_cache = quorum_invalidate_cache,
+    .bdrv_detach_aio_context            = quorum_detach_aio_context,
+    .bdrv_attach_aio_context            = quorum_attach_aio_context,
 
-    .is_filter           = true,
-    .bdrv_recurse_is_first_non_filter = quorum_recurse_is_first_non_filter,
+    .is_filter                          = true,
+    .bdrv_recurse_is_first_non_filter   = quorum_recurse_is_first_non_filter,
 };
 
 static void bdrv_quorum_init(void)