qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 30/40] quorum: split quorum_fifo_aio_cb from quorum_


From: Paolo Bonzini
Subject: [Qemu-devel] [PATCH 30/40] quorum: split quorum_fifo_aio_cb from quorum_aio_cb
Date: Tue, 24 Nov 2015 19:01:21 +0100

The two cases of quorum_aio_cb are called from different paths, clarify
that with an assertion.  Also note that the FIFO read pattern is not
doing rewrites.

Signed-off-by: Paolo Bonzini <address@hidden>
---
 block/quorum.c | 37 +++++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/block/quorum.c b/block/quorum.c
index 3b19c9e..d7a0f11 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -271,28 +271,37 @@ static void quorum_copy_qiov(QEMUIOVector *dest, 
QEMUIOVector *source)
     }
 }
 
-static void quorum_aio_cb(void *opaque, int ret)
+static void quorum_fifo_aio_cb(void *opaque, int ret)
 {
     QuorumChildRequest *sacb = opaque;
     QuorumAIOCB *acb = sacb->parent;
     BDRVQuorumState *s = acb->common.bs->opaque;
-    bool rewrite = false;
 
-    if (acb->is_read && s->read_pattern == QUORUM_READ_PATTERN_FIFO) {
-        /* We try to read next child in FIFO order if we fail to read */
-        if (ret < 0 && ++acb->child_iter < s->num_children) {
-            read_fifo_child(acb);
-            return;
-        }
+    assert(acb->is_read && s->read_pattern == QUORUM_READ_PATTERN_FIFO);
 
-        if (ret == 0) {
-            quorum_copy_qiov(acb->qiov, &acb->qcrs[acb->child_iter].qiov);
-        }
-        acb->vote_ret = ret;
-        quorum_aio_finalize(acb);
+    /* We try to read next child in FIFO order if we fail to read */
+    if (ret < 0 && ++acb->child_iter < s->num_children) {
+        read_fifo_child(acb);
         return;
     }
 
+    if (ret == 0) {
+        quorum_copy_qiov(acb->qiov, &acb->qcrs[acb->child_iter].qiov);
+    }
+    acb->vote_ret = ret;
+
+    /* FIXME: rewrite failed children if acb->child_iter > 0? */
+
+    quorum_aio_finalize(acb);
+}
+
+static void quorum_aio_cb(void *opaque, int ret)
+{
+    QuorumChildRequest *sacb = opaque;
+    QuorumAIOCB *acb = sacb->parent;
+    BDRVQuorumState *s = acb->common.bs->opaque;
+    bool rewrite = false;
+
     sacb->ret = ret;
     acb->count++;
     if (ret == 0) {
@@ -659,7 +668,7 @@ static BlockAIOCB *read_fifo_child(QuorumAIOCB *acb)
                      acb->qcrs[acb->child_iter].buf);
     bdrv_aio_readv(s->children[acb->child_iter]->bs, acb->sector_num,
                    &acb->qcrs[acb->child_iter].qiov, acb->nb_sectors,
-                   quorum_aio_cb, &acb->qcrs[acb->child_iter]);
+                   quorum_fifo_aio_cb, &acb->qcrs[acb->child_iter]);
 
     return &acb->common;
 }
-- 
1.8.3.1





reply via email to

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