Patchwork [RFC,V2,04/10] quorum: Add quorum_close().

login
register
mail settings
Submitter Benoit Canet
Date Aug. 7, 2012, 1:44 p.m.
Message ID <1344347073-7773-5-git-send-email-benoit@irqsave.net>
Download mbox | patch
Permalink /patch/175633/
State New
Headers show

Comments

Benoit Canet - Aug. 7, 2012, 1:44 p.m.
Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
 block/quorum.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
Blue Swirl - Aug. 7, 2012, 8:30 p.m.
On Tue, Aug 7, 2012 at 1:44 PM, Benoît Canet <benoit.canet@gmail.com> wrote:
> Signed-off-by: Benoit Canet <benoit@irqsave.net>
> ---
>  block/quorum.c |   12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/block/quorum.c b/block/quorum.c
> index de58ab8..9da0432 100644
> --- a/block/quorum.c
> +++ b/block/quorum.c
> @@ -107,6 +107,17 @@ clean_exit:
>      return ret;
>  }
>
> +static void quorum_close(BlockDriverState *bs)
> +{
> +    BDRVQuorumState *s = bs->opaque;
> +    int i;
> +
> +    /* Ensure writes reach stable storage */
> +    for (i = 0; i <= 2; i++) {
> +        bdrv_flush(s->bs[i]);

bdrv_close()

> +    }
> +}
> +
>  static BlockDriver bdrv_quorum = {
>      .format_name        = "quorum",
>      .protocol_name      = "quorum",
> @@ -114,6 +125,7 @@ static BlockDriver bdrv_quorum = {
>      .instance_size      = sizeof(BDRVQuorumState),
>
>      .bdrv_file_open     = quorum_open,
> +    .bdrv_close         = quorum_close,
>  };
>
>  static void bdrv_quorum_init(void)
> --
> 1.7.9.5
>
Stefan Hajnoczi - Aug. 8, 2012, 3:06 p.m.
On Tue, Aug 7, 2012 at 9:30 PM, Blue Swirl <blauwirbel@gmail.com> wrote:
> On Tue, Aug 7, 2012 at 1:44 PM, Benoît Canet <benoit.canet@gmail.com> wrote:
>> +static void quorum_close(BlockDriverState *bs)
>> +{
>> +    BDRVQuorumState *s = bs->opaque;
>> +    int i;
>> +
>> +    /* Ensure writes reach stable storage */
>> +    for (i = 0; i <= 2; i++) {
>> +        bdrv_flush(s->bs[i]);
>
> bdrv_close()

bdrv_delete() instead of close since we did bdrv_new() to allocate them.

We also need to g_free() the filenames.

Patch

diff --git a/block/quorum.c b/block/quorum.c
index de58ab8..9da0432 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -107,6 +107,17 @@  clean_exit:
     return ret;
 }
 
+static void quorum_close(BlockDriverState *bs)
+{
+    BDRVQuorumState *s = bs->opaque;
+    int i;
+
+    /* Ensure writes reach stable storage */
+    for (i = 0; i <= 2; i++) {
+        bdrv_flush(s->bs[i]);
+    }
+}
+
 static BlockDriver bdrv_quorum = {
     .format_name        = "quorum",
     .protocol_name      = "quorum",
@@ -114,6 +125,7 @@  static BlockDriver bdrv_quorum = {
     .instance_size      = sizeof(BDRVQuorumState),
 
     .bdrv_file_open     = quorum_open,
+    .bdrv_close         = quorum_close,
 };
 
 static void bdrv_quorum_init(void)