Received: from eggs.gnu.org ([2001:4830:134:3::10]:42377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c8sro-0004fO-Dd for qemu-devel@nongnu.org; Mon, 21 Nov 2016 12:58:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c8srn-0003g5-5H for qemu-devel@nongnu.org; Mon, 21 Nov 2016 12:58:56 -0500 References: <1479749488-31808-1-git-send-email-kwolf@redhat.com> <1479749488-31808-4-git-send-email-kwolf@redhat.com> From: Eric Blake Message-ID: Date: Mon, 21 Nov 2016 11:58:46 -0600 MIME-Version: 1.0 In-Reply-To: <1479749488-31808-4-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="0JV3rAVNxt0sRfBjdC9Dk5J6ItRRP9n40" 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: Kevin Wolf , qemu-block@nongnu.org Cc: berto@igalia.com, mreitz@redhat.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --0JV3rAVNxt0sRfBjdC9Dk5J6ItRRP9n40 From: Eric Blake To: Kevin Wolf , qemu-block@nongnu.org Cc: berto@igalia.com, mreitz@redhat.com, qemu-devel@nongnu.org Message-ID: Subject: Re: [PATCH 3/8] quorum: Implement .bdrv_co_readv/writev References: <1479749488-31808-1-git-send-email-kwolf@redhat.com> <1479749488-31808-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1479749488-31808-4-git-send-email-kwolf@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 > @@ -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); Worth using g_new0() here... > 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; =2E..to eliminate 0-assignments here? Not a show-stopper to leave it as-is, though. > -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); > } 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? 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?= > =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); 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. The conversion itself looks sane; Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --0JV3rAVNxt0sRfBjdC9Dk5J6ItRRP9n40 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJYMzXWAAoJEKeha0olJ0NqJAIH/RfD+CvzBHg0ujaUBP8YvI3X wVRqt9Lcy/FJtwQa5fzRB7IzoX22vBrXmPWm5e0T9v8MMtZY5PDuYVcjc+yUR32v ouWLohkZAJQ8hAGF0206ntpGWtcz/6kkPRqaJ/qZ9vk6vhHp4Kpg4sqK3Lia+GzM 8exNjX5UTQASAP/fgSPpVI3RF2xfhFA+LNhlzDXsjqDUXDGIf+I5UQiNtftyC1oL gfusANIK+Bq0Zav1p7B8EoD9+kRBCVqso4rtXdVhv4Q3RKIV7Wj5KNObC9s+/605 X8ueKMR+31v02KZfn59AkEYul0meRgsiPF7NPhcdbSpbyFiOO8xwzVmAl0TwnZ4= =enJi -----END PGP SIGNATURE----- --0JV3rAVNxt0sRfBjdC9Dk5J6ItRRP9n40--