[Samba] stat(2) cache, samba3 versus samba4

Martin Cracauer cracauer at cons.org
Fri Jan 5 14:02:06 UTC 2018

Short version:

Is there a way to enforce use of this cache:
I noticed it is absent from the ./source4 directory

I limited 
  server max protocol = SMB2
but that didn't do it.

Long story:

My samba server (4.2.14) hosts a couple of game install trees for a 
Windows 7 computer.

Some of the games cause storms of stat(2) system calls, here is a
partial strace:

newfstatat(35, "i50145t.bmp", {st_mode=S_IFREG|0664, st_size=35344, ...}, 0) = 0
newfstatat(35, "i01014o.BMP", {st_mode=S_IFREG|0664, st_size=21536, ...}, 0) = 0
newfstatat(35, "i50027g.bmp", {st_mode=S_IFREG|0664, st_size=28416, ...}, 0) = 0
newfstatat(35, "i02017g.BMP", {st_mode=S_IFREG|0664, st_size=11584, ...}, 0) = 0
newfstatat(35, "i99509o.bmp", {st_mode=S_IFREG|0664, st_size=73080, ...}, 0) = 0

Depending on the game they either slow down during startup due to
stat(2)ing all their files (toaw4), or the game becomes unusable
because checks continue during gameplay (some older versions of DSC
flight sims).  There are a lot more calls than needed to actually load
the game.  Whatever the reason for all these checks for changed files
is, they expect them to be "cheap" because they would come out the FS
buffer cache of the local OS if it wasn't a network drive.

Is there a way to cause the cache to be used for a specific client, or
a specific share?

To clarify, I know it will still be slow since instead of locally
cached system calls into the Windows kernel it will still have a
network turnaround.  However, right now I am doing actual system calls
on the server side, and exchanging those for pure userland replies
will help.

I also know iSCSI would help but it's a pain.

Thank you
Martin Cracauer <cracauer at cons.org>   http://www.cons.org/cracauer/

More information about the samba mailing list