From 3878085eca35d5c3b08761f61281de0b1b49ce2d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 1 Jul 2003 22:58:52 +0000 Subject: regenerate docs (This used to be commit cc02d3bc170fe5c8c4474156edb6c83720a47aa0) --- docs/htmldocs/locking.html | 135 ++++++++++++++++++++++----------------------- 1 file changed, 67 insertions(+), 68 deletions(-) (limited to 'docs/htmldocs/locking.html') diff --git a/docs/htmldocs/locking.html b/docs/htmldocs/locking.html index 6922f916f2..a128cac7ce 100644 --- a/docs/htmldocs/locking.html +++ b/docs/htmldocs/locking.html @@ -1,8 +1,7 @@ - -Chapter 14. File and Record Locking

Chapter 14. File and Record Locking

Jeremy Allison

Samba Team

Jelmer R. Vernooij

The Samba Team

John H. Terpstra

Samba Team

Eric Roseme

HP Oplocks Usage Recommendations Whitepaper

+Chapter 14. File and Record Locking

Chapter 14. File and Record Locking

Jeremy Allison

Samba Team

Jelmer R. Vernooij

The Samba Team

John H. Terpstra

Samba Team

Eric Roseme

HP Oplocks Usage Recommendations Whitepaper

One area which causes trouble for many network administrators is locking. The extent of the problem is readily evident from searches over the internet. -

Features and Benefits

+

Features and Benefits

Samba provides all the same locking semantics that MS Windows clients expect and that MS Windows NT4 / 200x servers provide also.

@@ -24,7 +23,7 @@ settings on the MS Windows client.

Note

Sometimes it is necessary to disable locking control settings BOTH on the Samba server as well as on each MS Windows client! -

Discussion

+

Discussion

There are two types of locking which need to be performed by a SMB server. The first is record locking which allows a client to lock a range of bytes in a open file. The second is the deny modes @@ -63,7 +62,7 @@ access should be allowed simultaneously with its open. A client may ask for DENY_NONE, DENY_READ, DENY_WRITE or DENY_ALL. There are also special compatibility modes called DENY_FCB and DENY_DOS. -

Opportunistic Locking Overview

+

Opportunistic Locking Overview

Opportunistic locking (Oplocks) is invoked by the Windows file system (as opposed to an API) via registry entries (on the server AND client) for the purpose of enhancing network performance when accessing a file @@ -84,8 +83,8 @@ other processes. The redirector sees that the file was opened with deny none (allowing concurrent access), verifies that no other process is accessing the file, checks that - oplocks are enabled, then grants deny-all/read-write/ex- - clusive access to the file. The client now performs + oplocks are enabled, then grants deny-all/read-write/exclusive + access to the file. The client now performs operations on the cached local file.

If a second process attempts to open the file, the open @@ -186,7 +185,7 @@ In mission critical high availability environments, careful attention should be given to opportunistic locking. Ideally, comprehensive testing should be done with all affected applications with oplocks enabled and disabled. -

Exclusively Accessed Shares

+

Exclusively Accessed Shares

Opportunistic locking is most effective when it is confined to shares that are exclusively accessed by a single user, or by only one user at a time. Because the true value of opportunistic locking is the local @@ -195,7 +194,7 @@ mechanism will cause a delay.

Home directories are the most obvious examples of where the performance benefit of opportunistic locking can be safely realized. -

Multiple-Accessed Shares or Files

+

Multiple-Accessed Shares or Files

As each additional user accesses a file in a share with opportunistic locking enabled, the potential for delays and resulting perceived poor performance increases. When multiple users are accessing a file on a @@ -207,7 +206,7 @@ of the caching user. As each additional client attempts to access a file with oplocks set, the potential performance improvement is negated and eventually results in a performance bottleneck. -

Unix or NFS Client Accessed Files

+

Unix or NFS Client Accessed Files

Local Unix and NFS clients access files without a mandatory file locking mechanism. Thus, these client platforms are incapable of initiating an oplock break request from the server to a Windows client @@ -215,9 +214,9 @@ that has a file cached. Local Unix or NFS file access can therefore write to a file that has been cached by a Windows client, which exposes the file to likely data corruption.

