[Samba] understanding stat cache

Ralph Boehme slow at samba.org
Mon Nov 13 16:22:17 UTC 2023

Hello Ulrich,

On 11/10/23 13:47, Ulrich Sibiller via samba wrote:
> We have a user that switched from Linux to Windows with his
> engineering software. Previously he was using NFS to access data and
> there were no performance complaints.
> Now, with Windows, the same procedures take minutes instead of
> seconds.

the classic workload where Samba performance sucks is when applications 
create many files in directories. In Samba this involves scanning the 
parent directory for every file as part of the case insensitive 
implementation on-top of a case sensitive filesystem.

There are a few things that can be done here, eg man smb.conf

        default case = upper/lower
            controls what the default case is for new
            filenames (ie. files that don't currently exist
            in the filesystem). Default lower. IMPORTANT
            NOTE: As part of the optimizations for
            directories containing large numbers of files,
            the following special case applies. If the
            options case sensitive = yes, preserve case = No,
            and short preserve case = No are set, then the
            case of all incoming client filenames, not just
            new filenames, will be modified. See additional
            notes below.

Ideally you'd have a filesystem that is case insensitive (ext4 added 
support recently) or a filesystem that is supported by Samba via a VFS 
hook to lookup files.

> So I am wondering why the first two lookups always fail and/or
> obviously are never stored to the stat cache?  Is there a depth limit
> in the stat cache?

the name stat cache is a bit misleading, only caches filenames, not stat 
info. It only helps if clients repeatedly access existing files with a 
wrong case.


SerNet Samba Team Lead          https://samba.plus/
Samba Team Member                https://samba.org/
SAMBA+ packages                 https://samba.plus/
Worldwide Samba Support, Consulting and Development
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba/attachments/20231113/073e2a7d/OpenPGP_signature.sig>

More information about the samba mailing list