Received: from eggs.gnu.org ([2001:4830:134:3::10]:49537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c5CjB-0002nO-0D for qemu-devel@nongnu.org; Fri, 11 Nov 2016 09:22:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c5Cj9-0000Vp-V8 for qemu-devel@nongnu.org; Fri, 11 Nov 2016 09:22:48 -0500 References: <1478819426-7564-1-git-send-email-eblake@redhat.com> <1478819426-7564-3-git-send-email-eblake@redhat.com> <5825A449.4020807@kamp.de> From: Eric Blake Message-ID: <29d2c105-3cc3-454d-cdc2-8a3a3cd6b204@redhat.com> Date: Fri, 11 Nov 2016 08:22:40 -0600 MIME-Version: 1.0 In-Reply-To: <5825A449.4020807@kamp.de> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="E7BskC3gJoMvj1MpGidNirdGJN4EOspeW" Subject: Re: [Qemu-devel] [Qemu-stable] [PATCH 2/2] block: Pass unaligned discard requests to drivers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven , qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, qemu-stable@nongnu.org, Max Reitz , Stefan Hajnoczi , pbonzini@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --E7BskC3gJoMvj1MpGidNirdGJN4EOspeW From: Eric Blake To: Peter Lieven , qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, qemu-stable@nongnu.org, Max Reitz , Stefan Hajnoczi , pbonzini@redhat.com Message-ID: <29d2c105-3cc3-454d-cdc2-8a3a3cd6b204@redhat.com> Subject: Re: [Qemu-stable] [PATCH 2/2] block: Pass unaligned discard requests to drivers References: <1478819426-7564-1-git-send-email-eblake@redhat.com> <1478819426-7564-3-git-send-email-eblake@redhat.com> <5825A449.4020807@kamp.de> In-Reply-To: <5825A449.4020807@kamp.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/11/2016 04:58 AM, Peter Lieven wrote: > Am 11.11.2016 um 00:10 schrieb Eric Blake: >> Discard is advisory, so rounding the requests to alignment >> boundaries is never semantically wrong from the data that >> the guest sees. But at least the Dell Equallogic iSCSI SANs >> has an interesting property that its advertised discard >> alignment is 15M, yet documents that discarding a sequence >> of 1M slices will eventually result in the 15M page being >> marked as discarded, and it is possible to observe which >> pages have been discarded. >> >> @@ -2468,11 +2464,25 @@ int coroutine_fn bdrv_co_pdiscard(BlockDriverS= tate *bs, int64_t offset, >> >> max_pdiscard =3D QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_pdiscard= , INT_MAX), >> align); >> - assert(max_pdiscard); >> + assert(max_pdiscard >=3D bs->bl.request_alignment); >> >> while (count > 0) { >> int ret; >> - int num =3D MIN(count, max_pdiscard); >> + int num =3D count; >> + >> + if (head) { >> + /* Make a small request up to the first aligned sector. *= / >> + num =3D MIN(count, align - head); >> + head =3D (head + num) % align; >=20 > Is there any way that head is !=3D 0 after this? The corresponding write_zero code (after my other pending patch) is: num =3D MIN(MIN(count, max_transfer), align - head); where it is indeed possible that head is still nonzero after this. But you are correct that for discard, as written, head is always zero after this assignment. On the other hand, I'm wondering if I should additionally be prepared to split twice: suppose you have a device with a 512 request_alignment, but the discard request is byte-aligned. If the device can discard 512 bytes at a time (qcow2 can, if the file was configured with 512-byte clusters), but the request is not on a 512-byte boundary, it may make sense to do a really small request up to request_alignment, then a larger request up to pdiscard_alignment, before doing the bulk at proper alignment. Should I send a v2 along those lines? I'm still working up a blkdebug patch that lets us add qemu-iotests, that will be my ultimate proof of whether I can indeed come up with a case that differs by whether I subdivide the head into as many as two parts. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --E7BskC3gJoMvj1MpGidNirdGJN4EOspeW 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/ iQEcBAEBCAAGBQJYJdQwAAoJEKeha0olJ0NqffYH/i7wms5vahi8plmiAhl6zjcD cQV95MXX3PwmOOWyL15B4o4GIwBUhAqNuOQxM6w42Y5RazZnlCPHE42kF50Ql8tD 4fwBB3yIe5/J4zTwiGmJ7n48gV0DjYhTVnukIMfCHX+EoS6VqHZvXNqAh3ZMs94p GH9O1nbXGVXEsQIXPvgF0plj8QlskYttV5BwUJNCJ6VYy5nRvY8U2Jz9EDbdsrZY ViRsPbN+JtyXz5Qo/jxxFM0vLlhwwpfclrKXiEGkKV5JUncPUoNl8mWcVAKGW37n Fg+AEaYYEjlsF0FuBoqCfTV060KCQ1vZSh++R5K2jZHFoIwCfQjjhm3xzV9a59I= =uMBS -----END PGP SIGNATURE----- --E7BskC3gJoMvj1MpGidNirdGJN4EOspeW--