From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAkeR-000451-LZ for qemu-devel@nongnu.org; Tue, 04 Feb 2014 13:23:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WAkeM-0003NY-I2 for qemu-devel@nongnu.org; Tue, 04 Feb 2014 13:23:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:63933) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WAiFY-0000lt-1A for qemu-devel@nongnu.org; Tue, 04 Feb 2014 10:49:24 -0500 Date: Tue, 4 Feb 2014 16:49:22 +0100 From: Kevin Wolf Message-ID: <20140204154922.GN3384@dhcp-200-207.str.redhat.com> References: <1391464280-25627-1-git-send-email-benoit.canet@irqsave.net> <1391464280-25627-10-git-send-email-benoit.canet@irqsave.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1391464280-25627-10-git-send-email-benoit.canet@irqsave.net> 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: =?iso-8859-1?Q?Beno=EEt?= Canet Cc: =?iso-8859-1?Q?Beno=EEt?= Canet , qemu-devel@nongnu.org, stefanha@redhat.com, mreitz@redhat.com 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(BlockDriverSta= te *bs) > } > } > =20 > +static int64_t coroutine_fn quorum_co_get_block_status(BlockDriverStat= e *bs, > + int64_t sector_= num, > + int nb_sectors, > + 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_sect= ors, &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); > + } 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. > + 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; 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 =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) Kevin