From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b895s-00021U-CL for qemu-devel@nongnu.org; Wed, 01 Jun 2016 12:34:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b895r-0007Kz-7B for qemu-devel@nongnu.org; Wed, 01 Jun 2016 12:34:08 -0400 References: <1464128732-12667-1-git-send-email-eblake@redhat.com> <1464128732-12667-6-git-send-email-eblake@redhat.com> <20160525133402.GH4815@noname.redhat.com> From: Eric Blake Message-ID: <574F0E77.8040909@redhat.com> Date: Wed, 1 Jun 2016 10:33:59 -0600 MIME-Version: 1.0 In-Reply-To: <20160525133402.GH4815@noname.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="brCoVfj0WqHdE6aJLXunTXVxhPGsJbISl" Subject: Re: [Qemu-devel] [PATCH 05/13] iscsi: Convert to bdrv_co_pwrite_zeroes() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Ronnie Sahlberg , Paolo Bonzini , Peter Lieven , Max Reitz This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --brCoVfj0WqHdE6aJLXunTXVxhPGsJbISl Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05/25/2016 07:34 AM, Kevin Wolf wrote: > Am 25.05.2016 um 00:25 hat Eric Blake geschrieben: >> Another step on our continuing quest to switch to byte-based >> interfaces. >> >> As this is the first byte-based iscsi interface, convert >> is_request_lun_aligned() into two versions, one for sectors >> and one for bytes. >> >> Signed-off-by: Eric Blake >> --- >> block/iscsi.c | 53 +++++++++++++++++++++++++++++++-------------------= --- >> 1 file changed, 31 insertions(+), 22 deletions(-) >> >> +static bool is_sector_request_lun_aligned(int64_t sector_num, int nb_= sectors, >> + IscsiLun *iscsilun) >> +{ >> + return is_byte_request_lun_aligned(sector_num << BDRV_SECTOR_BITS= , >> + nb_sectors << BDRV_SECTOR_BITS= , >> + iscsilun); >> } >=20 > You're switching from (nb_sectors * BDRV_SECTOR_SIZE) to (nb_sectors <<= > BDRV_SECTOR_BITS). The difference is that the former is a 64 bit > calculation because BDRV_SECTOR_BITS is unsigned long long, whereas the= > latter is a 32 bit calculation. >=20 > Fortunately, it seems to me that all input values come directly from th= e > block layer which already limits requests to BDRV_REQUEST_MAX_SECTORS. > So we should be safe from overflows here. Still, it won't hurt to add an assert. >> @@ -978,7 +985,7 @@ coroutine_fn iscsi_co_write_zeroes(BlockDriverStat= e *bs, int64_t sector_num, >> uint32_t nb_blocks; >> bool use_16_for_ws =3D iscsilun->use_16_for_rw; >> >> - if (!is_request_lun_aligned(sector_num, nb_sectors, iscsilun)) { >> + if (!is_byte_request_lun_aligned(offset, count, iscsilun)) { >> return -EINVAL; >> } >=20 > Should this become -ENOTSUP so that emulation can take over rather than= > failing the request? It's still -EINVAL on unaligned write requests; then again, the block layer guarantees that it will honor bs->request_alignment for write requests, even on RMW for write-zeroes fallbacks. So switching to -ENOTSUP makes sense. >=20 > We should probably also always set bs->bl.pwrite_zeroes_alignment, with= > a fallback to iscsilun->block_size if we don't have iscsilun->lbp.lbpws= =2E > But that's a separate patch. Yes, added as a separate patch. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --brCoVfj0WqHdE6aJLXunTXVxhPGsJbISl 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/ iQEcBAEBCAAGBQJXTw53AAoJEKeha0olJ0Nq8f8H/iwG7gN5lLIAWxDaVe9bLXe6 PzbXUffVkMNfet8A3cT59mRA01cPuOy1d30WCTzOAwEFHkhnyH0n7f/OTqi58p4S wpErhbykZZQ64KFmWlaVWhL08O0Ul4MMAeI+tosEA2ID5/o9747pic19H1I6CwEg AzHTwNhNW+kvx9419pPCPxUckQPJcS8LnVdPnB46f/TqkmmlsqLKQ+ld2QUSeCrW F2IBPave69buPOMDjjeo6gfvVQI2eSceSJyfhvE6kkijxrxBTx+pLM8+ebDmru38 i1mj95jXBWgeyvRYk807kIeBTxzZDp9+YNd0RZp8KQ9WiXKiNd2ykDCbmbVJs7o= =iZu9 -----END PGP SIGNATURE----- --brCoVfj0WqHdE6aJLXunTXVxhPGsJbISl--