Received: from eggs.gnu.org ([2001:4830:134:3::10]:46014) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7VSf-0005C9-Ko for qemu-devel@nongnu.org; Thu, 17 Nov 2016 17:47:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c7VSe-0000ma-P5 for qemu-devel@nongnu.org; Thu, 17 Nov 2016 17:47:17 -0500 References: <1479413642-22463-1-git-send-email-eblake@redhat.com> <1479413642-22463-8-git-send-email-eblake@redhat.com> From: Max Reitz Message-ID: <72cc9fae-16de-bded-0280-46f58bcefc4f@redhat.com> Date: Thu, 17 Nov 2016 23:47:07 +0100 MIME-Version: 1.0 In-Reply-To: <1479413642-22463-8-git-send-email-eblake@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="VdKVTnA5wvFhClxTrRDjGJkvcQOG1jTXS" Subject: Re: [Qemu-devel] [PATCH v2 7/9] blkdebug: Add pass-through write_zero and discard support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, kwolf@redhat.com, pbonzini@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --VdKVTnA5wvFhClxTrRDjGJkvcQOG1jTXS From: Max Reitz To: Eric Blake , qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, kwolf@redhat.com, pbonzini@redhat.com Message-ID: <72cc9fae-16de-bded-0280-46f58bcefc4f@redhat.com> Subject: Re: [PATCH v2 7/9] blkdebug: Add pass-through write_zero and discard support References: <1479413642-22463-1-git-send-email-eblake@redhat.com> <1479413642-22463-8-git-send-email-eblake@redhat.com> In-Reply-To: <1479413642-22463-8-git-send-email-eblake@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.11.2016 21:14, Eric Blake wrote: > In order to test the effects of artificial geometry constraints > on operations like write zero or discard, we first need blkdebug > to manage these actions. Ideally, it would be nice to let these > operations also react to injected errors like read/write/flush, > but it is not trivial to turn bdrv_aio error injection (where > we return BlockAIOCB*) into bdrv_co (where we return int), not > to mention the fact that I don't want to conflict with Kevin's > concurrent work on refactoring away from bdrv_aio. So for now, > the operations merely have a TODO comment for adding error > injection. >=20 > However, one thing we CAN test is the contract promised by the > block layer; namely, if a device has specified limits on > alignment or maximum size, then those limits must be obeyed (for > now, the blkdebug driver merely inherits limits from whatever it > is wrapping, but the next patch will further enhance it to allow > specific limit overrides). >=20 > Tested by setting up an NBD server with export 'foo', then invoking: > $ ./qemu-io > qemu-io> open -o driver=3Dblkdebug blkdebug::nbd://localhost:10809/foo > qemu-io> d 0 15M > qemu-io> w -z 0 15M >=20 > Pre-patch, the server never sees the discard (it was silently > eaten by the block layer); post-patch it is passed across the > wire. Likewise, pre-patch the write is always passed with > NBD_WRITE (with 15M of zeroes on the wire), while post-patch > it can utilize NBD_WRITE_ZEROES (for less traffic). >=20 > Signed-off-by: Eric Blake > --- > block/blkdebug.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++ > 1 file changed, 61 insertions(+) >=20 > diff --git a/block/blkdebug.c b/block/blkdebug.c > index 0a47977..d45826d 100644 > --- a/block/blkdebug.c > +++ b/block/blkdebug.c [...] > @@ -522,6 +528,59 @@ static BlockAIOCB *blkdebug_aio_flush(BlockDriverS= tate *bs, > } >=20 >=20 > +static int coroutine_fn blkdebug_co_pwrite_zeroes(BlockDriverState *bs= , > + int64_t offset, int = count, > + BdrvRequestFlags fla= gs) > +{ > + uint32_t align =3D MAX(bs->bl.request_alignment, > + bs->bl.pwrite_zeroes_alignment); > + > + /* Regardless of whether the lower layer has a finer granularity, > + * we want to treat any unaligned request as unsupported, and Why? Assuming there is a reason: Reviewed-by: Max Reitz > + * check that the block layer never hands us anything crossing an > + * alignment boundary. */ > + if (count < align) { > + return -ENOTSUP; > + } [...] --VdKVTnA5wvFhClxTrRDjGJkvcQOG1jTXS Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEvBAEBCAAZBQJYLjNrEhxtcmVpdHpAcmVkaGF0LmNvbQAKCRD0B9sAYdXPQONJ B/0VaG18YFMSW+cUZ6zlJZtIFZjEue7JE38LJ+srfr0zLhlwLFH5cgHOQ+HOY8u+ rNRaNqOUsufuAzm49W6eOtbT8UtlOG5FPUTJefEId9qFTe10GjzMmLZHkoKIDYZS BuOMDnV3tTTDCbDGf553ladZIltia1+VuAIehxwhzDxzozyQitfcOT8zjLybpZRF Pm0zS1xqhuOgueqzBJ9kmc7jLxdd70xI50vQI/jC08Kquorq+RVbcJ9/NKgfn+u2 1zgMc2Ao6kNupUbsUW4hCi2RL5M/NHMMFKnCaXITxzP/zDyA+u3n/ydT0rPqyHGw DbWLx1ZXu9bRLOwlYNBYuKrI =g0nW -----END PGP SIGNATURE----- --VdKVTnA5wvFhClxTrRDjGJkvcQOG1jTXS--