From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD36CC43603 for ; Wed, 4 Dec 2019 13:30:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 870632077B for ; Wed, 4 Dec 2019 13:30:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=laposte.net header.i=@laposte.net header.b="IVjMPm63" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727887AbfLDNac (ORCPT ); Wed, 4 Dec 2019 08:30:32 -0500 Received: from smtpoutz27.laposte.net ([194.117.213.102]:36492 "EHLO smtp.laposte.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727635AbfLDNac (ORCPT ); Wed, 4 Dec 2019 08:30:32 -0500 X-Greylist: delayed 1439 seconds by postgrey-1.27 at vger.kernel.org; Wed, 04 Dec 2019 08:30:31 EST Received: from smtp.laposte.net (localhost [127.0.0.1]) by lpn-prd-vrout015 (Postfix) with ESMTP id D899227D7D3 for ; Wed, 4 Dec 2019 14:06:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=laposte.net; s=mail0; t=1575464790; bh=QoIoJNvQPoGhf1mEusSBQCFVb/hmuGDTkK983LBNhUA=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=IVjMPm635PtB2Yl7mYU30crQdS480bPi7jOE3zVI1J9Xa55WFhJQYQ87r5VIZ2qny QYI8Fwe5PpySZWTBSyzmtuS4BYB2cGQCQaUGt9zABQuvyEM5d4CLHDoZ+PiI3cXFV1 fEbSqLB8Y1fGWVe6DonfAoI8eJ0laFwDU2H2sflNp405NQyyZ2Cy1UKXdi4e1vEJaW n4m3bcglSXgT74zsTVnI6l3IYI7li5HROizHwu9s9iNjQG75TbZwD7qAyxPJyMOP8Q UvlYgKDRtmZPguV2rA8+fYRbKXqawoyAgqTsISfYiYTdmYMQ2SreNRPiDShLS3xKXG +JYSYp4V+F35Q== Received: from smtp.laposte.net (localhost [127.0.0.1]) by lpn-prd-vrout015 (Postfix) with ESMTP id CA8BF27DDCF for ; Wed, 4 Dec 2019 14:06:30 +0100 (CET) Received: from lpn-prd-vrin003 (lpn-prd-vrin003.prosodie [10.128.63.4]) by lpn-prd-vrout015 (Postfix) with ESMTP id C3D1D27DC27 for ; Wed, 4 Dec 2019 14:06:30 +0100 (CET) Received: from lpn-prd-vrin003 (localhost [127.0.0.1]) by lpn-prd-vrin003 (Postfix) with ESMTP id AFFBF4A725A for ; Wed, 4 Dec 2019 14:06:30 +0100 (CET) Received: from [192.168.1.18] (lfbn-mar-1-801-152.w92-150.abo.wanadoo.fr [92.150.127.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lpn-prd-vrin003 (Postfix) with ESMTPSA id 4C5A04A7228; Wed, 4 Dec 2019 14:06:29 +0100 (CET) Subject: Re: [PATCH] fs: introduce is_dot_dotdot helper for cleanup To: Tiezhu Yang , Matthew Wilcox Cc: Alexander Viro , "Theodore Y. Ts'o" , Jaegeuk Kim , Chao Yu , Eric Biggers , Tyler Hicks , linux-fsdevel@vger.kernel.org, ecryptfs@vger.kernel.org, linux-fscrypt@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org References: <1575281413-6753-1-git-send-email-yangtiezhu@loongson.cn> <20191202200302.GN20752@bombadil.infradead.org> <357ad021-a58c-ad46-42bd-d5012126276f@loongson.cn> From: Jean-Louis Biasini X-Pep-Version: 2.0 Message-ID: <12554a8e-2899-f03f-ec3d-d4cf35c4dd71@laposte.net> Date: Wed, 4 Dec 2019 14:06:28 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <357ad021-a58c-ad46-42bd-d5012126276f@loongson.cn> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Language: en-US X-VR-FullState: 0 X-VR-Score: -100 X-VR-Cause-1: gggruggvucftvghtrhhoucdtuddrgedufedrudejledggeejucetufdoteggodetrfdotffvucfrrhho X-VR-Cause-2: fhhilhgvmecunfetrffquffvgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhht X-VR-Cause-3: shculddquddttddmnecujfgurhepuffvfhfhkffffgggjggtgfesthhqredttdefjeenucfhrhhomhep X-VR-Cause-4: lfgvrghnqdfnohhuihhsuceuihgrshhinhhiuceojhhlrdgsihgrshhinhhisehlrghpohhsthgvrdhn X-VR-Cause-5: vghtqeenucfkphepledvrdduhedtrdduvdejrdduhedvnecurfgrrhgrmhepmhhouggvpehsmhhtphho X-VR-Cause-6: uhhtpdhinhgvthepledvrdduhedtrdduvdejrdduhedvpdhhvghloheplgduledvrdduieekrddurddu X-VR-Cause-7: kegnpdhmrghilhhfrhhomhepjhhlrdgsihgrshhinhhisehlrghpohhsthgvrdhnvghtpdhrtghpthht X-VR-Cause-8: oheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhi X-VR-Cause-9: nhhugidqfhdvfhhsqdguvghvvghlsehlihhsthhsrdhsohhurhgtvghfohhrghgvrdhnvghtpdhrtghp X-VR-Cause-10: thhtoheplhhinhhugidqfhhstghrhihpthesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthho X-VR-Cause-11: pegvtghrhihpthhfshesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhf X-VR-Cause-12: shguvghvvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthihhhhitghkshestggr X-VR-Cause-13: nhhonhhitggrlhdrtghomhdprhgtphhtthhopegvsghighhgvghrsheskhgvrhhnvghlrdhorhhgpdhr X-VR-Cause-14: tghpthhtohephihutghhrghotdeshhhurgifvghirdgtohhmpdhrtghpthhtohepjhgrvghgvghukhes X-VR-Cause-15: khgvrhhnvghlrdhorhhgpdhrtghpthhtohepthihthhsohesmhhithdrvgguuhdprhgtphhtthhopehv X-VR-Cause-16: ihhrohesiigvnhhivhdrlhhinhhugidrohhrghdruhhkpdhrtghpthhtohepfihilhhlhiesihhnfhhr X-VR-Cause-17: rgguvggrugdrohhrghdprhgtphhtthhopeihrghnghhtihgviihhuheslhhoohhnghhsohhnrdgtnhen X-VR-Cause-18: ucevlhhushhtvghrufhiiigvpedt X-VR-AvState: No X-VR-State: 0 X-VR-State: 0 Sender: linux-fscrypt-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org Please UNSUBSCRIBE ME from this list of tell how to!!! Le 03/12/2019 =C3=A0 03:07, Tiezhu Yang a =C3=A9crit=C2=A0: > On 12/03/2019 04:03 AM, Matthew Wilcox wrote: >> On Mon, Dec 02, 2019 at 06:10:13PM +0800, Tiezhu Yang wrote: >>> There exists many similar and duplicate codes to check "." and "..", >>> so introduce is_dot_dotdot helper to make the code more clean. >> The idea is good.=C2=A0 The implementation is, I'm afraid, badly chose= n. >> Did you benchmark this change at all?=C2=A0 In general, you should pre= fer the >> core kernel implementation to that of some less-interesting filesystem= s. >> I measured the performance with the attached test program on my laptop= >> (Core-i7 Kaby Lake): >> >> qstr . time_1 0.020531 time_2 0.005786 >> qstr .. time_1 0.017892 time_2 0.008798 >> qstr a time_1 0.017633 time_2 0.003634 >> qstr matthew time_1 0.011820 time_2 0.003605 >> qstr .a time_1 0.017909 time_2 0.008710 >> qstr , time_1 0.017631 time_2 0.003619 >> >> The results are quite stable: >> >> qstr . time_1 0.021137 time_2 0.005780 >> qstr .. time_1 0.017964 time_2 0.008675 >> qstr a time_1 0.017899 time_2 0.003654 >> qstr matthew time_1 0.011821 time_2 0.003620 >> qstr .a time_1 0.017889 time_2 0.008662 >> qstr , time_1 0.017764 time_2 0.003613 >> >> Feel free to suggest some different strings we could use for testing. >> These seemed like interesting strings to test with.=C2=A0 It's always >> possible >> I've messed up something with this benchmark that causes it to not >> accurately represent the performance of each algorithm, so please chec= k >> that too. > > [Sorry to resend this email because the mail list server > was denied due to it is not plain text.] > > Hi Matthew, > > Thanks for your reply and suggestion. I measured the > performance with the test program, the following > implementation is better for various of test cases: > > bool is_dot_dotdot(const struct qstr *str) > { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (unlikely(str->name[0] =3D= =3D '.')) { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 if (str->len < 2 || (str->len =3D=3D 2 && str->name[1]= =3D=3D > '.')) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return= true; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return false; > } > > I will send a v2 patch used with this implementation. > > Thanks, > > Tiezhu Yang > >> >>> +bool is_dot_dotdot(const struct qstr *str) >>> +{ >>> +=C2=A0=C2=A0=C2=A0 if (str->len =3D=3D 1 && str->name[0] =3D=3D '.')= >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return true; >>> + >>> +=C2=A0=C2=A0=C2=A0 if (str->len =3D=3D 2 && str->name[0] =3D=3D '.' = && str->name[1] =3D=3D '.') >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return true; >>> + >>> +=C2=A0=C2=A0=C2=A0 return false; >>> +} >>> +EXPORT_SYMBOL(is_dot_dotdot); >>> diff --git a/fs/namei.c b/fs/namei.c >>> index 2dda552..7730a3b 100644 >>> --- a/fs/namei.c >>> +++ b/fs/namei.c >>> @@ -2458,10 +2458,8 @@ static int lookup_one_len_common(const char >>> *name, struct dentry *base, >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!len) >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EACCES= ; >>> =C2=A0 -=C2=A0=C2=A0=C2=A0 if (unlikely(name[0] =3D=3D '.')) { >>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (len < 2 || (len =3D=3D= 2 && name[1] =3D=3D '.')) >>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 r= eturn -EACCES; >>> -=C2=A0=C2=A0=C2=A0 } >>> +=C2=A0=C2=A0=C2=A0 if (unlikely(is_dot_dotdot(this))) >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EACCES; >>> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 while (len--) { >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned int c= =3D *(const unsigned char *)name++; >