From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ob0-f177.google.com (mail-ob0-f177.google.com [209.85.214.177]) by kanga.kvack.org (Postfix) with ESMTP id 07D2E800DA for ; Fri, 7 Nov 2014 00:52:09 -0500 (EST) Received: by mail-ob0-f177.google.com with SMTP id m8so1999102obr.36 for ; Thu, 06 Nov 2014 21:52:08 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: Date: Thu, 6 Nov 2014 21:52:07 -0800 Message-ID: Subject: Re: [fuse-devel] [PATCH v5 7/7] add a flag for per-operation O_DSYNC semantics From: Anand Avati Content-Type: multipart/alternative; boundary=001a113df27ec1df0505073e690c Sender: owner-linux-mm@kvack.org List-ID: To: Anton Altaparmakov 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 --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-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org