[Samba] "Text file busy" inconsistent problem with newly created files: bug?

Greg Ercolano erco at 3dsite.com
Wed Oct 6 06:49:47 GMT 2004


I have noticed an inconsistency with the behavior of linux smbfs
mounting a remote win2k server while a file is open for writing:

    1) If a linux process opens a file that /doesn't exist/ on the
       win2k server, while the file is open, other machines trying
       to read the file give the usual 'Text file is busy' (linux) or
       'file is in use by another process' (windows).

    2) However, if a linux process opens a file that /does/ exist,
       other machines can read the file just fine while it is open,
       both linux and windows print the file's contents just fine.

It seems like a bug; why should it matter if the file exists or not?

If intentional, how can a unix program (or mount flags?) control
opening the windows file in such a way that the file is /always/
readable by other machines, without ever giving 'text file busy'
errors. Basically, I need behavior #2 above consistently.

VERSIONS
--------
     Client is Redhat 9.0, running the default samba 2.2.7a-6.
     The file server is Windows 2000.

     I was able to confirm this behavior at a separate location,
     where they are running redhat 9.0 with the latest Samba 3.x.x installed,
     and I think they have a Windows 2003 server.

REPLICATION
-----------
     The problem is replicated in the following screen history, using
     a 'ping' command to hold the file open while other machines try
     to read its log output.

     Note that the *second* run of the 'ping' command is readable by
     the other machines, while the first is not.

	'win2k'  is the remote win2k file server.
	'linux1' is the local linux machine,  win2k mounted as /win2k/c
	'linux2' is the remote linux machine, win2k mounted as /win2k/c

------------------------------------------------------------------------- snip
[root at linux1] $ grep smbfs /etc/fstab                    <-- SHOW HOW LOCALHOST
                                                              MOUNTS THE WIN2K SERVER
//win2k/c  /win2k/c  smbfs   noauto,uid=500,gid=500,dmask=775,fmask=775 0 0

[root at linux1] $ mount | grep win2k                       <-- SHOW MOUNT
//win2k/c on /win2k/c type smbfs (0)

[root at linux1] $ rm /win2k/c/foo.log                      <-- MAKE SURE LOG FILE DOESNT EXIST
[root at linux1] $ ping localhost >& /win2k/c/foo.log &     <-- REDIRECT A 'SLOW' PROGRAM TO LOG
[1] 5778

[root at linux1] $ rsh linux2 cat /win2k/c/foo.log          <-- REMOTE LINUX CAN'T READ FILE
cat: /win2k/c/foo.log: Text file busy

[root at linux1] $ rsh win2k 'type c:\foo.log'              <-- WIN2K SERVER CAN'T READ FILE
The process cannot access the file because it is being used by another process.

[root at linux1] $ kill %%                                  <-- KILL THE PROCESS, CLOSING LOG
[1]  + Terminated                    ping localhost >& /win2k/c/foo.log

[root at linux1] $ ls -la /win2k/c/foo.log                  <-- VERIFY LOG FILE NOW EXISTS
-rwxrwxr-x    1 foo      foo        14534 Oct  5 23:26 /win2k/c/foo.log

[root at linux1] $ ping localhost >& /win2k/c/foo.log &     <-- RUN *SAME* COMMAND AGAIN
[1] 6397                                                 <-- (Only difference: file exists)

[root at linux1] $ rsh linux2 cat /win2k/c/foo.log          <-- REMOTE LINUX READS OK
PING localhost.erco.x (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost.erco.x (127.0.0.1): icmp_seq=1 ttl=64 time=0.030 ms
64 bytes from localhost.erco.x (127.0.0.1): icmp_seq=2 ttl=64 time=0.030 ms
64 bytes from localhost.erco.x (127.0.0.1): icmp_seq=3 ttl=64 time=0.035 ms
[..]

[root at linux1] $ rsh win2k 'type c:\foo.log'              <-- WIN2K SERVER READS OK
PING localhost.erco.x (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost.erco.x (127.0.0.1): icmp_seq=1 ttl=64 time=0.030 ms
64 bytes from localhost.erco.x (127.0.0.1): icmp_seq=2 ttl=64 time=0.030 ms
64 bytes from localhost.erco.x (127.0.0.1): icmp_seq=3 ttl=64 time=0.035 ms
[..]
------------------------------------------------------------------------- snip



More information about the samba mailing list