From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YAyJc-0000Rt-GA for qemu-devel@nongnu.org; Tue, 13 Jan 2015 05:03:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YAyJZ-0001Nm-7P for qemu-devel@nongnu.org; Tue, 13 Jan 2015 05:03:12 -0500 Received: from e06smtp13.uk.ibm.com ([195.75.94.109]:41532) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YAyJY-0001Nf-TL for qemu-devel@nongnu.org; Tue, 13 Jan 2015 05:03:09 -0500 Received: from /spool/local by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 13 Jan 2015 10:03:07 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id EB2791B08049 for ; Tue, 13 Jan 2015 10:03:40 +0000 (GMT) Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t0DA35lh62062668 for ; Tue, 13 Jan 2015 10:03:05 GMT Received: from d06av10.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t0DA34MW017346 for ; Tue, 13 Jan 2015 03:03:05 -0700 Message-ID: <54B4ED57.4000304@linux.vnet.ibm.com> Date: Tue, 13 Jan 2015 13:03:03 +0300 From: Ekaterina Tumanova MIME-Version: 1.0 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> In-Reply-To: <20150102115247.GC10823@stefanha-thinkpad.redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit 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: Stefan Hajnoczi Cc: kwolf@redhat.com, thuth@linux.vnet.ibm.com, dahi@linux.vnet.ibm.com, armbru@redhat.com, Public KVM Mailing List , mihajlov@linux.vnet.ibm.com, borntraeger@de.ibm.com, stefanha@redhat.com, cornelia.huck@de.ibm.com, pbonzini@redhat.com 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. > 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) Plus as far as I understand, in this hypothetical case of 2 ioctls defined, one will most probably will be a redefinition of another. p.s. ok to all further comments to patches. Thanks! Kate. > Also, the name SECTOR_SIZE is misleading. It's not a sector size value > but the "get sector size" ioctl request code. > > Stefan >