large directory performance

amobbs at amobbs at
Thu Sep 30 10:56:23 GMT 1999

Samba performs a readdir for each file open or creat, from

I'm using Samba on a system which has painfully slow readdir performance for
large directories (serving files off MO and DVD-RAM Jukeboxes), leading to a
delay of several seconds per open/creat. This really adds up if you're working
with all files in a directory of several 1000 files. (Yes, I know that having
several thousand files in a directory is a Bad Thing, just try convincing some
of the people using this system of that).

Now I think I can help the common case of opening an existing file when the
filename hasn't been mangled the case has remained the same, it doesn't end in a
'.' &c. by stat'ing the file name as given. If this succeeds I believe I can
then avoid doing a whole readdir.

However, this only solves the problem if the file does exist. For file creation,
there's still a problem, e.g. if I'm copying a directory of several thousand
files from a workstation to the jukebox then Samba will do a full readdir for
*every* file.

Are my suppositions about speeding up open valid? And can anybody think of a way
of avoiding a full readdir on creat? If the answer to either of these is yes, I
can write the code and contribute it back to Samba (if you want it).


More information about the samba-technical mailing list