Received: from eggs.gnu.org ([2001:4830:134:3::10]:33382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7UPk-0001l1-2p for qemu-devel@nongnu.org; Thu, 17 Nov 2016 16:40:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c7UPj-0001py-6l for qemu-devel@nongnu.org; Thu, 17 Nov 2016 16:40:12 -0500 References: <1479413642-22463-1-git-send-email-eblake@redhat.com> <1479413642-22463-4-git-send-email-eblake@redhat.com> From: Max Reitz Message-ID: <460171fb-4122-faaf-4007-4021132601ad@redhat.com> Date: Thu, 17 Nov 2016 22:40:00 +0100 MIME-Version: 1.0 In-Reply-To: <1479413642-22463-4-git-send-email-eblake@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="6o6Fh505USgniFMw80qV4qeUofLeaJB1l" Subject: Re: [Qemu-devel] [PATCH v3 3/9] block: Let write zeroes fallback work even with small max_transfer 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, "Denis V . Lunev" , Stefan Hajnoczi , Fam Zheng This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --6o6Fh505USgniFMw80qV4qeUofLeaJB1l 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, "Denis V . Lunev" , Stefan Hajnoczi , Fam Zheng Message-ID: <460171fb-4122-faaf-4007-4021132601ad@redhat.com> Subject: Re: [PATCH v3 3/9] block: Let write zeroes fallback work even with small max_transfer References: <1479413642-22463-1-git-send-email-eblake@redhat.com> <1479413642-22463-4-git-send-email-eblake@redhat.com> In-Reply-To: <1479413642-22463-4-git-send-email-eblake@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 17.11.2016 21:13, Eric Blake wrote: > Commit 443668ca rewrote the write_zeroes logic to guarantee that > an unaligned request never crosses a cluster boundary. But > in the rewrite, the new code assumed that at most one iteration > would be needed to get to an alignment boundary. >=20 > However, it is easy to trigger an assertion failure: the Linux > kernel limits loopback devices to advertise a max_transfer of > only 64k. Any operation that requires falling back to writes > rather than more efficient zeroing must obey max_transfer during > that fallback, which means an unaligned head may require multiple > iterations of the write fallbacks before reaching the aligned > boundaries, when layering a format with clusters larger than 64k > atop the protocol of file access to a loopback device. >=20 > Test case: >=20 > $ qemu-img create -f qcow2 -o cluster_size=3D1M file 10M > $ losetup /dev/loop2 /path/to/file > $ qemu-io -f qcow2 /dev/loop2 > qemu-io> w 7m 1k > qemu-io> w -z 8003584 2093056 >=20 > In fairness to Denis (as the original listed author of the culprit > commit), the faulty logic for at most one iteration is probably all > my fault in reworking his idea. But the solution is to restore what > was in place prior to that commit: when dealing with an unaligned > head or tail, iterate as many times as necessary while fragmenting > the operation at max_transfer boundaries. >=20 > Reported-by: Ed Swierk > CC: qemu-stable@nongnu.org > CC: Denis V. Lunev > Signed-off-by: Eric Blake > --- > block/io.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) Reviewed-by: Max Reitz --6o6Fh505USgniFMw80qV4qeUofLeaJB1l Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEvBAEBCAAZBQJYLiOwEhxtcmVpdHpAcmVkaGF0LmNvbQAKCRD0B9sAYdXPQF+P CACqV0iEffjTnDCzdB2QPqtjkIUwKGeJzTCesdfX3m+zZW8PBluUeYhjzoLH6Jps fqi+ZGfvbrL4LGsy1xE/IYzdUu6GkNMRv7OZdSEmrakJ9I5WJGaA9vLPpMrNfc13 P6Aj5zW+IiuB2CjjeiHtHY1jOS3LKER7nsjyWb8bfKQzWMLq5M7TjdfHqTMB7CSH DFS850U5JUjyg4v6lb30JSnfeQfUlgaH1vSNDa0G+1yYK4Rkv1FtHzPW7Wl92gSf jsraivdeR6rNqXU0z555LoD9l7erDkcYihB2zjYHq8yoxkaRCzfdX88+9tDf93nD zNBfkp56cL7RkXHrJ8NypTWD =3geK -----END PGP SIGNATURE----- --6o6Fh505USgniFMw80qV4qeUofLeaJB1l--