Received: from eggs.gnu.org ([2001:4830:134:3::10]:43928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YB3Kw-0001br-1F for qemu-devel@nongnu.org; Tue, 13 Jan 2015 10:24:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YB3Ks-0002nn-Rh for qemu-devel@nongnu.org; Tue, 13 Jan 2015 10:24:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56176) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YB3Ks-0002nd-KK for qemu-devel@nongnu.org; Tue, 13 Jan 2015 10:24:50 -0500 Date: Tue, 13 Jan 2015 15:24:38 +0000 From: Stefan Hajnoczi Message-ID: <20150113152438.GA26676@stefanha-thinkpad.redhat.com> References: <1418901484-12988-1-git-send-email-tumanova@linux.vnet.ibm.com> <1418901484-12988-3-git-send-email-tumanova@linux.vnet.ibm.com> <20150102115247.GC10823@stefanha-thinkpad.redhat.com> <54B4ED57.4000304@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="sdtB3X0nJg68CQEu" Content-Disposition: inline In-Reply-To: <54B4ED57.4000304@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH v5 2/5] raw-posix: Refactor logical block size detection. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ekaterina Tumanova Cc: kwolf@redhat.com, thuth@linux.vnet.ibm.com, dahi@linux.vnet.ibm.com, Stefan Hajnoczi , Public KVM Mailing List , armbru@redhat.com, borntraeger@de.ibm.com, cornelia.huck@de.ibm.com, pbonzini@redhat.com, mihajlov@linux.vnet.ibm.com --sdtB3X0nJg68CQEu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jan 13, 2015 at 01:03:03PM +0300, Ekaterina Tumanova wrote: > On 01/02/2015 02:52 PM, Stefan Hajnoczi wrote: > >On Thu, Dec 18, 2014 at 12:18:01PM +0100, Ekaterina Tumanova wrote: > >>+#if defined(BLKSSZGET) > >>+# define SECTOR_SIZE BLKSSZGET > >>+#elif defined(DKIOCGETBLOCKSIZE) > >>+# define SECTOR_SIZE DKIOCGETBLOCKSIZE > >>+#elif defined(DIOCGSECTORSIZE) > >>+# define SECTOR_SIZE DIOCGSECTORSIZE > >>+#else > >>+ return -ENOTSUP > >>+#endif > >>+ if (ioctl(fd, SECTOR_SIZE, sector_size) < 0) { > >>+ return -errno; > >>+ } > >>+ return 0; > >>+#undef SECTOR_SIZE > > > >Not a reason to respin, but I would have preferred simply moving the old > >code. > > > >I think the new code works because BLKSSZGET is Linux, DKIOCGETBLOCKSIZE > >is Mac OS, and DIOCGSECTORSIZE is FreeBSD. > > > >If there is a host OS where more than one ioctl is available and the > >first one fails then the new code is broken. The old code didn't use > >#elif so each ioctl had a chance to run. > > >=20 > In this case, why should it have a chance to run, if we only use one > result at a time? (Old code overwrites first result with the second) >=20 > Plus as far as I understand, in this hypothetical case of 2 ioctls > defined, one will most probably will be a redefinition of another. As code reviewer, I don't know exactly what all supported host OSes do (Linux, *BSD, Solaris, AIX, etc). If you leave the control flow unchanged then I'm confident that this patch doesn't introduce a bug. If you rewrite the control flow, then the semantics are different but I can't verify that they are correct in all cases. Spurious code changes make the life of code reviewers harder. Stefan --sdtB3X0nJg68CQEu Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUtTi2AAoJEJykq7OBq3PIG2YH/jxja7pSFG4akb0b0d0cb6pn SnztmeaVmkEx2IeT1QrA6i9eAc0NALIe1DmFnRN8vGYsXXErm0utuZZPbmPTB1Eq 9bus4wsJZReaZZ12fJw5E/68o8RCzejxnGsWQZ22wlojQU2ccyJ5Nf4pdx6atriS uJ56cCyvDYgeuHT8pQdHCC/0SRlE+r72beVVo6zqEg5sHie7uTh6kHMmYjzV8XNA xNwHldTioBQU8PU5/bJJSCm7X7D6ohdurQrys2fmRmQKI1QSZvgKqS2SkbZiA5XZ wgvT3AagZ68kMMML3c0y5DBexGtL5GbT5lrXxEQaZh0+kBqxNlDRB6nMxqpU2y4= =q6xC -----END PGP SIGNATURE----- --sdtB3X0nJg68CQEu--