-If files are shared between Windows clients, and either loca Unix +If files are shared between Windows clients, and either local Unix or NFS users, then turn opportunistic locking off. -

Slow and/or Unreliable Networks

+

Slow and/or Unreliable Networks

The biggest potential performance improvement for opportunistic locking occurs when the client-side caching of reads and writes delivers the most differential over sending those reads and writes over the wire. @@ -232,7 +231,7 @@ the most advantageous scenario to utilize opportunistic locking. If the network is slow, unreliable, or a WAN, then do not configure opportunistic locking if there is any chance of multiple users regularly opening the same file. -

Multi-User Databases

+

Multi-User Databases

Multi-user databases clearly pose a risk due to their very nature - they are typically heavily accessed by numerous users at random intervals. Placing a multi-user database on a share with opportunistic @@ -240,7 +239,7 @@ locking enabled will likely result in a locking management bottleneck on the Samba server. Whether the database application is developed in-house or a commercially available product, ensure that the share has opportunistic locking disabled. -

PDM Data Shares

+

PDM Data Shares

Process Data Management (PDM) applications such as IMAN, Enovia, and Clearcase, are increasing in usage with Windows client platforms, and therefore SMB data stores. PDM applications manage multi-user @@ -253,7 +252,7 @@ application and PDM server to negotiate and maintain. It is appropriate to eliminate the client OS from any caching tasks, and the server from any oplock management, by disabling opportunistic locking on the share. -

Beware of Force User

+

Beware of Force User

