Skip to content

Commit

Permalink
quorum: Add quorum_co_flush().
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
benoit-canet authored and kevmw committed Feb 21, 2014
1 parent a28e4c4 commit 1c508d1
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions block/quorum.c
Expand Up @@ -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,
Expand Down

0 comments on commit 1c508d1

Please sign in to comment.