From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WB5L2-0003OO-BV for qemu-devel@nongnu.org; Wed, 05 Feb 2014 11:28:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WB5Ku-0000jt-04 for qemu-devel@nongnu.org; Wed, 05 Feb 2014 11:28:36 -0500 Received: from paradis.irqsave.net ([62.212.105.220]:49237) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WB5Kt-0000jh-GM for qemu-devel@nongnu.org; Wed, 05 Feb 2014 11:28:27 -0500 Date: Wed, 5 Feb 2014 17:28:26 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140205162826.GB26199@irqsave.net> References: <1391464280-25627-1-git-send-email-benoit.canet@irqsave.net> <1391464280-25627-10-git-send-email-benoit.canet@irqsave.net> <20140204154922.GN3384@dhcp-200-207.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20140204154922.GN3384@dhcp-200-207.str.redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH V15 09/13] quorum: Add quorum_co_get_block_status. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: =?iso-8859-1?Q?Beno=EEt?= Canet , qemu-devel@nongnu.org, stefanha@redhat.com, mreitz@redhat.com Le Tuesday 04 Feb 2014 =E0 16:49:22 (+0100), Kevin Wolf a =E9crit : > Am 03.02.2014 um 22:51 hat Beno=EEt Canet geschrieben: > > From: Beno=EEt Canet > >=20 > > Signed-off-by: Benoit Canet > > Reviewed-by: Max Reitz > > --- > > block/quorum.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++= +++ > > 1 file changed, 51 insertions(+) > >=20 > > 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(BlockDriverS= tate *bs) > > } > > } > > =20 > > +static int64_t coroutine_fn quorum_co_get_block_status(BlockDriverSt= ate *bs, > > + int64_t secto= r_num, > > + int nb_sector= s, > > + int *pnum) > > +{ > > + BDRVQuorumState *s =3D bs->opaque; > > + QuorumVoteVersion *winner =3D NULL; > > + QuorumVotes result_votes, num_votes; > > + QuorumVoteValue result_value, num_value; > > + int i, num; > > + int64_t result =3D 0; > > + > > + QLIST_INIT(&result_votes.vote_list); > > + QLIST_INIT(&num_votes.vote_list); > > + result_votes.compare =3D quorum_64bits_compare; > > + num_votes.compare =3D quorum_64bits_compare; > > + > > + for (i =3D 0; i < s->total; i++) { > > + result =3D bdrv_get_block_status(s->bs[i], sector_num, nb_se= ctors, &num); > > + /* skip failed requests */ > > + if (result < 0) { > > + continue; > > + } > > + result_value.l =3D result & BDRV_BLOCK_DATA; > > + num_value.l =3D num; > > + quorum_count_vote(&result_votes, &result_value, i); > > + quorum_count_vote(&num_votes, &num_value, i); > > + } >=20 > 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 i= t > 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 ?=20 Best regards Beno=EEt >=20 > > + winner =3D quorum_get_vote_winner(&result_votes); > > + if (winner->vote_count < s->threshold) { > > + result =3D -EIO; > > + goto free_exit; > > + } > > + result =3D winner->value.l; > > + > > + winner =3D quorum_get_vote_winner(&num_votes); > > + if (winner->vote_count < s->threshold) { > > + result =3D -EIO; > > + goto free_exit; > > + } > > + *pnum =3D winner->value.l; >=20 > You can take the status from one group of devices and the number of > blocks that share this state from another group?! >=20 > > + > > +free_exit: > > + quorum_free_vote_list(&result_votes); > > + quorum_free_vote_list(&num_votes); > > + > > + return result; > > +} > > + > > static BlockDriver bdrv_quorum =3D { > > .format_name =3D "quorum", > > .protocol_name =3D "quorum", > > @@ -630,6 +680,7 @@ static BlockDriver bdrv_quorum =3D { > > .bdrv_aio_readv =3D quorum_aio_readv, > > .bdrv_aio_writev =3D quorum_aio_writev, > > .bdrv_invalidate_cache =3D quorum_invalidate_cache, > > + .bdrv_co_get_block_status =3D quorum_co_get_block_status, > > }; > > =20 > > static void bdrv_quorum_init(void) >=20 > Kevin