1<HTML> 2<HEAD> 3<TITLE> 4[Chapter 5] 5.5 Locks and Oplocks</title><META NAME="DC.title" CONTENT=""><META NAME="DC.creator" CONTENT=""><META NAME="DC.publisher" CONTENT="O'Reilly & Associates, Inc."><META NAME="DC.date" CONTENT="1999-11-05T21:33:03Z"><META NAME="DC.type" CONTENT="Text.Monograph"><META NAME="DC.format" CONTENT="text/html" SCHEME="MIME"><META NAME="DC.source" CONTENT="" SCHEME="ISBN"><META NAME="DC.language" CONTENT="en-US"><META NAME="generator" CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"></head> 5<BODY BGCOLOR="#FFFFFF" TEXT="#000000" link="#990000" vlink="#0000CC"> 6<table BORDER="0" CELLPADDING="0" CELLSPACING="0" width="90%"> 7<tr> 8<td width="25%" valign="TOP"> 9<img hspace=10 vspace=10 src="gifs/samba.s.gif" 10alt="Using Samba" align=left valign=top border=0> 11</td> 12<td height="105" valign="TOP"> 13<br> 14<H2>Using Samba</H2> 15<font size="-1"> 16Robert Eckstein, David Collier-Brown, Peter Kelly 17<br>1st Edition November 1999 18<br>1-56592-449-5, Order Number: 4495 19<br>416 pages, $34.95 20</font> 21<p> <a href="http://www.oreilly.com/catalog/samba/">Buy the hardcopy</a> 22<p><a href="index.html">Table of Contents</a> 23</td> 24</tr> 25</table> 26<hr size=1 noshade> 27<!--sample chapter begins --> 28 29<center> 30<DIV CLASS="htmlnav"> 31<TABLE WIDTH="515" BORDER="0" CELLSPACING="0" CELLPADDING="0"> 32<TR> 33<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 34<A CLASS="sect1" HREF="ch05_04.html" TITLE="5.4 Name Mangling and Case"> 35<IMG SRC="gifs/txtpreva.gif" ALT="Previous: 5.4 Name Mangling and Case" BORDER="0"></a></td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 36<B> 37<FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1"> 38<A CLASS="chapter" REL="up" HREF="ch05_01.html" TITLE="5. Browsing and Advanced Disk Shares "> 39Chapter 5<br> 40Browsing and Advanced Disk Shares </a></font></b></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 41<A CLASS="chapter" HREF="ch06_01.html" TITLE="6. Users, Security, and Domains "> 42<IMG SRC="gifs/txtnexta.gif" ALT="Next: 6. Users, Security, and Domains " BORDER="0"></a></td></tr></table> <hr noshade size=1></center> 43</div> 44<blockquote> 45<div> 46<H2 CLASS="sect1"> 47<A CLASS="title" NAME="ch05-75933"> 485.5 Locks and Oplocks</a></h2><P CLASS="para">Concurrent writes to a single file are not desirable in any operating system. To prevent this, most operating systems use <I CLASS="firstterm"> 49locks</i> to guarantee that only one process can write to a file at a time. Operating systems traditionally lock entire files, although newer ones allow a range of bytes within a file to be locked. If another process attempts to write to a file (or section of one) that is already locked, it will receive an error from the operating system and will wait until the lock is released.</p><P CLASS="para"> 50Samba supports the standard DOS and NT filesystem (deny-mode) locking requests, which allow only one process to write to an entire file on a server at a give time, as well as byte-range locking. In addition, Samba supports a new locking mechanism known in the Windows NT world as <I CLASS="firstterm"> 51opportunistic locking - </i><EM CLASS="emphasis"> 52oplock</em> for short.</p><DIV CLASS="sect2"> 53<H3 CLASS="sect2"> 54<A CLASS="title" NAME="ch05-pgfId-964663"> 555.5.1 Opportunistic Locking</a></h3><P CLASS="para"> 56Opportunistic locking allows a client to notify the Samba server that it will not only be the exclusive writer of a file, but will also cache its changes to that file on its own machine (and not on the Samba server) in order to speed up file access for that client. When Samba knows that a file has been opportunistically locked by a client, it marks its version as having an opportunistic lock and waits for the client to complete work on the file, at which point it expects the client to send the final changes back to the Samba server for synchronization.</p><P CLASS="para"> 57If a second client requests access to that file before the first client has finished working on it, Samba can send an <I CLASS="firstterm"> 58oplock break</i> request to the first client. This tells the client to stop caching its changes and return the current state of the file to the server so that the interrupting client can use it as it sees fit. An opportunistic lock, however, is not a replacement for a standard deny-mode lock. It is not unheard of for the interrupting process to be granted an oplock break only to discover that the original process also has a deny-mode lock on a file as well. <A CLASS="xref" HREF="ch05_05.html#ch05-74304"> 59Figure 5.8</a> illustrates this opportunistic locking process. </p><H4 CLASS="figure"> 60<A CLASS="title" NAME="ch05-74304"> 61Figure 5.8: Opportunistic locking</a></h4><IMG CLASS="graphic" SRC="figs/sam.0508.gif" ALT="Figure 5.8"><P CLASS="para"> 62In terms of locks, we highly recommend using the defaults provided by Samba: standard DOS/Windows deny-mode locks for compatibility and oplocks for the extra performance that local caching allows. If your operating system can take advantage of oplocks, it should provide significant performance improvements. Unless you have a specific reason for changing any of these options, it's best to leave them as they are.</p></div><DIV CLASS="sect2"> 63<H3 CLASS="sect2"> 64<A CLASS="title" NAME="ch05-pgfId-969392"> 655.5.2 Unix and Locking</a></h3><P CLASS="para">Windows systems cooperate well to avoid overwriting each other's changes. But if a file stored on a Samba system is accessed by a Unix process, this process won't know a thing about Windows oplocks and could easily ride roughshod over a lock. Some Unix systems have been enhanced to understand the Windows oplocks maintained by Samba. Currently the support exists only in SGI Irix 6.5.2f and later; Linux and FreeBSD should soon follow.</p><P CLASS="para"> 66If you have a system that understands oplocks, set <CODE CLASS="literal"> 67kernel</code> <CODE CLASS="literal"> 68oplocks</code> <CODE CLASS="literal"> 69=</code> <CODE CLASS="literal"> 70yes</code> in the Samba configuration file. That should eliminate conflicts between Unix processes and Windows users. </p><P CLASS="para"> 71If your system does not support kernel oplocks, you could end up with corrupted data when somebody runs a Unix process that reads or writes a file that Windows users also access. However, Samba provides a rough protection mechanism in the absence of kernel oplocks: the <CODE CLASS="literal"> 72veto</code> <CODE CLASS="literal"> 73oplock</code> <CODE CLASS="literal"> 74files</code> option. If you can anticipate which Samba files are used by both Windows users and Unix users, set their names in a <CODE CLASS="literal"> 75veto</code> <CODE CLASS="literal"> 76oplock</code> <CODE CLASS="literal"> 77files</code> option. This will suppress the use of oplocks on matching filenames, which will supress client caching, and let the Windows and Unix programs use system locking or update times to detect competition for the same file. A sample option is: </p><PRE CLASS="programlisting"> 78veto oplock files = /*.dbm/</pre><P CLASS="para"> 79This option allows both Unix processes and Windows users to edit files ending in the suffix <EM CLASS="emphasis"> 80.dbm</em>. Note that the syntax of this option is similar to <CODE CLASS="literal"> 81veto</code> <CODE CLASS="literal"> 82files</code>.</p><P CLASS="para"> 83Samba's options for locks and oplocks are given in <A CLASS="xref" HREF="ch05_05.html#ch05-53407"> 84Table 5.8</a>. </p><br> 85<TABLE CLASS="table" BORDER="1" CELLPADDING="3"> 86<CAPTION CLASS="table"> 87<A CLASS="title" NAME="ch05-53407"> 88Table 5.8: Locks and Oplocks Configuration Options </a></caption><THEAD CLASS="thead"> 89<TR CLASS="row" VALIGN="TOP"> 90<TH CLASS="entry" ALIGN="LEFT" ROWSPAN="1" COLSPAN="1"> 91<P CLASS="para"> 92Option</p></th><TH CLASS="entry" ALIGN="LEFT" ROWSPAN="1" COLSPAN="1"> 93<P CLASS="para"> 94Parameters</p></th><TH CLASS="entry" ALIGN="LEFT" ROWSPAN="1" COLSPAN="1"> 95<P CLASS="para"> 96Function</p></th><TH CLASS="entry" ALIGN="LEFT" ROWSPAN="1" COLSPAN="1"> 97<P CLASS="para"> 98Default</p></th><TH CLASS="entry" ALIGN="LEFT" ROWSPAN="1" COLSPAN="1"> 99<P CLASS="para"> 100Scope</p></th></tr></thead><TBODY CLASS="tbody"> 101<TR CLASS="row" VALIGN="TOP"> 102<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 103<P CLASS="para"> 104<CODE CLASS="literal"> 105share modes</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 106<P CLASS="para">boolean</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 107<P CLASS="para"> 108If set to <CODE CLASS="literal"> 109yes</code>, turns on support for DOS-style whole-file locks.</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 110<P CLASS="para"> 111<CODE CLASS="literal"> 112yes</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 113<P CLASS="para"> 114Share</p></td></tr><TR CLASS="row" VALIGN="TOP"> 115<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 116<P CLASS="para"> 117<CODE CLASS="literal"> 118locking</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 119<P CLASS="para"> 120boolean</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 121<P CLASS="para"> 122If <CODE CLASS="literal"> 123yes</code>, turns on byte-range locks.</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 124<P CLASS="para"> 125<CODE CLASS="literal"> 126yes</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 127<P CLASS="para"> 128Share</p></td></tr><TR CLASS="row" VALIGN="TOP"> 129<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 130<P CLASS="para"> 131<CODE CLASS="literal"> 132strict locking</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 133<P CLASS="para"> 134boolean</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 135<P CLASS="para"> 136If <CODE CLASS="literal"> 137yes</code>, denies access to an entire file if a byte-range lock exists in it.</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 138<P CLASS="para"> 139<CODE CLASS="literal"> 140no</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 141<P CLASS="para"> 142Share</p></td></tr><TR CLASS="row" VALIGN="TOP"> 143<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 144<P CLASS="para"> 145<CODE CLASS="literal"> 146oplocks</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 147<P CLASS="para"> 148boolean</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 149<P CLASS="para"> 150If <CODE CLASS="literal"> 151yes</code>, turn on local caching of files on the client for this share.</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 152<P CLASS="para"> 153<CODE CLASS="literal"> 154yes</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 155<P CLASS="para"> 156Share</p></td></tr><TR CLASS="row" VALIGN="TOP"> 157<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 158<P CLASS="para"> 159<CODE CLASS="literal"> 160kernel oplocks</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 161<P CLASS="para"> 162boolean</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 163<P CLASS="para"> 164If <CODE CLASS="literal"> 165yes</code>, indicates that the kernel supports oplocks.</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 166<P CLASS="para"> 167<CODE CLASS="literal"> 168yes</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 169<P CLASS="para"> 170Global</p></td></tr><TR CLASS="row" VALIGN="TOP"> 171<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 172<P CLASS="para"> 173<CODE CLASS="literal"> 174fake oplocks</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 175<P CLASS="para"> 176boolean</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 177<P CLASS="para"> 178If <CODE CLASS="literal"> 179yes</code>, tells client the lock was obtained, but doesn't actually lock it.</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 180<P CLASS="para"> 181<CODE CLASS="literal"> 182no</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 183<P CLASS="para"> 184Share</p></td></tr><TR CLASS="row" VALIGN="TOP"> 185<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 186<P CLASS="para"> 187<CODE CLASS="literal"> 188blocking locks </code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 189<P CLASS="para"> 190boolean</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 191<P CLASS="para"> 192Allows lock requestor to wait for the lock to be granted.</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 193<P CLASS="para"> 194<CODE CLASS="literal"> 195yes</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 196<P CLASS="para"> 197Share</p></td></tr><TR CLASS="row" VALIGN="TOP"> 198<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 199<P CLASS="para"> 200<CODE CLASS="literal"> 201veto oplock files</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 202<P CLASS="para"> 203string (list of filenames)</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 204<P CLASS="para"> 205Does not oplock specified files.</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 206<P CLASS="para"> 207None</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 208<P CLASS="para"> 209Share</p></td></tr><TR CLASS="row" VALIGN="TOP"> 210<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 211<P CLASS="para"> 212<CODE CLASS="literal"> 213lock directory</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 214<P CLASS="para"> 215string (fully-qualified pathname)</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 216<P CLASS="para"> 217Sets the location where various Samba files, including locks, are stored.</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 218<P CLASS="para"> 219As specified in Samba makefile</p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 220<P CLASS="para"> 221Global</p></td></tr></tbody></table><DIV CLASS="sect3"> 222<H4 CLASS="sect3"> 223<A CLASS="title" NAME="ch05-pgfId-958552"> 2245.5.2.1 share modes</a></h4><P CLASS="para"> 225The most primitive locks available to Samba are deny-mode locks, known as <I CLASS="firstterm"> 226share modes</i>, which are employed by programs such as text editors to avoid accidental overwriting of files. For reference, the deny-mode locks are listed in <A CLASS="xref" HREF="ch05_05.html#ch05-55885"> 227Table 5.9</a>. </p><br> 228<TABLE CLASS="table" BORDER="1" CELLPADDING="3"> 229<CAPTION CLASS="table"> 230<A CLASS="title" NAME="ch05-55885"> 231Table 5.9: SMB Deny-Mode Locks </a></caption><THEAD CLASS="thead"> 232<TR CLASS="row" VALIGN="TOP"> 233<TH CLASS="entry" ALIGN="LEFT" ROWSPAN="1" COLSPAN="1"> 234<P CLASS="para"> 235Lock</p></th><TH CLASS="entry" ALIGN="LEFT" ROWSPAN="1" COLSPAN="1"> 236<P CLASS="para"> 237Description</p></th></tr></thead><TBODY CLASS="tbody"> 238<TR CLASS="row" VALIGN="TOP"> 239<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 240<P CLASS="para"> 241<CODE CLASS="literal"> 242DENY_NONE</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 243<P CLASS="para"> 244Do not deny any other file requests.</p></td></tr><TR CLASS="row" VALIGN="TOP"> 245<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 246<P CLASS="para"> 247<CODE CLASS="literal"> 248DENY_ALL</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 249<P CLASS="para"> 250Deny all open requests on the current file.</p></td></tr><TR CLASS="row" VALIGN="TOP"> 251<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 252<P CLASS="para"> 253<CODE CLASS="literal"> 254DENY_READ</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 255<P CLASS="para"> 256Deny any read-only open requests on the current file.</p></td></tr><TR CLASS="row" VALIGN="TOP"> 257<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 258<P CLASS="para"> 259<CODE CLASS="literal"> 260DENY_WRITE</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 261<P CLASS="para"> 262Deny any write-only open requests on the current file.</p></td></tr><TR CLASS="row" VALIGN="TOP"> 263<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 264<P CLASS="para"> 265<CODE CLASS="literal"> 266DENY_DOS</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 267<P CLASS="para"> 268If opened for reading, others can read but cannot write to the file. If opened for writing, others cannot open the file at all.</p></td></tr><TR CLASS="row" VALIGN="TOP"> 269<TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 270<P CLASS="para"> 271<CODE CLASS="literal"> 272DENY_FCB</code></p></td><TD CLASS="entry" ROWSPAN="1" COLSPAN="1"> 273<P CLASS="para"> 274Obsolete.</p></td></tr></tbody></table><P CLASS="para"> 275The <CODE CLASS="literal"> 276share</code> <CODE CLASS="literal"> 277modes</code> parameter, which enforces the use of these locks, is enabled by default. To disable it, use the following command:</p><PRE CLASS="programlisting"> 278[accounting] 279 share modes = no</pre><P CLASS="para"> 280We highly recommend against disabling the default locking mechanism unless you have a justifiable reason for doing so. Most Windows and DOS applications rely on these locking mechanisms in order to work correctly, and will complain bitterly if this functionality is taken away.</p></div><DIV CLASS="sect3"> 281<H4 CLASS="sect3"> 282<A CLASS="title" NAME="ch05-pgfId-958557"> 2835.5.2.2 locking</a></h4><P CLASS="para"> 284The <CODE CLASS="literal"> 285locking</code> option can be used to tell Samba to engage or disengage server-side byte-range locks on behalf of the client. Samba implements byte-range locks on the server side with normal Unix advisory locks and will consequently prevent other properly-behaved Unix processes from overwriting a locked byte range.</p><P CLASS="para"> 286This option can be specified per share as follows:</p><PRE CLASS="programlisting"> 287[accounting] 288 locking = yes</pre><P CLASS="para"> 289If the <CODE CLASS="literal"> 290locking</code> option is set to <CODE CLASS="literal"> 291yes</code>, the requestor will be delayed until the holder of either type of lock releases it (or crashes). If, however, the option is set to <CODE CLASS="literal"> 292no</code>, no byte-range locks will be kept for the files, although requests to lock and unlock files will appear to succeed. The option is set to <CODE CLASS="literal"> 293yes</code> by default; however, you can turn this option off if you have read-only media.</p></div><DIV CLASS="sect3"> 294<H4 CLASS="sect3"> 295<A CLASS="title" NAME="ch05-pgfId-959694"> 2965.5.2.3 strict locking</a></h4><P CLASS="para"> 297This option checks every file access for a byte-range lock on the range of bytes being accessed. This is typically not needed if a client adheres to all the locking mechanisms in place. This option is set to <CODE CLASS="literal"> 298no</code> by default; however, you can reset it per share as follows:</p><PRE CLASS="programlisting"> 299[accounting] 300 strict locking = yes</pre><P CLASS="para"> 301If this option is set to <CODE CLASS="literal"> 302yes</code>, mandatory locks are enforced on any file with byte-range locks.</p></div><DIV CLASS="sect3"> 303<H4 CLASS="sect3"> 304<A CLASS="title" NAME="ch05-pgfId-958563"> 3055.5.2.4 blocking locks</a></h4><P CLASS="para"> 306Samba also supports <I CLASS="firstterm"> 307blocking locks</i>, a minor variant of range locks. Here, if the range of bytes is not available, the client specifies an amount of time that it's willing to wait. The server then caches the lock request, periodically checking to see if the file is available. If it is, it notifies the client; however, if time expires, Samba will tell the client that the request has failed. This strategy prevents the client from continually polling to see if the lock is available.</p><P CLASS="para"> 308You can disable this option per share as follows:</p><PRE CLASS="programlisting"> 309[accounting] 310 blocking locks = no</pre><P CLASS="para"> 311When set to <CODE CLASS="literal"> 312yes</code>, blocking locks will be enforced on the file. If this option is set to <CODE CLASS="literal"> 313no</code>, Samba behaves as if normal locking mechanisms are in place on the file. The default is <CODE CLASS="literal"> 314yes</code>.</p></div><DIV CLASS="sect3"> 315<H4 CLASS="sect3"> 316<A CLASS="title" NAME="ch05-pgfId-958571"> 3175.5.2.5 oplocks</a></h4><P CLASS="para"> 318This option enables or disables support for oplocks on the client. The option is enabled by default. However, you can disable it with the following command:</p><PRE CLASS="programlisting"> 319[data] 320 oplocks = no</pre><P CLASS="para"> 321If you are in an extremely unstable network environment or have many clients that cannot take advantage of opportunistic locking, it may be better to shut this Samba feature off. Oplocks should be disabled if you are accessing the same files from both Unix applications (such as <EM CLASS="emphasis"> 322vi</em>) and SMB clients (unless you are lucky enough to have an operating system that supports kernel oplocks as discussed earlier).</p></div><DIV CLASS="sect3"> 323<H4 CLASS="sect3"> 324<A CLASS="title" NAME="ch05-pgfId-958575"> 3255.5.2.6 fake oplocks</a></h4><P CLASS="para"> 326Before opportunistic locking was available on Samba, the Samba daemons pretended to allow oplocks via the <CODE CLASS="literal"> 327fake</code> <CODE CLASS="literal"> 328oplocks</code> option. If this option was enabled, all clients were told that the file is available for opportunistic locking, and never warned of simultaneous access. This option is deprecated now that real oplocks are available on Samba.</p></div><DIV CLASS="sect3"> 329<H4 CLASS="sect3"> 330<A CLASS="title" NAME="ch05-pgfId-958577"> 3315.5.2.7 kernel oplocks</a></h4><P CLASS="para"> 332If a Unix application separate from Samba tries to update a file that Samba has oplocked to a Windows client, it will likely succeed (depending on the operating system) and both Samba and the client will never be aware of it. However, if the local Unix operating system supports it, Samba can warn it of oplocked files, which can suspend the Unix process, notify the client via Samba to write its copy back, and only then allow the open to complete. Essentially, this means that the operating system kernel on the Samba system has the ability to handle oplocks as well as Samba.</p><P CLASS="para"> 333You can enable this behavior with the <CODE CLASS="literal"> 334kernel</code> <CODE CLASS="literal"> 335oplocks</code> option, as follows:</p><PRE CLASS="programlisting"> 336[global] 337 kernel oplocks = yes</pre><P CLASS="para"> 338Samba can automatically detect kernel oplocks and use them if present. At the time of this writing, this feature is supported only by SGI Irix 6.5.2f and later. However, Linux and FreeBSD support are expected in the near future. A system without kernel oplocks will allow the Unix process to update the file, but the client programs will notice the change only at a later time, if at all. </p></div><DIV CLASS="sect3"> 339<H4 CLASS="sect3"> 340<A CLASS="title" NAME="ch05-pgfId-958581"> 3415.5.2.8 veto oplock files</a></h4><P CLASS="para"> 342You can provide a list of filenames that are never granted opportunistic locks with the <CODE CLASS="literal"> 343veto</code> <CODE CLASS="literal"> 344oplock</code> <CODE CLASS="literal"> 345files</code> option. This option can be set either globally or on a per-share basis. For example:</p><PRE CLASS="programlisting"> 346veto oplock files = /*.bat/*.htm/</pre><P CLASS="para"> 347The value of this option is a series of patterns. Each pattern entry must begin, end, or be separated from another with a slash (/) character, even if there is only one pattern listed. Asterisks can be used as a wildcard to represent zero or more characters. Questions marks can be used to represent exactly one character.</p><P CLASS="para"> 348We recommend that you disable oplocks on any files that are meant to be updated by Unix or are intended to be shared by several processes simultaneously.</p></div><DIV CLASS="sect3"> 349<H4 CLASS="sect3"> 350<A CLASS="title" NAME="ch05-pgfId-960237"> 3515.5.2.9 lock directory</a></h4><P CLASS="para"> 352This option (sometimes called <CODE CLASS="literal"> 353lock</code> <CODE CLASS="literal"> 354dir</code>) specifies the location of a directory where Samba will store SMB deny-mode lock files. Samba stores other files in this directory as well, such as browse lists and its shared memory file. If WINS is enabled, the WINS database is written to this directory as well. The default for this option is specified in the Samba makefile; it is typically <I CLASS="filename"> 355/usr/local/samba/var/locks</i>. You can override this location as follows:</p><PRE CLASS="programlisting"> 356[global] 357 lock directory = /usr/local/samba/locks</pre><P CLASS="para"> 358You typically would not need to override this option, unless you want to move the lock files to a more standardized location, such as <I CLASS="filename"> 359/var/spool/locks</i>. </p></div></div></div></blockquote> 360<div> 361<center> 362<hr noshade size=1><TABLE WIDTH="515" BORDER="0" CELLSPACING="0" CELLPADDING="0"> 363<TR> 364<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 365<A CLASS="sect1" HREF="ch05_04.html" TITLE="5.4 Name Mangling and Case"> 366<IMG SRC="gifs/txtpreva.gif" ALT="Previous: 5.4 Name Mangling and Case" BORDER="0"></a></td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 367<A CLASS="book" HREF="index.html" TITLE=""> 368<IMG SRC="gifs/txthome.gif" ALT="" BORDER="0"></a></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 369<A CLASS="chapter" HREF="ch06_01.html" TITLE="6. Users, Security, and Domains "> 370<IMG SRC="gifs/txtnexta.gif" ALT="Next: 6. Users, Security, and Domains " BORDER="0"></a></td></tr><TR> 371<TD ALIGN="LEFT" VALIGN="TOP" WIDTH="172"> 3725.4 Name Mangling and Case</td><TD ALIGN="CENTER" VALIGN="TOP" WIDTH="171"> 373<A CLASS="index" HREF="inx.html" TITLE="Book Index"> 374<IMG SRC="gifs/index.gif" ALT="Book Index" BORDER="0"></a></td><TD ALIGN="RIGHT" VALIGN="TOP" WIDTH="172"> 3756. Users, Security, and Domains </td></tr></table><hr noshade size=1></center> 376</div> 377 378<!-- End of sample chapter --> 379<CENTER> 380<FONT SIZE="1" FACE="Verdana, Arial, Helvetica"> 381<A HREF="http://www.oreilly.com/"> 382<B>O'Reilly Home</B></A> <B> | </B> 383<A HREF="http://www.oreilly.com/sales/bookstores"> 384<B>O'Reilly Bookstores</B></A> <B> | </B> 385<A HREF="http://www.oreilly.com/order_new/"> 386<B>How to Order</B></A> <B> | </B> 387<A HREF="http://www.oreilly.com/oreilly/contact.html"> 388<B>O'Reilly Contacts<BR></B></A> 389<A HREF="http://www.oreilly.com/international/"> 390<B>International</B></A> <B> | </B> 391<A HREF="http://www.oreilly.com/oreilly/about.html"> 392<B>About O'Reilly</B></A> <B> | </B> 393<A HREF="http://www.oreilly.com/affiliates.html"> 394<B>Affiliated Companies</B></A><p> 395<EM>© 1999, O'Reilly & Associates, Inc.</EM> 396</FONT> 397</CENTER> 398</BODY> 399</html> 400