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 <pbonz...@redhat.com> --- block/quorum.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/block/quorum.c b/block/quorum.c index 0a42962..026528e 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) { @@ -658,7 +667,7 @@ static BlockAIOCB *read_fifo_child(QuorumAIOCB *acb) acb->qcrs[acb->child_iter].buf); bdrv_aio_readv(s->bs[acb->child_iter], 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; } -- 2.4.3