[Samba] Samba client file locking

Jeremy Allison jra at samba.org
Mon May 22 21:23:42 GMT 2006

On Mon, May 22, 2006 at 04:13:18PM +1000, Matthias Reif wrote:
> Hello,
> I am trying to work out the file locking mechanism on our Samba server when
> connecting from Linux clients. I am getting some strange behaviour in a
> mixed Linux/Windows environment when multiple clients open/lock the same
> file for writing. Everything seems fine when a Windows client creates the
> lock, but if a Linux client creates the lock, we get either two or more
> Linux clients being able to open the same file for writing (SMBFS) or the

I don't think smbfs implements locking at all.

> other extreme, if one Linux client opens the file none of the others can't
> even open it in read-only mode (CIFS). The main application used on the
> network is OpenOffice2.

Currently CIFSFS probably maps the posix write lock into a CIFS
exclusive lock - which would prevent any other client from issuing
a read over that area. 3.0.23 might help here as it supports on
the wire POSIX locking (experimental mode - not currently mapped
into an underlying filesystem lock).

> I noticed that depending on the client I use Samba creates a different kind
> of lock with different behaviour when multiple clients attempt to open the
> same file. Neither smbfs nor cifs create the correct lock share mode
> (DENY_WRITE) and the access mode is different (smbfs:0x3, cifs:0x12019f as
> opposed to Windows: 0x2019f)

You're confusing deny modes with locks. They are not the same thing.
Are you talking about locks or deny modes here ?


More information about the samba mailing list