Received: from eggs.gnu.org ([2001:4830:134:3::10]:39035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c99Jw-0007f9-9e for qemu-devel@nongnu.org; Tue, 22 Nov 2016 06:33:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c99Jv-0002NC-1q for qemu-devel@nongnu.org; Tue, 22 Nov 2016 06:33:04 -0500 Date: Tue, 22 Nov 2016 12:32:51 +0100 From: Kevin Wolf Message-ID: <20161122113251.GB5615@noname.redhat.com> References: <1479749488-31808-1-git-send-email-kwolf@redhat.com> <1479749488-31808-4-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="NzB8fVQJ5HfG6fxh" Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH 3/8] quorum: Implement .bdrv_co_readv/writev List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-block@nongnu.org, berto@igalia.com, mreitz@redhat.com, qemu-devel@nongnu.org --NzB8fVQJ5HfG6fxh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 21.11.2016 um 18:58 hat Eric Blake geschrieben: > On 11/21/2016 11:31 AM, Kevin Wolf wrote: > > This converts the quorum block driver from implementing callback-based > > interfaces for read/write to coroutine-based ones. This is the first > > step that will allow us further simplification of the code. > >=20 > > Signed-off-by: Kevin Wolf > > --- > > block/quorum.c | 192 ++++++++++++++++++++++++++++++++++---------------= -------- > > 1 file changed, 115 insertions(+), 77 deletions(-) > >=20 >=20 > > @@ -174,14 +162,14 @@ static bool quorum_64bits_compare(QuorumVoteValue= *a, QuorumVoteValue *b) > > static QuorumAIOCB *quorum_aio_get(BlockDriverState *bs, > > QEMUIOVector *qiov, > > uint64_t sector_num, > > - int nb_sectors, > > - BlockCompletionFunc *cb, > > - void *opaque) > > + int nb_sectors) > > { > > BDRVQuorumState *s =3D bs->opaque; > > - QuorumAIOCB *acb =3D qemu_aio_get(&quorum_aiocb_info, bs, cb, opaq= ue); > > + QuorumAIOCB *acb =3D g_new(QuorumAIOCB, 1); >=20 > Worth using g_new0() here... >=20 > > int i; > > =20 > > + acb->co =3D qemu_coroutine_self(); > > + acb->bs =3D bs; > > acb->sector_num =3D sector_num; > > acb->nb_sectors =3D nb_sectors; > > acb->qiov =3D qiov; > > @@ -191,6 +179,7 @@ static QuorumAIOCB *quorum_aio_get(BlockDriverState= *bs, > > acb->rewrite_count =3D 0; > > acb->votes.compare =3D quorum_sha256_compare; > > QLIST_INIT(&acb->votes.vote_list); > > + acb->has_completed =3D false; > > acb->is_read =3D false; > > acb->vote_ret =3D 0; >=20 > ...to eliminate 0-assignments here? Not a show-stopper to leave it > as-is, though. Not in this patch anyway. I could add a cleanup patch at the end of series or as a follow-up, though. As you probably know by now, my style of writing this in new code would use a compound literal: QuorumAIOCB *acb =3D g_new(QuorumAIOCB, 1); *acb =3D (QuorumAIOCB) { ... }; > > -static BlockAIOCB *read_fifo_child(QuorumAIOCB *acb); > > +static int read_fifo_child(QuorumAIOCB *acb); > > =20 > > static void quorum_copy_qiov(QEMUIOVector *dest, QEMUIOVector *source) > > { > > @@ -272,14 +261,14 @@ static void quorum_report_bad_acb(QuorumChildRequ= est *sacb, int ret) > > QuorumAIOCB *acb =3D sacb->parent; > > QuorumOpType type =3D acb->is_read ? QUORUM_OP_TYPE_READ : QUORUM_= OP_TYPE_WRITE; > > quorum_report_bad(type, acb->sector_num, acb->nb_sectors, > > - sacb->aiocb->bs->node_name, ret); > > + sacb->bs->node_name, ret); > > } > > =20 > > -static void quorum_fifo_aio_cb(void *opaque, int ret) > > +static int quorum_fifo_aio_cb(void *opaque, int ret) > > { > > QuorumChildRequest *sacb =3D opaque; > > QuorumAIOCB *acb =3D sacb->parent; > > - BDRVQuorumState *s =3D acb->common.bs->opaque; > > + BDRVQuorumState *s =3D acb->bs->opaque; > > =20 > > assert(acb->is_read && s->read_pattern =3D=3D QUORUM_READ_PATTERN_= FIFO); > > =20 > > @@ -288,8 +277,7 @@ static void quorum_fifo_aio_cb(void *opaque, int re= t) > > =20 > > /* We try to read next child in FIFO order if we fail to read = */ > > if (acb->children_read < s->num_children) { > > - read_fifo_child(acb); > > - return; > > + return read_fifo_child(acb); > > } >=20 > Question unrelated to this patch: in FIFO mode, are we doing work > sequentially or in parallel? That is, does the quorum code kick off all > children simultaneously, then wait until the first child answers with > success (and abort all remaining children) or failure (at which point > moving to the second child may already have an answer)? Or does it only > kick of the first child, wait for a response, and not start the second > child until after the first child fails? It's the latter. This is quite easy to see in the new model (at the end of this patch series) because in FIFO mode, reads don't spawn coroutines, but just have a loop of bdrv_co_preadv() calls. > I guess one way has more > potentially wasted work (and a stress test of our ability to cancel work > on secondary children), while the other has higher latencies, so maybe > it is something that a future quorum patch may want to make configurable? Our ability to cancel work barely exists, so I'm not too sure whether the other way would really be worth implementing. > > =20 > > -static BlockAIOCB *read_fifo_child(QuorumAIOCB *acb) > > +static int read_fifo_child(QuorumAIOCB *acb) > > { > > - BDRVQuorumState *s =3D acb->common.bs->opaque; > > + BDRVQuorumState *s =3D acb->bs->opaque; > > int n =3D acb->children_read++; > > + int ret; > > =20 > > - acb->qcrs[n].aiocb =3D bdrv_aio_readv(s->children[n], acb->sector_= num, > > - acb->qiov, acb->nb_sectors, > > - quorum_fifo_aio_cb, &acb->qcrs= [n]); > > + acb->qcrs[n].bs =3D s->children[n]->bs; > > + ret =3D bdrv_co_preadv(s->children[n], acb->sector_num * BDRV_SECT= OR_SIZE, > > + acb->nb_sectors * BDRV_SECTOR_SIZE, acb->qiov= , 0); > > + ret =3D quorum_fifo_aio_cb(&acb->qcrs[n], ret); >=20 > somewhat answering myself - it looks like the current fifo approach is > high-latency rather than parallel, in that at most one child is being > run at a time. Yes, you can see it in this patch already, even if it's even clearer at the end of the series. Kevin --NzB8fVQJ5HfG6fxh Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJYNCzjAAoJEH8JsnLIjy/W0YsP/1wD9ti1LnYOBSpLWzatk91m VpyWqX9zcTZcxEXnL8qg0BgLb1i72mhiXzLiMOcNv3pAxJe7y0gqoZ+ojKL609RS +eVVF4tG/Col0YuT9R/dNVIaq5gbDwrxnEewunOsvOsjZzTxUlB4nrxEnH723BU6 awuyggYj/3Uy+8MTX+8FIHzsvaVya7b7MsXUel2Bkz5XwaFFjMI/CpIjZIMuxfLg jdg8XtuJQitBwwLlTSujBoK/n0sueV64AQP6yLkg/EeuRgzA+zd9F7kY5KjPc7go s3Iq1G1WLDro8DEeMya45KGPH3HGaMhM3XKdOzpqjt8IFytcRn9iCSD4K/OdmbT7 qdVKNYYm+RTUxUrOD6KrH6dK3fBkrvCTHejIAIbiWNEHlE88bKwcAaJYeHDFSJOx W5F6q7NNPW8tWLMNkICEFUXq+SQQdz+pkQ3s6kASVHDAlZsJdsUXsHwzLf2WwXcR mN2M0hOErS+r8T9aBXlFA2EgIVuczryLD24qF00AUdzoP/z3Yc89qm3AMfc5rgW9 S8pB7E6l58vpnNRF0y8tfxBBkynmG6GcIxPcqFRYMiXVz1ZF/2637/SpMkCvpJpt BdfHs9sn2RvELbAu+bzMgMOYBKNZRutvPcRG5KfLoh8H5dPYZIE19thYShsqzOpG f7zCVYOUrFgsSUUU17HM =eBgW -----END PGP SIGNATURE----- --NzB8fVQJ5HfG6fxh--