Niakwa, Inc.

    

 


What's News
NPL Products
NPL Support
NPL Downloads
System Integration
swiggle_small.gif (991 bytes)

swiggle_small.gif (991 bytes)

September 24, 1999 No. 89

Opportunistic File Locking

Running a NPL Windows RunTime on a Windows NT server with Windows 95/98 or Windows NT workstations, it has been reported from a couple of sites that were having periodic problems with file sharing and locking, resulting in spurious I90's with associated "MS-DOS error code 21: Lock violation".

The process that causes the spurious I90's problem is called "Opportunistic File Locking" or Oplocks.  With Exclusive Oplock, if a file is opened in a non-exclusive (deny none) mode, the redirector requests an opportunistic lock of the entire file.  As long as no other process has the file open, the server will grant this oplock, giving the redirector exclusive access to the specified file.  This will allow the redirector to perform read-ahead, write-behind, and lock caching, as long as no other process tries to open the file.

When a second process attempts to open the file, the original owner will be asked to Break Oplock or Break to Level II Oplock.  At that point, the redirector must invalidate cached data, flush writes and locks, and release the oplock, or close the file. It is at this point that the file is re-opened in "shared" mode.

Note:  For more information on this, and  please see Microsoft TechNet Article Q129202.

Theoretically, the oplocks problem tends to only show up on networks that are very busy, or which have clients that do not reply in a timely manner to server oplock break requests.  When using the standard default registry values, the server assumes that the client with an oplock has 'died' if it does not respond within 35 seconds to a break oplock request.  An oplock break failure can result in data loss and possibly allowing two clients to simultaneously open a shared file in exclusive mode. 

The following registry entries are used to enable or disable oplocks for Windows NT Workstation and Server. These registry keys may not exist by default.  This registry setting change must be done on Windows NT Server and Workstations, and is not a requirement for Windows 95/98 since it does not use oplocks.  To access the registry, run REGEDT32.EXE from the File menu, choose Run in Program Manager or File Manager.  The settings are for changing the default setting from one (1) to zero (0).

WARNING: Using Registry Editor incorrectly can cause serious, system-wide problems that may require you to reinstall Windows NT to correct them.  Microsoft and Niakwa cannot guarantee that any problems resulting from the use of Registry Editor can be solved.  Use this tool at your own risk.

WARNING:  Please note that there is a serious performance penalty paid for turning off Oplocks. 

Note: On NT systems you need Administrative access to make the registry changes.  After changing the registry settings, reboot the server or workstation for the settings to take effect.  If your network needed the oplocks disabled when using NPL Revision 5.00.09, it would be advisable to leave it disabled for Revision 5.01.07.

Workstation

\HKEY_LOCAL_MACHINE
\SYSTEM
\CurrentControlSet
\Services
\LanmanWorkstation
\Parameters

UseOpportunisticLocking REG_DWORD 0 or 1

Default: 1 (True)

File Server

\HKEY_LOCAL_MACHINE
\SYSTEM
\CurrentControlSet
\Services
\LanmanServer
\Parameters

EnableOplocks REG_DWORD 0 or 1

Default: 1 (True)

Note:  These entries are not usually in the registry as Microsoft assumes that you want to use this function.

 

blank.gif (841 bytes)


Niakwa, Basic-2C and NPL are trademarks of Niakwa, Inc. All other products mentioned are registered trademarks or trademarks of their respective companies.

Questions or problems regarding this web site should be directed to webmaster@niakwa.com.
Copyright 1996-2010 Niakwa, Inc. All rights reserved.
Last updated: Thursday January 07, 2010.