From: Anand Avati Subject: Re: [fuse-devel] [PATCH v5 7/7] add a flag for per-operation O_DSYNC semantics Date: Thu, 6 Nov 2014 21:52:07 -0800 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a113df27ec1df0505073e690c Cc: Jeff Moyer , linux-arch@vger.kernel.org, linux-aio@kvack.org, linux-nfs@vger.kernel.org, Volker Lendecke , "Theodore Ts'o" , linux-mm@kvack.org, "fuse-devel@lists.sourceforge.net" , linux-api@vger.kernel.org, Linux Kernel Mailing List , Al Viro , Christoph Hellwig , Tejun Heo , Milosz Tanski , linux-fsdevel@vger.kernel.org, Michael Kerrisk , ceph-devel@vger.kernel.org, Christoph Hellwig , ocfs2-devel@oss.oracle.com, Mel Gorman To: Anton Altaparmakov Return-path: In-Reply-To: Sender: owner-linux-aio@kvack.org List-ID: --001a113df27ec1df0505073e690c Content-Type: text/plain; charset=UTF-8 On Thu, Nov 6, 2014 at 8:22 PM, Anton Altaparmakov wrote: > > On 7 Nov 2014, at 01:46, Jeff Moyer wrote: > > Minor nit, but I'd rather read something that looks like this: > > > > if (type == READ && (flags & RWF_NONBLOCK)) > > return -EAGAIN; > > else if (type == WRITE && (flags & RWF_DSYNC)) > > return -EINVAL; > > But your version is less logically efficient for the case where "type == > READ" is true and "flags & RWF_NONBLOCK" is false because your version then > has to do the "if (type == WRITE" check before discovering it does not need > to take that branch either, whilst the original version does not have to do > such a test at all. > Seriously? Just focus on the code readability/maintainability which makes the code most easily understood/obvious to a new pair of eyes, and leave such micro-optimizations to the compiler.. Thanks --001a113df27ec1df0505073e690c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Thu, Nov 6, 2014 at 8:22 PM, Anton Altaparmakov &l= t;aia21@cam.ac.uk&= gt; wrote:
> On 7 Nov 2014, at = 01:46, Jeff Moyer <jmoyer@redhat.co= m> wrote:
> Minor nit, but I'd rather read something that looks like this:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0if (type =3D=3D READ && (flags &= RWF_NONBLOCK))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return -EAGAIN;<= br> >=C2=A0 =C2=A0 =C2=A0 =C2=A0else if (type =3D=3D WRITE && (flags= & RWF_DSYNC))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return -EINVAL;<= br>
But your version is less logically efficient for the case where "type = =3D=3D READ" is true and "flags & RWF_NONBLOCK" is false= because your version then has to do the "if (type =3D=3D WRITE" = check before discovering it does not need to take that branch either, whils= t the original version does not have to do such a test at all.

Seriously? Just focus on the code readability/maint= ainability which makes the code most easily understood/obvious to a new pai= r of eyes, and leave such micro-optimizations to the compiler..
<= br>
Thanks
--001a113df27ec1df0505073e690c-- -- To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to majordomo@kvack.org. For more info on Linux AIO, see: http://www.kvack.org/aio/ Don't email: aart@kvack.org