[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87k0k4w4mb.fsf@protonmail.com>
Date: Sun, 29 Aug 2021 17:19:28 +0000
From: "Caleb D.S. Brzezinski" <calebdsb@...tonmail.com>
To: Al Viro <viro@...iv.linux.org.uk>
Cc: hirofumi@...l.parknet.co.jp, linux-kernel@...r.kernel.org,
linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH 2/3] fat: add the msdos_format_name() filename cache
Hi Al,
"Al Viro" <viro@...iv.linux.org.uk> writes:
> 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 <calebdsb@...tonmail.com>
>> > ---
>> > 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
>> Where does the extension come from?
I'll be honest, I don't have any. Before I started writing this code I
poked msdos_format_name() with a lot of sticks to make sure I understood
the behavior, and it never carried over extentions into the FAT system;
at least, not that I saw through this function.
> While we are at it, your "fast path" doesn't even look at opts
> argument...
My understanding is that opts is a semi-global/per-drive setting. If
that's wrong then again, yes, this won't function correctly, but it does
seem to work.
Thanks.
Caleb B.
--
"Come now, and let us reason together," Says the LORD
-- Isaiah 1:18a, NASB
Powered by blists - more mailing lists