[Samba] Prevent read locks on shares

John Gardeniers jgardeniers at objectmastery.com
Wed Jan 27 23:47:51 UTC 2016


Thanks Jeremy but I don't understand why the lock is being applied at 
all when it's not being asked for.

Your advice to not disable locking if applications legitimately share 
file access to me seems to be the inverse of what is needed. After all, 
the fact that our application shares file access is the very reason we 
don't want file locking.

regards,
John


On 28/01/16 10:37, Jeremy Allison wrote:
> On Thu, Jan 28, 2016 at 09:25:20AM +1100, John Gardeniers wrote:
>> I really don't know if this is a Samba or Linux issue but after
>> migrating one of our file shares from a Samba 3 server to a Samba 4
>> server we discovered a problem that never existed before. On this
>> share we have a couple of ini files which is periodically read by a
>> Windows application on client machines. The problem appeared when
>> one of those files needed to be edited, which can happen several
>> times a day. The write failed with an error message stating that the
>> file was already opened by another user.
>>
>> Using lsof I discovered that there was a read lock on the file. Up
>> until yesterday I wasn't even aware of read locks, having never
>> encountered them before. Googling only turns up some old articles on
>> how locks can be implemented, but I can find nothing about
>> preventing them.
>>
>> The Windows application which reads the file simply opens it for
>> read access and doesn't do anything fancy at all. How is the read
>> lock applied? How can it be prevented? We have had to quickly switch
>> back to the old server until this can be resolved.
> Even on a read-only share a file open for read can
> have a read-lock set on it.
>
> It's mapped internally to a lock record, and can
> also be mapped to a POSIX fcntl lock.
>
> You can turn off file locking on a per-share
> basis by setting:
>
> locking = no
>
> in the [share] section of the smb.conf, but
> this is inadvisable if you have applications
> that legitimately share file access.
>




More information about the samba mailing list