Received: from eggs.gnu.org ([2001:4830:134:3::10]:44205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ayisR-0004s4-C0 for qemu-devel@nongnu.org; Fri, 06 May 2016 12:45:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ayisF-0002gZ-LA for qemu-devel@nongnu.org; Fri, 06 May 2016 12:45:13 -0400 References: <1459513321-3776-1-git-send-email-olaf@aepfle.de> <56FEAD92.5010802@redhat.com> <20160401174953.GD22458@aepfle.de> From: Max Reitz Message-ID: <7bcb7f33-5fb1-20d8-e92f-3b913b54e53b@redhat.com> Date: Fri, 6 May 2016 18:44:27 +0200 MIME-Version: 1.0 In-Reply-To: <20160401174953.GD22458@aepfle.de> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="QHdwKILIRF3A2qd112aOw7vwkKtEcdG9h" Subject: Re: [Qemu-devel] [Qemu-block] [PATCH] block: split large discard requests from block frontend List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Olaf Hering Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Kevin Wolf , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --QHdwKILIRF3A2qd112aOw7vwkKtEcdG9h Content-Type: multipart/mixed; boundary="onAQJORsw5K5TNIiDAkAoJreh9omiUWcf" From: Max Reitz To: Olaf Hering Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, Kevin Wolf , Stefan Hajnoczi Message-ID: <7bcb7f33-5fb1-20d8-e92f-3b913b54e53b@redhat.com> Subject: Re: [Qemu-block] [PATCH] block: split large discard requests from block frontend References: <1459513321-3776-1-git-send-email-olaf@aepfle.de> <56FEAD92.5010802@redhat.com> <20160401174953.GD22458@aepfle.de> In-Reply-To: <20160401174953.GD22458@aepfle.de> --onAQJORsw5K5TNIiDAkAoJreh9omiUWcf Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01.04.2016 19:49, Olaf Hering wrote: > On Fri, Apr 01, Max Reitz wrote: >=20 >> In any case, do you have a test case where a guest was able to submit = a >> request that led to the overflow error you described in the commit mes= sage? >=20 > mkfs -t ext4 /dev/sdb1 in a xen guest with qcow2 as backing device. > When I added discard support to libxl I worked with raw images, so I di= d > not notice this. Not sure why it happens to work in kvm guests. I assum= e > the frontend driver just works around the qemu bug by limiting its > request size. Sorry for not having replied in so long. I know next to nothing about Xen, but I'm very much inclined to think the Xen block driver (hw/block/xen_disk.c) is at fault here. The blkif_request_discard structure it uses for accepting discard requests apparently has a uint64_t nr_sectors field. So I think using the Xen block device, it is possible for a guest to submit discard requests with more then INT_MAX sectors involved, and it's the Xen's block device emulation code job to split those requests into smaller ones. That said, I'm not sure this is ideal. It doesn't really look like other block drivers care so much about splitting requests either. So we're a bit in a pickle there. Anyway, for your issue at hand I think there is a simpler solution. bdrv_co_discard() can and already does split requests. So if we remove the calls to blk_check_request() in blk_discard() and bdrv_check_request() in bdrv_co_discard(), everything should already work just fine. Therefore, I think what could work for now is for blk_discard() and bdrv_co_discard() to modify the checks they are doing on the incoming request. In theory, all we need to do is skip the length check for both, i.e. accept requests even if they are longer than INT_MAX / BDRV_SECTOR_SIZE sectors. I'm not sure how we can do that nicely in practice, though. Max --onAQJORsw5K5TNIiDAkAoJreh9omiUWcf-- --QHdwKILIRF3A2qd112aOw7vwkKtEcdG9h 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 iQEcBAEBCAAGBQJXLMnrAAoJEDuxQgLoOKyt8rIH/2/VhmB8fZgOtJ6+uACcd9Ka PJJNO4g6osj1LegLIi7G9mdyySmUPS+DYZxUcq4yRsAL5Un0ZbZTg7ESmqUSqXKb H3VGLQv/+Ws9W/IHQdYNbZFSGVzoWEPC0e3b2sFRgYQvsqQfq7tTyUSwoIhuERwr Px230TTKWQkqUajxmafwGSMj9/jisR+FEqLMkWp4s8jAhyGuGF2oSAtLfueD7vlw dymL7NCTX5i5MNM0obbHpPE5AxWVkMkgGyMVmEU+OOn16OXvljllJ24YgJto7eVm DyWARSNWmV8v69usdSibbUT9GYNMjA8rLKrSUuVKBxnH2nmt/5SAPr9HPSQDUy0= =qA3T -----END PGP SIGNATURE----- --QHdwKILIRF3A2qd112aOw7vwkKtEcdG9h--