From: Zhang Bingjun (Eddy) on
hi samba fellows,

It is my first time to ask questions in samba mail list. Very sorry if
my question is very naive.

The problem is when I write to
a non-existent file from windows to a linux export, there will be an
extra readdir operation triggered. If I write to an existent file, no
readdir operation will be triggered.

How could I avoid the extra readdir operation in all cases when I am just
writing to a file?

Very much appreciate your help!

I used samba
(3.4.0) to export a FUSE mount from Ubuntu with the following smb.cnf:

----------------------------------------------------------------
[global]
security = share
guest account = nobody

[mofs]
path = /mnt/mofs
public = yes
guest ok = yes
guest only = yes
guest account = nobody
writeable = yes
browseable = yes
----------------------------------------------------------------

From the FUSE debugging info, I can see an extra readdir operation is
there when writing to a non-existent file
(/test/wj9.txt). I highlighted all key OS file
operations in the FUSE debugging info below:

----------------------------------------------------------------------------------
unique: 22, opcode: GETATTR (3), nodeid: 1, insize: 56
*getattr /*
unique: 22, success, outsize: 120
unique: 23, opcode: LOOKUP (1), nodeid: 1, insize: 45
LOOKUP /test
*getattr /test*
NODEID: 2
unique: 23, success, outsize: 144
unique: 24, opcode: LOOKUP (1), nodeid: 2, insize: 48
LOOKUP /test/wj9.txt
*getattr /test/wj9.txt*
unique: 24, error: -2 (No such file or directory), outsize: 16
unique: 25, opcode: LOOKUP (1), nodeid: 2, insize: 48
LOOKUP /test/wj9.txt
*getattr /test/wj9.txt*
unique: 25, error: -2 (No such file or directory), outsize: 16
unique: 26, opcode: OPENDIR (27), nodeid: 2, insize: 48
unique: 26, success, outsize: 32
unique: 27, opcode: READDIR (28), nodeid: 2, insize: 80
*readdir[0] from 0*
unique: 27, success, outsize: 496
unique: 28, opcode: READDIR (28), nodeid: 2, insize: 80
unique: 28, success, outsize: 16
unique: 29, opcode: RELEASEDIR (29), nodeid: 2, insize: 64
unique: 29, success, outsize: 16
unique: 30, opcode: GETATTR (3), nodeid: 2, insize: 56
*getattr /test*
unique: 30, success, outsize: 120
unique: 31, opcode: LOOKUP (1), nodeid: 2, insize: 48
LOOKUP /test/wj9.txt
*getattr /test/wj9.txt*
unique: 31, error: -2 (No such file or directory), outsize: 16
unique: 32, opcode: LOOKUP (1), nodeid: 2, insize: 48
LOOKUP /test/wj9.txt
*getattr /test/wj9.txt*
unique: 32, error: -2 (No such file or directory), outsize: 16
unique: 33, opcode: LOOKUP (1), nodeid: 2, insize: 48
LOOKUP /test/wj9.txt
*getattr /test/wj9.txt*
unique: 33, error: -2 (No such file or directory), outsize: 16
unique: 34, opcode: CREATE (35), nodeid: 2, insize: 64
*create flags: 0x8042 /test/wj9.txt 0100744 umask=0000*
create[10570272] flags: 0x81e6 /test/wj9.txt
*getattr /test/wj9.txt*
NODEID: 7
unique: 34, success, outsize: 160
unique: 35, opcode: SETATTR (4), nodeid: 7, insize: 128
*truncate /test/wj9.txt 0*
*getattr /test/wj9.txt*
unique: 35, success, outsize: 120
unique: 36, opcode: GETATTR (3), nodeid: 2, insize: 56
*getattr /test*
unique: 36, success, outsize: 120
unique: 37, opcode: WRITE (16), nodeid: 7, insize: 112
*write[10570272] 32 bytes to 0 flags: 0xa002*
write[10570272] 32 bytes to 0
unique: 37, success, outsize: 24
unique: 38, opcode: WRITE (16), nodeid: 7, insize: 112
*write[10570272] 32 bytes to 32 flags: 0xa002*
write[10570272] 32 bytes to 32
unique: 38, success, outsize: 24
unique: 39, opcode: FLUSH (25), nodeid: 7, insize: 64
*flush[10570272]*
unique: 39, success, outsize: 16
unique: 40, opcode: RELEASE (18), nodeid: 7, insize: 64
*release[10570272] flags: 0x8002*
unique: 40, success, outsize: 16
unique: 41, opcode: GETATTR (3), nodeid: 7, insize: 56
*getattr /test/wj9.txt*
unique: 41, success, outsize: 120
unique: 42, opcode: SETATTR (4), nodeid: 7, insize: 128
utimens /test/wj9.txt 1000000000.000000000 1273643329.801998000
*getattr /test/wj9.txt*
unique: 42, success, outsize: 120
----------------------------------------------------------------------------------

However, if I write to an existent file
(/test/wj12.txt), there is no readdir operation. I highlighted all key OS
file operations in the FUSE debugging info below:

----------------------------------------------------------------------------------
unique: 5, opcode: GETATTR (3), nodeid: 1, insize: 56
*getattr /*
unique: 5, success, outsize: 120
unique: 6, opcode: LOOKUP (1), nodeid: 1, insize: 45
LOOKUP /test
*getattr /test*
NODEID: 2
unique: 6, success, outsize: 144
unique: 7, opcode: LOOKUP (1), nodeid: 2, insize: 49
LOOKUP /test/wj12.txt
*getattr /test/wj12.txt*
NODEID: 3
unique: 7, success, outsize: 144
unique: 8, opcode: OPEN (14), nodeid: 3, insize: 48
*open flags: 0x8002 /test/wj12.txt*
open[16502720] flags: 0x8002 /test/wj12.txt
unique: 8, success, outsize: 32
unique: 9, opcode: SETATTR (4), nodeid: 3, insize: 128
*truncate /test/wj12.txt 0*
*getattr /test/wj12.txt*
unique: 9, success, outsize: 120
unique: 10, opcode: GETXATTR (22), nodeid: 3, insize: 72
unique: 10, error: -38 (Function not implemented), outsize: 16
unique: 11, opcode: WRITE (16), nodeid: 3, insize: 112
*write[16502720] 32 bytes to 0 flags: 0x8002*
write[16502720] 32 bytes to 0
unique: 11, success, outsize: 24
unique: 12, opcode: WRITE (16), nodeid: 3, insize: 112
*write[16502720] 32 bytes to 32 flags: 0x8002*
write[16502720] 32 bytes to 32
unique: 12, success, outsize: 24
unique: 13, opcode: FLUSH (25), nodeid: 3, insize: 64
*flush[16502720]*
unique: 13, success, outsize: 16
unique: 14, opcode: RELEASE (18), nodeid: 3, insize: 64
*release[16502720] flags: 0x8002*
unique: 14, success, outsize: 16
unique: 15, opcode: GETATTR (3), nodeid: 3, insize: 56
*getattr /test/wj12.txt*
unique: 15, success, outsize: 120
unique: 16, opcode: SETATTR (4), nodeid: 3, insize: 128
utimens /test/wj12.txt 1000000000.000000000 1273651911.055820000
*getattr /test/wj12.txt*
unique: 16, success, outsize: 120
----------------------------------------------------------------------------------

Thanks!

Best regards,
Zhang Bingjun, Eddy
--
To unsubscribe from this list go to the following URL and read the
instructions: https://lists.samba.org/mailman/options/samba