Patchwork [RFC,V3,7/9] quorum: Add quorum_co_flush().

login
register
mail settings
Submitter Benoit Canet
Date Aug. 14, 2012, 2:14 p.m.
Message ID <1344953651-16622-8-git-send-email-benoit@irqsave.net>
Download mbox | patch
Permalink /patch/177300/
State New
Headers show

Comments

Benoit Canet - Aug. 14, 2012, 2:14 p.m.
Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 block/quorum.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
Blue Swirl - Aug. 14, 2012, 6:52 p.m.
On Tue, Aug 14, 2012 at 2:14 PM, BenoƮt Canet <benoit.canet@gmail.com> wrote:
> Signed-off-by: Benoit Canet <benoit@irqsave.net>
> ---
>  block/quorum.c |   16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
>
> diff --git a/block/quorum.c b/block/quorum.c
> index 0a6647f..86962b4 100644
> --- a/block/quorum.c
> +++ b/block/quorum.c
> @@ -279,6 +279,21 @@ static BlockDriverAIOCB *quorum_aio_writev(BlockDriverState *bs,
>      return &acb->common;
>  }
>
> +static coroutine_fn int quorum_co_flush(BlockDriverState *bs)
> +{
> +    BDRVQuorumState *s = bs->opaque;
> +    int i, ret = 0;
> +
> +    for (i = 0; i < s->m; i++) {
> +        ret = bdrv_co_flush(s->bs[i]);
> +        if (ret < 0) {
> +            return ret;

This stops flushing if any of the replicates fail. Shouldn't we just
ignore error?

> +        }
> +    }
> +
> +    return ret;
> +}
> +
>  static BlockDriver bdrv_quorum = {
>      .format_name        = "quorum",
>      .protocol_name      = "quorum",
> @@ -289,6 +304,7 @@ static BlockDriver bdrv_quorum = {
>
>      .bdrv_file_open     = quorum_open,
>      .bdrv_close         = quorum_close,
> +    .bdrv_co_flush_to_disk = quorum_co_flush,
>
>      .bdrv_aio_writev    = quorum_aio_writev,
>  };
> --
> 1.7.9.5
>

Patch

diff --git a/block/quorum.c b/block/quorum.c
index 0a6647f..86962b4 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -279,6 +279,21 @@  static BlockDriverAIOCB *quorum_aio_writev(BlockDriverState *bs,
     return &acb->common;
 }
 
+static coroutine_fn int quorum_co_flush(BlockDriverState *bs)
+{
+    BDRVQuorumState *s = bs->opaque;
+    int i, ret = 0;
+
+    for (i = 0; i < s->m; i++) {
+        ret = bdrv_co_flush(s->bs[i]);
+        if (ret < 0) {
+            return ret;
+        }
+    }
+
+    return ret;
+}
+
 static BlockDriver bdrv_quorum = {
     .format_name        = "quorum",
     .protocol_name      = "quorum",
@@ -289,6 +304,7 @@  static BlockDriver bdrv_quorum = {
 
     .bdrv_file_open     = quorum_open,
     .bdrv_close         = quorum_close,
+    .bdrv_co_flush_to_disk = quorum_co_flush,
 
     .bdrv_aio_writev    = quorum_aio_writev,
 };