This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.
[sfrench/samba-autobuild/.git] / docs / htmldocs / oplocks.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <HTML
3 ><HEAD
4 ><TITLE
5 >Oplocks</TITLE
6 ><META
7 NAME="GENERATOR"
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.77"><LINK
9 REL="HOME"
10 TITLE="SAMBA Project Documentation"
11 HREF="samba-howto-collection.html"><LINK
12 REL="UP"
13 TITLE="General installation"
14 HREF="introduction.html"><LINK
15 REL="PREVIOUS"
16 TITLE="Improved browsing in samba"
17 HREF="improved-browsing.html"><LINK
18 REL="NEXT"
19 TITLE="Quick Cross Subnet Browsing / Cross Workgroup Browsing guide"
20 HREF="browsing-quick.html"></HEAD
21 ><BODY
22 CLASS="CHAPTER"
23 BGCOLOR="#FFFFFF"
24 TEXT="#000000"
25 LINK="#0000FF"
26 VLINK="#840084"
27 ALINK="#0000FF"
28 ><DIV
29 CLASS="NAVHEADER"
30 ><TABLE
31 SUMMARY="Header navigation table"
32 WIDTH="100%"
33 BORDER="0"
34 CELLPADDING="0"
35 CELLSPACING="0"
36 ><TR
37 ><TH
38 COLSPAN="3"
39 ALIGN="center"
40 >SAMBA Project Documentation</TH
41 ></TR
42 ><TR
43 ><TD
44 WIDTH="10%"
45 ALIGN="left"
46 VALIGN="bottom"
47 ><A
48 HREF="improved-browsing.html"
49 ACCESSKEY="P"
50 >Prev</A
51 ></TD
52 ><TD
53 WIDTH="80%"
54 ALIGN="center"
55 VALIGN="bottom"
56 ></TD
57 ><TD
58 WIDTH="10%"
59 ALIGN="right"
60 VALIGN="bottom"
61 ><A
62 HREF="browsing-quick.html"
63 ACCESSKEY="N"
64 >Next</A
65 ></TD
66 ></TR
67 ></TABLE
68 ><HR
69 ALIGN="LEFT"
70 WIDTH="100%"></DIV
71 ><DIV
72 CLASS="CHAPTER"
73 ><H1
74 ><A
75 NAME="OPLOCKS"
76 ></A
77 >Chapter 3. Oplocks</H1
78 ><DIV
79 CLASS="SECT1"
80 ><H1
81 CLASS="SECT1"
82 ><A
83 NAME="AEN378"
84 ></A
85 >3.1. What are oplocks?</H1
86 ><P
87 >When a client opens a file it can request an "oplock" or file
88 lease. This is (to simplify a bit) a guarentee that no one else
89 has the file open simultaneously. It allows the client to not
90 send any updates on the file to the server, thus reducing a
91 network file access to local access (once the file is in
92 client cache). An "oplock break" is when the server sends
93 a request to the client to flush all its changes back to
94 the server, so the file is in a consistent state for other
95 opens to succeed. If a client fails to respond to this
96 asynchronous request then the file can be corrupted. Hence
97 the "turn off oplocks" answer if people are having multi-user
98 file access problems.</P
99 ><P
100 >Unless the kernel is "oplock aware" (SGI IRIX and Linux are
101 the only two UNIXes that are at the moment) then if a local
102 UNIX process accesses the file simultaneously then Samba
103 has no way of telling this is occuring, so the guarentee
104 to the client is broken. This can corrupt the file. Short
105 answer - it you have UNIX clients accessing the same file
106 as smbd locally or via NFS and you're not running Linux or
107 IRIX then turn off oplocks for that file or share.</P
108 ><P
109 >"Share modes". These are modes of opening a file, that
110 guarentee an invarient - such as DENY_WRITE - which means
111 that if any other opens are requested with write access after
112 this current open has succeeded then they should be denied
113 with a "sharing violation" error message. Samba handles these
114 internally inside smbd. UNIX clients accessing the same file
115 ignore these invarients. Just proving that if you need simultaneous
116 file access from a Windows and UNIX client you *must* have an
117 application that is written to lock records correctly on both
118 sides. Few applications are written like this, and even fewer
119 are cross platform (UNIX and Windows) so in practice this isn't
120 much of a problem.</P
121 ><P
122 >"Locking". This really means "byte range locking" - such as
123 lock 10 bytes at file offset 24 for write access. This is the
124 area in which well written UNIX and Windows apps will cooperate.
125 Windows locks (at least from NT or above) are 64-bit unsigned
126 offsets. UNIX locks are either 31 bit or 63 bit and are signed
127 (the top bit is used for the sign). Samba handles these by
128 first ensuring that all the Windows locks don't conflict (ie.
129 if other Windows clients have competing locks then just reject
130 immediately) - this allows us to support 64-bit Windows locks
131 on 32-bit filesystems. Secondly any locks that are valid are
132 then mapped onto UNIX fcntl byte range locks. These are the
133 locks that will be seen by UNIX processes. If there is a conflict
134 here the lock is rejected.</P
135 ><P
136 >Note that if a client has an oplock then it "knows" that no
137 other client can have the file open so usually doesn't bother
138 to send to lock request to the server - this means once again
139 if you need to share files between UNIX and Windows processes
140 either use IRIX or Linux, or turn off oplocks for these
141 files/shares.</P
142 ></DIV
143 ></DIV
144 ><DIV
145 CLASS="NAVFOOTER"
146 ><HR
147 ALIGN="LEFT"
148 WIDTH="100%"><TABLE
149 SUMMARY="Footer navigation table"
150 WIDTH="100%"
151 BORDER="0"
152 CELLPADDING="0"
153 CELLSPACING="0"
154 ><TR
155 ><TD
156 WIDTH="33%"
157 ALIGN="left"
158 VALIGN="top"
159 ><A
160 HREF="improved-browsing.html"
161 ACCESSKEY="P"
162 >Prev</A
163 ></TD
164 ><TD
165 WIDTH="34%"
166 ALIGN="center"
167 VALIGN="top"
168 ><A
169 HREF="samba-howto-collection.html"
170 ACCESSKEY="H"
171 >Home</A
172 ></TD
173 ><TD
174 WIDTH="33%"
175 ALIGN="right"
176 VALIGN="top"
177 ><A
178 HREF="browsing-quick.html"
179 ACCESSKEY="N"
180 >Next</A
181 ></TD
182 ></TR
183 ><TR
184 ><TD
185 WIDTH="33%"
186 ALIGN="left"
187 VALIGN="top"
188 >Improved browsing in samba</TD
189 ><TD
190 WIDTH="34%"
191 ALIGN="center"
192 VALIGN="top"
193 ><A
194 HREF="introduction.html"
195 ACCESSKEY="U"
196 >Up</A
197 ></TD
198 ><TD
199 WIDTH="33%"
200 ALIGN="right"
201 VALIGN="top"
202 >Quick Cross Subnet Browsing / Cross Workgroup Browsing guide</TD
203 ></TR
204 ></TABLE
205 ></DIV
206 ></BODY
207 ></HTML
208 >