Samba includes an smb.conf parameter called force user that changes the user accessing a share from the incoming user to whatever user is defined by the smb.conf variable. If opportunistic locking is enabled @@ -271,7 +270,7 @@ Avoid the combination of the following: Slow or unreliable networks

  • Opportunistic Locking Enabled -

  • Advanced Samba Opportunistic Locking Parameters

    +

    Advanced Samba Opportunistic Locking Parameters

    Samba provides opportunistic locking parameters that allow the administrator to adjust various properties of the oplock mechanism to account for timing and usage levels. These parameters provide good @@ -285,7 +284,7 @@ are required, then the better option is to simply turn oplocks off. The samba SWAT help text for both parameters reads "DO NOT CHANGE THIS PARAMETER UNLESS YOU HAVE READ AND UNDERSTOOD THE SAMBA OPLOCK CODE." This is good advice. -

    Mission Critical High Availability

    +

    Mission Critical High Availability

    In mission critical high availability environments, data integrity is often a priority. Complex and expensive configurations are implemented to ensure that if a client loses connectivity with a file server, a @@ -315,7 +314,7 @@ In mission critical high availability environments, careful attention should be given to opportunistic locking. Ideally, comprehensive testing should be done with all affected applications with oplocks enabled and disabled. -

    Samba Opportunistic Locking Control

    +

    Samba Opportunistic Locking Control

    Opportunistic Locking is a unique Windows file locking feature. It is not really file locking, but is included in most discussions of Windows file locking, so is considered a defacto locking feature. @@ -339,7 +338,7 @@ synchronising the contents of the entire file back to the server for a single ch

    Level1 Oplocks (aka just plain "oplocks") is another term for opportunistic locking.

    -Level2 Oplocks provids opportunistic locking for a file that will be treated as +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.

    @@ -352,7 +351,7 @@ Unless your system supports kernel oplocks, you should disable oplocks if you ar accessing the same files from both Unix/Linux and SMB clients. Regardless, oplocks should always be disabled if you are sharing a database file (e.g., Microsoft Access) between multiple clients, as any break the first client receives will affect synchronisation of -the entire file (not just the single record), which will result in a noticable performance +the entire file (not just the single record), which will result in a noticeable performance impairment and, more likely, problems accessing the database in the first place. Notably, Microsoft Outlook's personal folders (*.pst) react very badly to oplocks. If in doubt, disable oplocks and tune your system from that point. @@ -365,29 +364,29 @@ of your client sending oplock breaks and will instead want to disable oplocks fo

    Another factor to consider is the perceived performance of file access. If oplocks provide no measurable speed benefit on your network, it might not be worth the hassle of dealing with them. -

    Example Configuration

    -In the following we examine two destinct aspects of samba locking controls. -

    Disabling Oplocks

    +

    Example Configuration

    +In the following we examine two distinct aspects of Samba locking controls. +

    Disabling Oplocks

    You can disable oplocks on a per-share basis with the following: -

    -
    +

    +

     [acctdata]
     	oplocks = False
     	level2 oplocks = False
    -
    -

    +

    +

    The default oplock type is Level1. Level2 Oplocks are enabled on a per-share basis in the smb.conf file.

    Alternately, you could disable oplocks on a per-file basis within the share: -

    -
    +

    +

     	veto oplock files = /*.mdb/*.MDB/*.dbf/*.DBF/
    -
    -

    +

    +

    If you are experiencing problems with oplocks as apparent from Samba's log entries, you may want to play it safe and disable oplocks and level2 oplocks. -

    Disabling Kernel OpLocks

    +

    Disabling Kernel OpLocks

    Kernel OpLocks is an smb.conf parameter that notifies Samba (if the UNIX kernel has the capability to send a Windows client an oplock break) when a UNIX process is attempting to open the file that is @@ -399,13 +398,13 @@ to the risk of data corruption. If the UNIX kernel has the ability to send an oplock break, then the kernel oplocks parameter enables Samba to send the oplock break. Kernel oplocks are enabled on a per-server basis in the smb.conf file. -

    -
    +

    +

     [global]
     kernel oplocks = yes
    -
    +

    The default is "no". -

    +

    Veto OpLocks is an smb.conf parameter that identifies specific files for which Oplocks are disabled. When a Windows client opens a file that has been configured for veto oplocks, the client will not be granted @@ -417,26 +416,26 @@ allow Windows clients to utilize the performance benefit of file caching without the risk of data corruption. Veto Oplocks can be enabled on a per-share basis, or globally for the entire server, in the smb.conf file: -

    -
    <title>Example Veto OpLock Settings</title>
    +

    +

    <title>Example Veto OpLock Settings</title>
     [global]
             veto oplock files = /filename.htm/*.txt/
     
     [share_name]
             veto oplock files = /*.exe/filename.ext/
    -
    -

    +

    +

    Oplock break wait time is an smb.conf parameter that adjusts the time interval for Samba to reply to an oplock break request. Samba recommends "DO NOT CHANGE THIS PARAMETER UNLESS YOU HAVE READ AND UNDERSTOOD THE SAMBA OPLOCK CODE." Oplock Break Wait Time can only be configured globally in the smb.conf file: -

    -
    +

    +

     [global]
               oplock break wait time =  0 (default)
    -
    -

    +

    +

    Oplock break contention limit is an smb.conf parameter that limits the response of the Samba server to grant an oplock if the configured number of contending clients reaches the limit specified by the @@ -444,15 +443,15 @@ parameter. Samba recommends "DO NOT CHANGE THIS PARAMETER UNLESS YOU HAVE READ AND UNDERSTOOD THE SAMBA OPLOCK CODE." Oplock Break Contention Limit can be enable on a per-share basis, or globally for the entire server, in the smb.conf file: -

    -
    +

    +

     [global]
               oplock break contention limit =  2 (default)
     
     [share_name]
              oplock break contention limit =  2 (default)
    -
    -

    MS Windows Opportunistic Locking and Caching Controls

    +

    +

    MS Windows Opportunistic Locking and Caching Controls

    There is a known issue when running applications (like Norton Anti-Virus) on a Windows 2000/ XP workstation computer that can affect any application attempting to access shared database files across a network. This is a result of a default setting configured in the Windows 2000/XP @@ -489,20 +488,20 @@ Windows 2000 will still respect the EnableOplocks registry value used to disable in earlier versions of Windows.

    You can also deny the granting of opportunistic locks by changing the following registry entries: -

    -
    +

    +

     	HKEY_LOCAL_MACHINE\System\
     		CurrentControlSet\Services\MRXSmb\Parameters\
     
     		OplocksDisabled REG_DWORD 0 or 1
     		Default: 0 (not disabled)
    -
    -

    Note

    +

    +

    Note

    The OplocksDisabled registry value configures Windows clients to either request or not request opportunistic locks on a remote file. To disable oplocks, the value of OplocksDisabled must be set to 1. -

    -
    +

    +

     	HKEY_LOCAL_MACHINE\System\
     		CurrentControlSet\Services\LanmanServer\Parameters
     
    @@ -511,8 +510,8 @@ request opportunistic locks on a remote file. To disable oplocks, the value of
     
     		EnableOpLockForceClose REG_DWORD 0 or 1
     		Default: 0 (Disabled by Default)
    -
    -

    Note

    +

    +

    Note

    The EnableOplocks value configures Windows-based servers (including Workstations sharing files) to allow or deny opportunistic locks on local files.

    @@ -544,7 +543,7 @@ An illustration of how level II oplocks work: station holds any oplock on the file. Because the workstations can have no cached writes or locks at this point, they need not respond to the break-to-none advisory; all they need do is invalidate locally cashed read-ahead data. -

    Workstation Service Entries

    +	

    Workstation Service Entries

     	\HKEY_LOCAL_MACHINE\System\
     		CurrentControlSet\Services\LanmanWorkstation\Parameters
     
    @@ -553,7 +552,7 @@ An illustration of how level II oplocks work:
     

    Indicates whether the redirector should use opportunistic-locking (oplock) performance enhancement. This parameter should be disabled only to isolate problems. -

    Server Service Entries

    +

    Server Service Entries

     	\HKEY_LOCAL_MACHINE\System\
     		CurrentControlSet\Services\LanmanServer\Parameters
     
    @@ -582,7 +581,7 @@ the server disables raw I/O and opportunistic locking for this connection.
     Specifies the time that the server waits for a client to respond to an oplock break
     request. Smaller values can allow detection of crashed clients more quickly but can
     potentially cause loss of cached data.
    -

    Persistent Data Corruption

    +

    Persistent Data Corruption

    If you have applied all of the settings discussed in this paper but data corruption problems and other symptoms persist, here are some additional things to check out:

    @@ -593,10 +592,10 @@ rebuild the data files in question. This involves creating a new data file with same definition as the file to be rebuilt and transferring the data from the old file to the new one. There are several known methods for doing this that can be found in our Knowledge Base. -

    Common Errors

    +

    Common Errors

    In some sites locking problems surface as soon as a server is installed, in other sites -locking problems may not surface for a long time. Almost without exeception, when a locking -problem does surface it will cause embarassment and potential data corruption. +locking problems may not surface for a long time. Almost without exception, when a locking +problem does surface it will cause embarrassment and potential data corruption.

    Over the past few years there have been a number of complaints on the samba mailing lists that have claimed that samba caused data corruption. Three causes have been identified @@ -623,18 +622,18 @@ so far: report on https://bugzilla.samba.org without delay. Make sure that you give as much information as you possibly can to help isolate the cause and to allow reproduction of the problem (an essential step in problem isolation and correction). -

    locking.tdb error messages

    -
    +	

    locking.tdb error messages

    +

     	> We are seeing lots of errors in the samba logs like:
     	>
     	>    tdb(/usr/local/samba_2.2.7/var/locks/locking.tdb): rec_read bad magic
     	> 0x4d6f4b61 at offset=36116
     	>
     	> What do these mean?
    -	
    -

    - Corrupted tdb. Stop all instancesd of smbd, delete locking.tdb, restart smbd. -

    Additional Reading

    +

    +

    + Corrupted tdb. Stop all instances of smbd, delete locking.tdb, restart smbd. +

    Additional Reading

    You may want to check for an updated version of this white paper on our Web site from time to time. Many of our white papers are updated as information changes. For those papers, the Last Edited date is always at the top of the paper. -- cgit