Received: from eggs.gnu.org ([2001:4830:134:3::10]:49242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7ViO-0001Of-D2 for qemu-devel@nongnu.org; Thu, 17 Nov 2016 18:03:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c7ViN-0005oI-JI for qemu-devel@nongnu.org; Thu, 17 Nov 2016 18:03:32 -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: Max Reitz Message-ID: Date: Fri, 18 Nov 2016 00:03:20 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="IWwt7f5wOj0OOmtfO4iC961inCplOuodp" 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: Eric Blake , 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) --IWwt7f5wOj0OOmtfO4iC961inCplOuodp From: Max Reitz To: Eric Blake , 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: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 18.11.2016 00:01, Eric Blake wrote: > 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. >>> >=20 >>> max_pdiscard =3D QEMU_ALIGN_DOWN(MIN_NON_ZERO(bs->bl.max_pdiscar= d, 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; >>> + } >> >> Could be written as >> >> num =3D num % bs->bl.request_alignment ?: num; >> >> But that's up to you. >> >> More importantly, is it possible that request_alignment > >> pdiscard_alignment? In that case, align would be request_alignment, he= ad >> would be less than request_alignment but could be more than >> pdiscard_alignment. >=20 > pdiscard_alignment can be 0 (no inherent limit); but it if it is > nonzero, it must be at least request_alignment. The block layer (shoul= d > be, if it is not already) enforcing that as part of the > .bdrv_refresh_limits() callback contract; at any rate, it is documented= > that way in block_int.h Yes, you're right. Thus: Reviewed-by: Max Reitz --IWwt7f5wOj0OOmtfO4iC961inCplOuodp Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEvBAEBCAAZBQJYLjc4EhxtcmVpdHpAcmVkaGF0LmNvbQAKCRD0B9sAYdXPQE2Q B/9vbKXE5DxbvLMpqIUgawqQrp+fo6eA8vvCaUiFrkwjowdyqENaOV86Rnblj+B8 IpziIBEtPvwsNJYvSXSTK409r9PNyACGTguLApxi9qaFJga8t8Nx2qmxkGZl+Yu6 qOfpoSdpRokN8bmmWywoHcZqQu6h4r3yyUstqqxs2FH2RmWg3EOIx8X4ue9gotAf LG1hQ3GNawcjvQL+xej/NIhhEZ2jec+Yltf/LJnUY5lQyc9V5t2KAlkDbdDCEUBu YlnK2QTL88bDYSyiNcB5EvK3raHYNOzewpuEa/CBqA/Z/qt8rY1x6kkSbuiXl31d F7TRR2A8HoQUhA8dvbYjD1wG =OwB5 -----END PGP SIGNATURE----- --IWwt7f5wOj0OOmtfO4iC961inCplOuodp--