Disable oplocks in a heterogeneous Samba / NFS environment

logo-samba-150x150

Opportunistic locking is part of the Windows client file caching mechanism. It is not a robust or reliable feature when implemented on the variety of customized networks that exist in enterprise computing. Oplocking as opposed to poplocking essentially means that the client is allowed to download and cache a file on their local storage while making changes and if another client wants to access the file, the first client receives a break and must synchronize the file back to the server. This can give significant performance gains, up to 30% in optimal conditions.

Samba/CIFS doesn’t play nice with NFS, so if you’re in a mixed environment where some windows machines access and modify the same files that Linux or Solaris touch through NFS, then disable the oplocks. This is important for things like database files to avoid corruption! However, if you export samba shares as read-only, then opportunistic locking shouldn’t be a problem. Works for me, but YMMV.

You can disable oplocks for entire shares

Or globally like this, and it will disable level2 oplocks too

[global]
   oplocks = False

Or you can just disable level 2 oplocks:

level2 oplocks can only be enabled if oplocks are enabled.

[ps3]
    level2 oplocks = False

But how do you disable oplocks for specific files, directories, or regular expressions?

[borderlands]
   veto oplock files = path/file*.txt
   veto oplock files = www
   veto oplock files = *.mdb

Samba implements opportunistic locking as a server-side component of the client caching mechanism. Because of the lightweight nature of the windows feature design, effective configuration of opportunistic locking requires a good understanding of its limitations, and then applying that understanding when configuring data access for each particular customized network and client usage state.

See http://oreilly.com/catalog/samba/chapter/book/ch05_05.html for more info.

There are three types of oplocks:

Level1 oplocks is another term for opportunistic locking.

Level2 oplocks provides opportunistic locking for a file that will be treated as read only. Typically this is used on files that are read-only or on files that the client has no initial intention to write to at time of opening the file.

Kernel oplocks are essentially a method that allows the Linux kernel to co-exist with Samba’s oplocked files

Posted by admica   @   21 October 2009

Related Posts

0 Comments

No comments yet. Be the first to leave a comment !
Leave a Comment

Name

Email

Website

Previous Post
« How to debug wxPython errors when your applications crash
Next Post
How to restore a postgresql database from dumpall backup »
Powered by Wordpress   |   Lunated designed by ZenVerse