Le Tuesday 04 Feb 2014 à 16:49:22 (+0100), Kevin Wolf a écrit : > Am 03.02.2014 um 22:51 hat Benoît Canet geschrieben: > > From: Benoît Canet <ben...@irqsave.net> > > > > Signed-off-by: Benoit Canet <ben...@irqsave.net> > > Reviewed-by: Max Reitz <mre...@redhat.com> > > --- > > block/quorum.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 51 insertions(+) > > > > diff --git a/block/quorum.c b/block/quorum.c > > index cef4424..677a96d 100644 > > --- a/block/quorum.c > > +++ b/block/quorum.c > > @@ -619,6 +619,56 @@ static void quorum_invalidate_cache(BlockDriverState > > *bs) > > } > > } > > > > +static int64_t coroutine_fn quorum_co_get_block_status(BlockDriverState > > *bs, > > + int64_t sector_num, > > + int nb_sectors, > > + int *pnum) > > +{ > > + BDRVQuorumState *s = bs->opaque; > > + QuorumVoteVersion *winner = NULL; > > + QuorumVotes result_votes, num_votes; > > + QuorumVoteValue result_value, num_value; > > + int i, num; > > + int64_t result = 0; > > + > > + QLIST_INIT(&result_votes.vote_list); > > + QLIST_INIT(&num_votes.vote_list); > > + result_votes.compare = quorum_64bits_compare; > > + num_votes.compare = quorum_64bits_compare; > > + > > + for (i = 0; i < s->total; i++) { > > + result = bdrv_get_block_status(s->bs[i], sector_num, nb_sectors, > > &num); > > + /* skip failed requests */ > > + if (result < 0) { > > + continue; > > + } > > + result_value.l = result & BDRV_BLOCK_DATA; > > + num_value.l = num; > > + quorum_count_vote(&result_votes, &result_value, i); > > + quorum_count_vote(&num_votes, &num_value, i); > > + } > > This doesn't work. bdrv_get_block_status() doesn't guarantee that it > returns all consecutive blocks with the same status. You need to call it > in a loop here, or change bdrv_get_block_status() so that it loops > itself.
I don't see what can be done with the results generated by the loop. Does quorum really need this function ? Best regards Benoît > > > + winner = quorum_get_vote_winner(&result_votes); > > + if (winner->vote_count < s->threshold) { > > + result = -EIO; > > + goto free_exit; > > + } > > + result = winner->value.l; > > + > > + winner = quorum_get_vote_winner(&num_votes); > > + if (winner->vote_count < s->threshold) { > > + result = -EIO; > > + goto free_exit; > > + } > > + *pnum = winner->value.l; > > You can take the status from one group of devices and the number of > blocks that share this state from another group?! > > > + > > +free_exit: > > + quorum_free_vote_list(&result_votes); > > + quorum_free_vote_list(&num_votes); > > + > > + return result; > > +} > > + > > static BlockDriver bdrv_quorum = { > > .format_name = "quorum", > > .protocol_name = "quorum", > > @@ -630,6 +680,7 @@ static BlockDriver bdrv_quorum = { > > .bdrv_aio_readv = quorum_aio_readv, > > .bdrv_aio_writev = quorum_aio_writev, > > .bdrv_invalidate_cache = quorum_invalidate_cache, > > + .bdrv_co_get_block_status = quorum_co_get_block_status, > > }; > > > > static void bdrv_quorum_init(void) > > Kevin