Received: from eggs.gnu.org ([2001:4830:134:3::10]:48828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7VgK-0000D0-R4 for qemu-devel@nongnu.org; Thu, 17 Nov 2016 18:01:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c7VgJ-0005Hg-U0 for qemu-devel@nongnu.org; Thu, 17 Nov 2016 18:01:24 -0500 References: <1479413642-22463-1-git-send-email-eblake@redhat.com> <1479413642-22463-6-git-send-email-eblake@redhat.com> <0c583cb9-0dbf-a43b-ba47-25f51a1b3232@redhat.com> From: Eric Blake Message-ID: Date: Thu, 17 Nov 2016 17:01:16 -0600 MIME-Version: 1.0 In-Reply-To: <0c583cb9-0dbf-a43b-ba47-25f51a1b3232@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="UtjTlnQmeu10TsIBcJx2xtfE9TeuWDcg8" Subject: Re: [Qemu-devel] [PATCH v2 5/9] block: Pass unaligned discard requests to drivers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, kwolf@redhat.com, pbonzini@redhat.com, qemu-stable@nongnu.org, Stefan Hajnoczi , Fam Zheng This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --UtjTlnQmeu10TsIBcJx2xtfE9TeuWDcg8 From: Eric Blake To: Max Reitz , qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, kwolf@redhat.com, pbonzini@redhat.com, qemu-stable@nongnu.org, Stefan Hajnoczi , Fam Zheng Message-ID: Subject: Re: [PATCH v2 5/9] block: Pass unaligned discard requests to drivers References: <1479413642-22463-1-git-send-email-eblake@redhat.com> <1479413642-22463-6-git-send-email-eblake@redhat.com> <0c583cb9-0dbf-a43b-ba47-25f51a1b3232@redhat.com> In-Reply-To: <0c583cb9-0dbf-a43b-ba47-25f51a1b3232@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/17/2016 04:26 PM, Max Reitz wrote: > On 17.11.2016 21:13, Eric Blake wrote: >> 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. >> >> 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 small requests to get to alignment boundaries. */= >> + num =3D MIN(count, align - head); >> + if (!QEMU_IS_ALIGNED(num, bs->bl.request_alignment)) { >> + num %=3D bs->bl.request_alignment; >> + } >=20 > Could be written as >=20 > num =3D num % bs->bl.request_alignment ?: num; >=20 > But that's up to you. >=20 > More importantly, is it possible that request_alignment > > pdiscard_alignment? In that case, align would be request_alignment, hea= d > would be less than request_alignment but could be more than > pdiscard_alignment. pdiscard_alignment can be 0 (no inherent limit); but it if it is nonzero, it must be at least request_alignment. The block layer (should be, if it is not already) enforcing that as part of the =2Ebdrv_refresh_limits() callback contract; at any rate, it is documented= that way in block_int.h --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --UtjTlnQmeu10TsIBcJx2xtfE9TeuWDcg8 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/ iQEcBAEBCAAGBQJYLja8AAoJEKeha0olJ0NqL04IAKf1ZRkKdPdw/IO5YiZvmZxu 9qzc6ln000CwinKoqFNIIFMIAEQYGI1yKxdC04xyhoUpGqdYmOLSrbgkcaekI+vZ zOCzp+EfRB5sAe5PUt0ac/qmCljRyVjIvSLpa9vhDmgOPpEsEbCLAWQYP1m7nYuB INxP9hxpxDS4wYT8h4Bf8vLIcRBlNY3Hsvclwe8Lp0xKMbEiNHtfpXGkJZw3YYbd HnjJeNm2B2MF93zHwDftHhz5/w6ojMac1k84AY/6M9C90FgU3kK9gGcMsRe7L46c +XulL+A7TMrSREqRfEPiVjW8ecTbv9vcbWbpljLGHyMfXhgU8N/tZ/tZ7V7wXRk= =ZGZp -----END PGP SIGNATURE----- --UtjTlnQmeu10TsIBcJx2xtfE9TeuWDcg8--