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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 CAC1DC432BE for ; Sun, 29 Aug 2021 15:26:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AA0A9606A5 for ; Sun, 29 Aug 2021 15:26:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235573AbhH2P1P (ORCPT ); Sun, 29 Aug 2021 11:27:15 -0400 Received: from zeniv-ca.linux.org.uk ([142.44.231.140]:49322 "EHLO zeniv-ca.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231216AbhH2P1M (ORCPT ); Sun, 29 Aug 2021 11:27:12 -0400 Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mKMhL-00H4Vs-T2; Sun, 29 Aug 2021 15:26:16 +0000 Date: Sun, 29 Aug 2021 15:26:15 +0000 From: Al Viro To: "Caleb D.S. Brzezinski" Cc: hirofumi@mail.parknet.co.jp, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 2/3] fat: add the msdos_format_name() filename cache Message-ID: References: <20210829142459.56081-1-calebdsb@protonmail.com> <20210829142459.56081-3-calebdsb@protonmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 29, 2021 at 03:11:22PM +0000, Al Viro wrote: > On Sun, Aug 29, 2021 at 02:25:29PM +0000, Caleb D.S. Brzezinski wrote: > > Implement the main msdos_format_name() filename cache. If used as a > > module, all memory allocated for the cache is freed when the module is > > de-registered. > > > > Signed-off-by: Caleb D.S. Brzezinski > > --- > > fs/fat/namei_msdos.c | 35 +++++++++++++++++++++++++++++++++++ > > 1 file changed, 35 insertions(+) > > > > diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c > > index 7561674b1..f9d4f63c3 100644 > > --- a/fs/fat/namei_msdos.c > > +++ b/fs/fat/namei_msdos.c > > @@ -124,6 +124,16 @@ static int msdos_format_name(const unsigned char *name, int len, > > unsigned char *walk; > > unsigned char c; > > int space; > > + u64 hash; > > + struct msdos_name_node *node; > > + > > + /* check if the name is already in the cache */ > > + > > + hash = msdos_fname_hash(name); > > + if (find_fname_in_cache(res, hash)) > > + return 0; > > Huh? How could that possibly work, seeing that > * your hash function only looks at the first 8 characters > * your find_fname_in_cache() assumes that hash collisions > are impossible, which is... unlikely, considering the nature of > that hash function > * find_fname_in_cache(res, hash) copies at most 8 characters > into res in case of match. Where does the extension come from? > > Out of curiosity, how have you tested that thing? While we are at it, your "fast path" doesn't even look at opts argument...