diff mbox

[08/50] block/quorum: Implement bdrv_is_inserted()

Message ID 1422288204-29271-9-git-send-email-mreitz@redhat.com
State New
Headers show

Commit Message

Max Reitz Jan. 26, 2015, 4:02 p.m. UTC
bdrv_is_inserted() should be invoked recursively on the children of
quorum.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/quorum.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Eric Blake Jan. 27, 2015, 7:20 p.m. UTC | #1
On 01/26/2015 09:02 AM, Max Reitz wrote:
> bdrv_is_inserted() should be invoked recursively on the children of
> quorum.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  block/quorum.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/block/quorum.c b/block/quorum.c
> index 437b122..7811c4a 100644
> --- a/block/quorum.c
> +++ b/block/quorum.c
> @@ -1064,6 +1064,20 @@ static void quorum_refresh_filename(BlockDriverState *bs)
>      bs->full_open_options = opts;
>  }
>  
> +static int quorum_is_inserted(BlockDriverState *bs)
> +{
> +    BDRVQuorumState *s = bs->opaque;
> +    int i;
> +
> +    for (i = 0; i < s->num_children; i++) {
> +        if (!bdrv_is_inserted(s->bs[i])) {
> +            return 0;

If you convert the callback to return bool, this may need minor tweaks.
 But they don't affect correctness;

Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox

Patch

diff --git a/block/quorum.c b/block/quorum.c
index 437b122..7811c4a 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -1064,6 +1064,20 @@  static void quorum_refresh_filename(BlockDriverState *bs)
     bs->full_open_options = opts;
 }
 
+static int quorum_is_inserted(BlockDriverState *bs)
+{
+    BDRVQuorumState *s = bs->opaque;
+    int i;
+
+    for (i = 0; i < s->num_children; i++) {
+        if (!bdrv_is_inserted(s->bs[i])) {
+            return 0;
+        }
+    }
+
+    return 1;
+}
+
 static BlockDriver bdrv_quorum = {
     .format_name                        = "quorum",
     .protocol_name                      = "quorum",
@@ -1087,6 +1101,8 @@  static BlockDriver bdrv_quorum = {
 
     .is_filter                          = true,
     .bdrv_recurse_is_first_non_filter   = quorum_recurse_is_first_non_filter,
+
+    .bdrv_is_inserted                   = quorum_is_inserted,
 };
 
 static void bdrv_quorum_init(void)