Re: [PATCH 2/3] fat: add the msdos_format_name() filename cache

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Al,

"Al Viro" <viro@xxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxx>
>> > ---
>> >  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





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux