From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35196) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGS7P-0006BD-4m for qemu-devel@nongnu.org; Fri, 24 Jun 2016 10:30:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bGS7N-0007ob-4j for qemu-devel@nongnu.org; Fri, 24 Jun 2016 10:30:02 -0400 Date: Fri, 24 Jun 2016 16:29:51 +0200 From: Kevin Wolf Message-ID: <20160624142951.GD5422@noname.redhat.com> References: <1466721446-27737-1-git-send-email-eblake@redhat.com> <1466721446-27737-18-git-send-email-eblake@redhat.com> <20160624064310.GC13266@ad.usersys.redhat.com> <576D4099.2020108@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="T4sUOijqQbZv57TR" Content-Disposition: inline In-Reply-To: <576D4099.2020108@redhat.com> Subject: Re: [Qemu-devel] [PATCH v3 17/22] block: Switch discard length bounds to byte-based List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Fam Zheng , qemu-devel@nongnu.org, qemu-block@nongnu.org, stefanha@redhat.com, Max Reitz , Ronnie Sahlberg , Paolo Bonzini , Peter Lieven --T4sUOijqQbZv57TR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 24.06.2016 um 16:15 hat Eric Blake geschrieben: > On 06/24/2016 12:43 AM, Fam Zheng wrote: > > On Thu, 06/23 16:37, Eric Blake wrote: > >> Sector-based limits are awkward to think about; in our on-going > >> quest to move to byte-based interfaces, convert max_discard and > >> discard_alignment. Rename them, using 'pdiscard' as an aid to > >> track which remaining discard interfaces need conversion, and so > >> that the compiler will help us catch the change in semantics > >> across any rebased code. The BlockLimits type is now completely > >> byte-based; and in iscsi.c, sector_limits_lun2qemu() is no > >> longer needed. > >> > >> pdiscard_alignment is made unsigned (we use power-of-2 alignments > >> as bitmasks, where unsigned is easier to think about) while > >> leaving max_pdiscard signed (since we still have an 'int' > >> interface); this is comparable to what commit cf081fc did for > >> write zeroes limits. We may later want to make everything an > >> unsigned 64-bit limit - but that requires a bigger code audit. > >> >=20 > >> - /* optimal alignment for discard requests in sectors */ > >> - int64_t discard_alignment; > >> + /* optimal alignment for discard requests in bytes, must be power > >> + * of 2, less than max_discard if that is set, and multiple of > >=20 > > s/max_discard/max_pdiscard/ >=20 > Maintainer could touch it up on pull request. Okay, no problem. > >> /* align request */ > >> - if (bs->bl.discard_alignment && > >> - num >=3D bs->bl.discard_alignment && > >> - sector_num % bs->bl.discard_alignment) { > >> - if (num > bs->bl.discard_alignment) { > >> - num =3D bs->bl.discard_alignment; > >> + if (discard_alignment && > >> + num >=3D discard_alignment && > >> + sector_num % discard_alignment) { > >> + if (num > discard_alignment) { > >> + num =3D discard_alignment; > >> } > >> - num -=3D sector_num % bs->bl.discard_alignment; > >> + num -=3D sector_num % discard_alignment; > >=20 > > Or just > >=20 > > num =3D discard_alignment - sector_num % discard_alignme= nt; > >=20 > > without the if. > >=20 >=20 > Sure. It all gets simplified later when I switch to bdrv_co_pdiscard(). > Up to the maintainer. This is an actual code change and not a bug fix, so I'll leave this one alone. We can always have a follow-up patch, but as you say your other work will simplify it anyway, I guess that's not necessary. Kevin --T4sUOijqQbZv57TR Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJXbUPfAAoJEH8JsnLIjy/W4TEP/0gE7pwSzTSHKoFSmLLeM3I7 ueM2N34j9oTLBqZGlD2lHZgt54yrBA41el/NTYlKxov2kjrSEQodgyPI82h7Dzgw 0Venv1ryhmxvZKAAzasSmNmiHrEhgkzz9yC/TR/6vljrItZSP3gu4Yk62oiVkus9 uD1MdqAetcxuVEvUauwvyW7KkjqTu0sw7a5QokSv1dyDHJVCu5TfgdvalqfbNuMH 6Oxbs/zX0gA+n6AVMTq1GnxIUbpypDDqQn30k3BujSSOckhYAiIuJrJhIbi98ynp NDiRLicV2ZUBas6jK7FYQJOoZ4gvMC8MNjXo84V4dM/0IYsYsg5Q7PXNdzN68GWN MSld/hYstBBtnqvWJ6yJnSNd3hmuSU3XTLji91s51o8YyD/oKWe0jalMd3gU5mp4 h0achgJdycAxGDqAEfRedBiGKl/Ds/IAlCbklJxcUnIA7BVh+qRAmyfNOc2sh19p nImUSpQ4DuSCpKI2QizKFEeL9YQLnw7+mqzmsulxBX/XzrD5ZiZZG2o2hWCReS7q hPMaxTUHC+WWgXrtFB9wc7Ip1V3NfJr+pqrvX9YYt3BL6Azc1Cj2AIfKBSNuadKe Ceu8ieMC5SzMFABo9EAIxRxwEt0DoSCoyAUw5R2cAB3Hcb71Z0nTnlGOeeTWEUvc L2ywziFmtJU7OyaPzlyk =Lu3s -----END PGP SIGNATURE----- --T4sUOijqQbZv57TR--