Optimizing findfirst for existing files
Heinrich Mislik
Heinrich.Mislik at univie.ac.at
Fri Oct 19 10:47:22 GMT 2007
Hi,
this is from samba log:
[2007/10/19 11:43:26, 3, pid=3088612]
smbd/trans2.c:call_trans2findfirst(1365)
call_trans2findfirst: dirtype = 22, maxentries = 1366,
close_after_first=1, close_if_end = 2 requires_resume_key = 4 level =
0x104, max_data_bytes = 16384
[2007/10/19 11:43:26, 5, pid=3088612]
smbd/filename.c:unix_convert(108)
unix_convert called on file "pcr/Cookies/a0348477 at CA7OLRB8.txt"
[2007/10/19 11:43:26, 5, pid=3088612]
smbd/filename.c:unix_convert(174)
conversion finished pcr/Cookies/a0348477 at CA7OLRB8.txt ->
pcr/Cookies/a0348477 at CA7OLRB8.txt
[2007/10/19 11:43:26, 5, pid=3088612]
smbd/trans2.c:call_trans2findfirst(1418)
dir=pcr/Cookies, mask = a0348477 at CA7OLRB8.txt
[2007/10/19 11:43:26, 5, pid=3088612] smbd/dir.c:start_dir(334)
start_dir dir=pcr/Cookies
[2007/10/19 11:43:26, 3, pid=3088612] smbd/dir.c:dptr_create(491)
creating new dirptr 256 for path pcr/Cookies, expect_close = 1
[2007/10/19 11:43:26, 4, pid=3088612]
smbd/trans2.c:call_trans2findfirst(1448)
dptr_num is 256, wcard = a0348477 at CA7OLRB8.txt, attr = 22
[2007/10/19 11:43:26, 5, pid=3088612]
smbd/trans2.c:get_lanman2_dir_entry(973)
get_lanman2_dir_entry found pcr/Cookies/a0348477 at CA7OLRB8.txt
fname=a0348477 at CA7OLRB8.txt
[2007/10/19 11:43:26, 5, pid=3088612]
smbd/trans2.c:call_trans2findfirst(1499)
call_trans2findfirst - (2) closing dptr_num 256
[2007/10/19 11:43:26, 4, pid=3088612]
smbd/dir.c:dptr_close_internal(224)
closing dptr key 256
[2007/10/19 11:43:26, 4, pid=3088612]
smbd/trans2.c:call_trans2findfirst(1529)
SMBtrans2 mask=a0348477 at CA7OLRB8.txt directory=pcr/Cookies
dirtype=22 numentries=1
This shows a findfirst call with a name of
'pcr/Cookies/a0348477 at CA7OLRB8.txt'
that already exists. Unix_convert does a stat on the file and fills
in the
struct in sbuf. This information is completly ignored and findfirst
continues
with reading the whole directory and machting entries just to get the
(expected)
result that one file matches. In this case the directory contains
6000 files
(IE Cookies) making the search rather expensive and happening very
often.
I think, it would be worth to shortcut in this case by just returning
after
unix_convert and saying: found 1 file and it is the last one.
I am willing to try a patch as described if you think it useful. OTH
maybe
someone with better knowledge of samba internals should do it.
Thanks anyway.
Cheers
Heinrich
--
Heinrich Mislik
Zentraler Informatikdienst der Universitaet Wien
A-1010 Wien, Universitaetsstrasse 7
Tel.: (+43 1) 4277-14056, Fax: (+43 1) 4277-9140
More information about the samba-technical
mailing list