Configuring opportunistic locking in Windows
This article was previously published under Q296264
By default, opportunistic locking is enabled for server message block (SMB) clients that run one of the Windows operating systems that is listed in the "Applies to" section. Opportunistic locking lets clients lock files and locally cache information without the risk of another user changing the file. This increases performance for many file operations but may decrease performance in other operations because the server that grants the opportunistic lock must manage the breaking of that lock when another user requests access to the file.
Notes for Windows Vista
- The opportunistic locking registry keys are valid only for traditional SMB (SMB1). You cannot turn off opportunistic locking for SMB2. SMB2 was introduced in Windows Vista to enable faster communication between computer that are running Windows Vista and Windows Server 2008 or Windows Server 2008 R2.
- If you disable opportunistic locking, the offline files feature in Windows Vista fails.
Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:
322756 How to back up and restore the registry in Windows
The location of the client registry entry for opportunistic locking has changed from the location in Microsoft Windows NT. In later versions of Windows, you can disable opportunistic locking by setting the following registry entry to 1:
OplocksDisabled REG_DWORD 0 or 1Note The OplocksDisabled entry configures Windows clients to request or not to request opportunistic locks on a remote file.
Default: 0 (not disabled)
Default: 0 (not disabled)
You can also deny the granting of opportunistic locks by setting the following registry entry to 0:
EnableOplocks REG_DWORD 0 or 1Note The EnableOplocks entry configures Windows-based servers to allow or to deny opportunistic locks on local files. These servers include workstations that share files.
Default: 1 (enabled)
Default: 1 (enabled)
In addition, you can use the following values to tune opportunistic locking for Windows-based computers that have granted opportunistic locks.
The following value specifies the minimum link throughput that the server allows before it disables raw and opportunistic locks for this connection:
MinLinkThroughput REG_DWORD 0 to infinite bytes per secondThe following value specifies the maximum time that is allowed for a link delay. If delays exceed this number, the server disables raw I/O and opportunistic locking for this connection.
MaxLinkDelay REG_DWORD 0 to 100,000 secondsThe following value specifies the time that the server waits for a client to respond to an oplock break request. Smaller values allow detection of crashed clients more quickly, but might potentially cause loss of cached data.
OplockBreakWait REG_DWORD 10 to 180 secondsNote You must restart the computer for these registry changes to take effect.
Article ID: 296264 - Last Review: 04/04/2011 05:05:00 - Revision: 11.0
Microsoft Windows Server 2003, Standard Edition (32-bit x86), Microsoft Windows Server 2003, Enterprise Edition (32-bit x86), Microsoft Windows Server 2003, Datacenter Edition (32-bit x86), Microsoft Windows Server 2003, Web Edition, Microsoft Windows Server 2003, Enterprise x64 Edition, Microsoft Windows XP Professional, Microsoft Windows XP Tablet PC Edition, Microsoft Windows XP Professional x64 Edition, Microsoft Windows 2000 Server, Microsoft Windows 2000 Advanced Server, Microsoft Windows 2000 Professional Edition, Microsoft Windows Small Business Server 2003 Premium Edition, Microsoft Windows Small Business Server 2003 Standard Edition, Windows Server 2008 Datacenter without Hyper-V, Windows Server 2008 Enterprise without Hyper-V, Windows Server 2008 for Itanium-Based Systems, Windows Server 2008 Standard without Hyper-V, Windows Server 2008 Datacenter, Windows Server 2008 Enterprise, Windows Server 2008 Standard, Windows Web Server 2008, Windows Server 2008 R2 Datacenter, Windows Server 2008 R2 Enterprise, Windows Server 2008 R2 Standard, Windows Web Server 2008 R2, Windows Vista Business, Windows Vista Enterprise, Windows Vista Ultimate, Windows 7 Enterprise, Windows 7 Professional, Windows 7 Ultimate
- kbenv kbfilesystems kbinfo w2000fs KB296264