[Samba] What's Happening
ken at lt.com
Sun May 26 04:21:02 GMT 2002
Urban Widmark wrote:
> On Fri, 24 May 2002, Kenneth Loafman wrote:
> > I misspoke when I said file locking. The locking is via a guard file
> > created with "open(guard, O_WRONLY | O_CREAT | O_EXCL, 0644)", which
> > should protect against other processes opening it once it has been
> > created. It appears that is not working either.
> My open manpage has the following:
> "O_EXCL is broken on NFS file systems, programs which rely on it for
> performing locking tasks will contain a race condition."
> Perhaps the same applies to smbfs. I don't know why it doesn't work, if in
> fact this is what doesn't work.
It appears that smbfs has the same problem.
> You could try using a directory instead of a file as guard, but if all
> processes that you need locking between are on the same linux machine you
> could just put it locally.
Never thought of a directory. Thanks. Locally is not possible since
there are multiple SMP machines going after the jobqueue. I'm thinking
now of a scheduler task that would perform locking for the entire
complex. Problem there is the single point of failure implied.
> Note that my comment regarding locking has nothing to do with the error
> messages you saw which are network related, except possibly the -26 error.
> And that is simply a verbose way of saying that the file open failed.
I'm sure some problems are network related. I need to find a way to
turn on timestamps so we can correlate activities across machines.
> One thing to note is that when a connection is lost the smb server closes
> any files you had open. After smbfs reconnects it also starts to reopen
> files behind your back as you access them, but that leaves a hole where
> someone else could open the file.
The guard file, if existing, keeps any other job away from the job. The
problem is that there has to be a lock to keep multiple jobs from
creating the file simultaneously.
> > If locking does not work, and guard files don't work, how does one
> > maintain a queue via Samba? Are there any papers on the subject? Do I
> > need to put the guard files on an NFS mounted FS on a Linux box? I seem
> > to recall that NFS has locking problems as well.
> Note that samba is not involved in this, please use the word smbfs. The
> only samba parts that are used are the ones that connect to a server and
> they do not deserve any blame.
OK. So smbfs is part of another project?
> smbfs works fine for many simpler tasks, single user accessing files,
> running programs from a central server, remote edits. But people seem to
> run into various limitations when they want to do more advanced things.
There are provisions for locks in Samba. I did not want to try to map
MS and Linux file locking, so I tried file creation which is normally
atomic. I'll give directory creation a try next, and see if that works
better. All I need to solve this problem is one known atomic action
that can be performed from Linux to a Win 2K filesystem.
More information about the samba