diff options
author | BenoƮt Canet <benoit@irqsave.net> | 2014-02-21 22:21:18 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2014-02-21 22:29:51 +0100 |
commit | 1c508d174d4b9dfd066c3729a2560afeef5e081f (patch) | |
tree | a271590b33522812a961e9baf6ea9705fe23178d /block | |
parent | a28e4c408b28e4d55c5bd327a19290e1da3855dd (diff) | |
download | qemu-1c508d174d4b9dfd066c3729a2560afeef5e081f.zip qemu-1c508d174d4b9dfd066c3729a2560afeef5e081f.tar.gz qemu-1c508d174d4b9dfd066c3729a2560afeef5e081f.tar.bz2 |
quorum: Add quorum_co_flush().
Makes a vote to select error if any.
Signed-off-by: Benoit Canet <benoit@irqsave.net>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/quorum.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/block/quorum.c b/block/quorum.c index 38bc217..840afda 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -629,12 +629,40 @@ static void quorum_invalidate_cache(BlockDriverState *bs) } } +static coroutine_fn int quorum_co_flush(BlockDriverState *bs) +{ + BDRVQuorumState *s = bs->opaque; + QuorumVoteVersion *winner = NULL; + QuorumVotes error_votes; + QuorumVoteValue result_value; + int i; + int result = 0; + + QLIST_INIT(&error_votes.vote_list); + error_votes.compare = quorum_64bits_compare; + + for (i = 0; i < s->num_children; i++) { + result = bdrv_co_flush(s->bs[i]); + result_value.l = result; + quorum_count_vote(&error_votes, &result_value, i); + } + + winner = quorum_get_vote_winner(&error_votes); + result = winner->value.l; + + quorum_free_vote_list(&error_votes); + + return result; +} + static BlockDriver bdrv_quorum = { .format_name = "quorum", .protocol_name = "quorum", .instance_size = sizeof(BDRVQuorumState), + .bdrv_co_flush_to_disk = quorum_co_flush, + .bdrv_getlength = quorum_getlength, .bdrv_aio_readv = quorum_aio_readv, |