Received: from eggs.gnu.org ([2001:4830:134:3::10]:44181) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c8upB-00054x-Kr for qemu-devel@nongnu.org; Mon, 21 Nov 2016 15:04:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c8upA-0000pd-8y for qemu-devel@nongnu.org; Mon, 21 Nov 2016 15:04:21 -0500 References: <1479749488-31808-1-git-send-email-kwolf@redhat.com> <1479749488-31808-8-git-send-email-kwolf@redhat.com> From: Eric Blake Message-ID: <122bc834-8ab3-ce9d-2b22-8459afe6feee@redhat.com> Date: Mon, 21 Nov 2016 14:04:10 -0600 MIME-Version: 1.0 In-Reply-To: <1479749488-31808-8-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="oEVeJ1WFj6EVNJjvxqL9anAOeqbx1b0NS" Subject: Re: [Qemu-devel] [PATCH 7/8] quorum: Implement .bdrv_co_preadv/pwritev() 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) --oEVeJ1WFj6EVNJjvxqL9anAOeqbx1b0NS From: Eric Blake To: Kevin Wolf , qemu-block@nongnu.org Cc: berto@igalia.com, mreitz@redhat.com, qemu-devel@nongnu.org Message-ID: <122bc834-8ab3-ce9d-2b22-8459afe6feee@redhat.com> Subject: Re: [PATCH 7/8] quorum: Implement .bdrv_co_preadv/pwritev() References: <1479749488-31808-1-git-send-email-kwolf@redhat.com> <1479749488-31808-8-git-send-email-kwolf@redhat.com> In-Reply-To: <1479749488-31808-8-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 enables byte granularity requests on quorum nodes. >=20 > Note that the QMP events emitted by the driver are an external API that= > we were careless enough to define as sector based. The offset and lengt= h > of requests reported in events are rounded therefore. >=20 > Signed-off-by: Kevin Wolf > --- > block/quorum.c | 79 ++++++++++++++++++++++++++------------------------= -------- > 1 file changed, 36 insertions(+), 43 deletions(-) >=20 > -static void quorum_report_bad(QuorumOpType type, uint64_t sector_num, > - int nb_sectors, char *node_name, int ret= ) > +static void quorum_report_bad(QuorumOpType type, uint64_t offset, > + uint64_t bytes, char *node_name, int ret= ) > { > const char *msg =3D NULL; > + int64_t start_sector =3D offset / BDRV_SECTOR_SIZE; > + int64_t end_sector =3D DIV_ROUND_UP(offset + bytes, BDRV_SECTOR_SI= ZE); This one looks correct, > + > if (ret < 0) { > msg =3D strerror(-ret); > } > =20 > - qapi_event_send_quorum_report_bad(type, !!msg, msg, node_name, > - sector_num, nb_sectors, &error_a= bort); > + qapi_event_send_quorum_report_bad(type, !!msg, msg, node_name, sta= rt_sector, > + end_sector - start_sector, &erro= r_abort); > } > =20 > static void quorum_report_failure(QuorumAIOCB *acb) > { > const char *reference =3D bdrv_get_device_or_node_name(acb->bs); > - qapi_event_send_quorum_failure(reference, acb->sector_num, > - acb->nb_sectors, &error_abort); > + qapi_event_send_quorum_failure(reference, > + acb->offset / BDRV_SECTOR_SIZE, > + acb->bytes / BDRV_SECTOR_SIZE, but this one still looks like it could give unexpected results for acb->bytes < BDRV_SECTOR_SIZE. > =20 > -static int quorum_co_readv(BlockDriverState *bs, > - int64_t sector_num, int nb_sectors, > - QEMUIOVector *qiov) > +static int quorum_co_preadv(BlockDriverState *bs, uint64_t offset, > + uint64_t bytes, QEMUIOVector *qiov, int fl= ags) > { Is it worth adding assert(!flags)? For now, the block layer doesn't have any defined flags (and if it did, we'd probably want to add a =2Esupported_read_flags to parallel the existing .supported_write_flags).= > BDRVQuorumState *s =3D bs->opaque; > - QuorumAIOCB *acb =3D quorum_aio_get(bs, qiov, sector_num, nb_secto= rs); > + QuorumAIOCB *acb =3D quorum_aio_get(bs, qiov, offset, bytes); > int ret; > =20 > acb->is_read =3D true; > @@ -726,9 +722,7 @@ static void write_quorum_entry(void *opaque) > QuorumChildRequest *sacb =3D &acb->qcrs[i]; > =20 > sacb->bs =3D s->children[i]->bs; > - sacb->ret =3D bdrv_co_pwritev(s->children[i], > - acb->sector_num * BDRV_SECTOR_SIZE, > - acb->nb_sectors * BDRV_SECTOR_SIZE, > + sacb->ret =3D bdrv_co_pwritev(s->children[i], acb->offset, acb->by= tes, > acb->qiov, 0); A followup patch that supports non-zero flags such as BDRV_REQUEST_FUA might be nice (presumably, we would advertise supported_write_flags of of BDRV_REQUEST_FUA only if all children support it). I agree that this patch is not the place to do it, though, so hard-coding to 0 may be okay, if... > if (sacb->ret =3D=3D 0) { > acb->success_count++; > @@ -745,12 +739,11 @@ static void write_quorum_entry(void *opaque) > } > } > =20 > -static int quorum_co_writev(BlockDriverState *bs, > - int64_t sector_num, int nb_sectors, > - QEMUIOVector *qiov) > +static int quorum_co_pwritev(BlockDriverState *bs, uint64_t offset, > + uint64_t bytes, QEMUIOVector *qiov, int f= lags) > { =2E..you make a decision on whether asserting that flags is zero is best for now. [Huh - side thought: right now, we don't have any defined semantics for BDRV_REQUEST_FUA on reads (although we modeled it in part after SCSI, which does have it defined for reads). But quorum rewrites on read might be an interesting application of where we can trigger a write during reads, and where we may want to guarantee FUA semantics on those writes, thus making a potentially plausible use of the flag on read] Due to my question about rounding in the event code, I'm omitting R-b for now. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --oEVeJ1WFj6EVNJjvxqL9anAOeqbx1b0NS 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/ iQEcBAEBCAAGBQJYM1M6AAoJEKeha0olJ0NqOG0H/2wL2RuZBF5KjO1/BwigPkUP W8LQQqkPtU5GEGHZ3912CkwbMO3ROQSK7jmeYg/mhHC2ep37uIffVweG0FEaexTk hcsEIXwkKWdzTPZtGtmeZeJkLLivxRWhyZW0PgJ2i9FX/ff+PjHSgnFA8bOvzYcs h39MFSXWzT1cILCtH4WAWOyrkeqbDPHDNnkmSYuRKGhpey0ZHwSHfuSOSYO9obit XyX/1DPG7cR6tM/xILb+od7uBDdBMDuVGeNOhqWbo5qDGW5rkMSM75PWQkEVIPx2 ox1iun4vJuRVCTVr3yd0Y3TgYPp1mdxdx7HyHuVBrl+3MpSeC/2tEXso/8zQA7k= =FiW3 -----END PGP SIGNATURE----- --oEVeJ1WFj6EVNJjvxqL9anAOeqbx1b0NS--