[Samba] File locking problems - disable oplocks?

Andrew Martin amartin at xes-inc.com
Thu Jan 30 08:16:48 MST 2014

Hello,

I am running a Samba 3.6.3 fileserver on Ubuntu 12.04. It is joined to a Samba 4 Active Directory domain for user authentication. I have shares configured as follows:
[MyShare]
path = /path/to/MyShare
browseable = yes
public = yes
guest ok = yes
writable = yes
printable = no
create mode = 0664
force create mode = 0660
directory mode = 0775
force directory mode = 0660
veto oplock files = /*mgc*/
dos filetimes = yes
force group = "domain users"

Most clients access the share via network drives in Windows 7, however a few access it over NFS via other Linux servers. I have disabled thumbs.db thumbnail caching on the Windows 7 clients via Group Policy.

The Windows 7 clients will create a file (typically a PDF), open it, and then try to delete or overwrite it with a new version. Intermittently, this operation will fail with Windows reporting that the file is still in use. Or, if they do delete it, it appears to be gone until they navigate away from the folder and then back into it, in which case the file reappears. During this period while the file is "locked", the server reports the following:
1291         10089      DENY_WRITE 0x20089     RDONLY     NONE             /path/to/MyShare   path/to/the/document.pdf   Wed Jan 29 11:59:15 2014

If the user attempts to remove the file using smbclient instead of Windows Explorer, it also fails:
smb: \path\to\the\> rm document.pdf
NT_STATUS_SHARING_VIOLATION deleting remote file \path\to\the\document.pdf
NT_STATUS_SHARING_VIOLATION listing \path\to\the\document.pdf

Waiting a period of time (maybe around 30 minutes) releases the lock and the file allowed to be written to. Reading through the Samba documentation about locking (http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/locking.html), it seems like disabling oplocks on the share would be advisable in this situation? Are there any potential problems/side effects that disabling oplocks would cause? How would this work with a future upgrade to Samba 4.x, where SMB2 or SMB3 could be used but my understanding is these newer protocols don't allow you to disable oplocking?

Thanks,

Andrew