qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 09/11] quorum: Add quorum_getlength().


From: Benoît Canet
Subject: [Qemu-devel] [PATCH 09/11] quorum: Add quorum_getlength().
Date: Tue, 23 Oct 2012 14:23:47 +0200

Check that every bs file return the same length.
If not return -EIO to disable the quorum and
avoid length discrepancy.

Signed-off-by: Benoit Canet <address@hidden>
---
 block/quorum.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/block/quorum.c b/block/quorum.c
index 6d76c49..a01f712 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -604,12 +604,32 @@ static coroutine_fn int quorum_co_flush(BlockDriverState 
*bs)
     return 0;
 }
 
+static int64_t quorum_getlength(BlockDriverState *bs)
+{
+    BDRVQuorumState *s = bs->opaque;
+    int64_t result;
+    int i;
+
+    /* check that every file have the same length */
+    result = bdrv_getlength(s->bs[0]);
+    for (i = 1; i < s->total; i++) {
+        int64_t value = bdrv_getlength(s->bs[i]);
+        if (value != result) {
+            return -EIO;
+        }
+    }
+
+    return result;
+}
+
 static BlockDriver bdrv_quorum = {
     .format_name        = "quorum",
     .protocol_name      = "quorum",
 
     .instance_size      = sizeof(BDRVQuorumState),
 
+    .bdrv_getlength     = quorum_getlength,
+
     .bdrv_file_open     = quorum_open,
     .bdrv_close         = quorum_close,
     .bdrv_co_flush_to_disk = quorum_co_flush,
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]