Received: from eggs.gnu.org ([2001:4830:134:3::10]:56729) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9Bp6-0003mY-Th for qemu-devel@nongnu.org; Tue, 22 Nov 2016 09:13:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9Bp5-0005IE-Pc for qemu-devel@nongnu.org; Tue, 22 Nov 2016 09:13:24 -0500 References: <1479413642-22463-1-git-send-email-eblake@redhat.com> <1479413642-22463-6-git-send-email-eblake@redhat.com> <20161122140343.GF5615@noname.redhat.com> From: Eric Blake Message-ID: Date: Tue, 22 Nov 2016 08:13:15 -0600 MIME-Version: 1.0 In-Reply-To: <20161122140343.GF5615@noname.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="smdJxAO08sBRbknEXBrEahPCnRKF0ms9j" 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: Kevin Wolf Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, pbonzini@redhat.com, qemu-stable@nongnu.org, Stefan Hajnoczi , Fam Zheng , Max Reitz This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --smdJxAO08sBRbknEXBrEahPCnRKF0ms9j From: Eric Blake To: Kevin Wolf Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, pbonzini@redhat.com, qemu-stable@nongnu.org, Stefan Hajnoczi , Fam Zheng , Max Reitz 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> <20161122140343.GF5615@noname.redhat.com> In-Reply-To: <20161122140343.GF5615@noname.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/22/2016 08:03 AM, Kevin Wolf wrote: > Am 17.11.2016 um 21:13 hat Eric Blake geschrieben: >> 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. >> >> >> Rework the block layer discard algorithm to mirror the write >> zero algorithm: always peel off any unaligned head or tail >> and manage that in isolation, then do the bulk of the request >> on an aligned boundary. The fallback when the driver returns >> -ENOTSUP for an unaligned request is to silently ignore that >> portion of the discard request; but for devices that can pass >> the partial request all the way down to hardware, this can >> result in the hardware coalescing requests and discarding >> aligned pages after all. >> >=20 > Hm, from the commit message I expected splitting requests in three > (head, bulk, tail), but actually we can end up splitting it in five? Correct; so maybe I need to improve the commit message. The goal in multiple splits was to make it easier for drivers to not have to worry about re-aligning things (a request is either sub-sector, sub-page but sector-aligned, or page-aligned). >=20 > Just to check whether I got this right, let me try an example: Let's > assume request alignment 512, pdiscard alignment 64k, and we get a > discard request with offset 510, length 130k. This algorithm makes the > following calls to the driver: >=20 > 1. pdiscard offset=3D510, len=3D2 | new count =3D 130k - = 2 > 2. pdiscard offset=3D512, len=3D(64k - 512) | new count =3D 66k + 5= 10 > 3. pdiscard offset=3D64k, len=3D64k | new count =3D 2558 > 4. pdiscard offset=3D128k, len=3D2048 | new count =3D 510 > 5. pdiscard offset=3D130k, len=3D510 | new count =3D 0 >=20 > Correct? >=20 Yes. > If so, is this really necessary or even helpful? I see that the iscsi > driver throws away requests 1 and 5 and needs the split because > otherwise it would disregard the areas covered by 2 and 4, too. But why= > can't or shouldn't the iscsi driver do this rounding itself when it get= s > combined 1+2 and 4+5 requests? Because then every driver has to implement rounding; I thought that having centralized rounding code was easier to maintain overall than having every driver reimplement it. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --smdJxAO08sBRbknEXBrEahPCnRKF0ms9j 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/ iQEcBAEBCAAGBQJYNFJ7AAoJEKeha0olJ0Nq92IH/jFdl1ffT6xToigh9w36Eawq ucFso7lvrIm+I+pUfDWEhykawN1NbXqvYUd+XSTUviQkO5SGzlS2TERbnRaoW2xp jtbt+xo0yb4kscYPNLQJkopOQpZHIJjkDqcWIBcXMJFcqyze/KjL1XAkH9lHk9Nn JeD4/7DMV7qgEeGuUJywdqGviq97UafaAIbgKe/HsG7bC329XPH/LGkJtY1ZP116 vtVgcbJgFcrhY+SrZhTjDvjtoM14yZF6WWLng3qvub1ftPnxTHyCRwh8c3VSFKmU kaGPuH82a9XmyNqlN0SQYKjrQBDpVNCWlRPuE3uqfaswBDkJdsA+he4JcC9jTQM= =TBMS -----END PGP SIGNATURE----- --smdJxAO08sBRbknEXBrEahPCnRKF0ms9j--