qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH V9 07/11] quorum: Add quorum_getlength().


From: Max Reitz
Subject: Re: [Qemu-devel] [PATCH V9 07/11] quorum: Add quorum_getlength().
Date: Fri, 04 Oct 2013 16:49:46 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130923 Thunderbird/17.0.9

On 2013-10-02 14:39, Benoît Canet wrote:
Check that every bs file return the same length.
*returns

If not return -EIO to disable the quorum and
I'd prefer "If not," (mind the comma) or "Otherwise," (comma optional).

Max

avoid length discrepancy.

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

diff --git a/block/quorum.c b/block/quorum.c
index e235ac1..b3649a4 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -541,12 +541,38 @@ static BlockDriverAIOCB 
*quorum_aio_writev(BlockDriverState *bs,
      return &acb->common;
  }
+static int64_t quorum_getlength(BlockDriverState *bs)
+{
+    BDRVQuorumState *s = bs->opaque;
+    int64_t result;
+    int i;
+
+    /* check that all file have the same length */
+    result = bdrv_getlength(&s->bs[0]);
+    if (result < 0) {
+        return result;
+    }
+    for (i = 1; i < s->total; i++) {
+        int64_t value = bdrv_getlength(&s->bs[i]);
+        if (value < 0) {
+            return value;
+        }
+        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_aio_readv     = quorum_aio_readv,
      .bdrv_aio_writev    = quorum_aio_writev,
  };




reply via email to

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