Level II Oplocks Are Not Granted After a File Is Locked (306981)



The information in this article applies to:

  • Microsoft Windows 2000 Professional SP1
  • Microsoft Windows 2000 Professional SP2
  • Microsoft Windows 2000 Advanced Server SP1
  • Microsoft Windows 2000 Advanced Server SP2
  • Microsoft Windows 2000 Server SP1
  • Microsoft Windows 2000 Server SP2
  • Microsoft Windows XP Home Edition
  • Microsoft Windows XP Professional
  • Microsoft Windows XP 64-Bit Edition
  • Microsoft Windows NT Workstation 4.0
  • Microsoft Windows NT Workstation 4.0 SP1
  • Microsoft Windows NT Workstation 4.0 SP2
  • Microsoft Windows NT Workstation 4.0 SP3
  • Microsoft Windows NT Workstation 4.0 SP4
  • Microsoft Windows NT Workstation 4.0 SP5
  • Microsoft Windows NT Workstation 4.0 SP6
  • Microsoft Windows NT Workstation 4.0 SP6a
  • Microsoft Windows NT Server 4.0
  • Microsoft Windows NT Server 4.0 SP1
  • Microsoft Windows NT Server 4.0 SP2
  • Microsoft Windows NT Server 4.0 SP3
  • Microsoft Windows NT Server 4.0 SP4
  • Microsoft Windows NT Server 4.0 SP5
  • Microsoft Windows NT Server 4.0 SP6
  • Microsoft Windows NT Server 4.0 SP6a

This article was previously published under Q306981

SYMPTOMS

Level II oplocks are not granted for a file that has had a range of the file locked. This behavior occurs until all references to the file are removed, including references from the operating system, such as the file cache.

This problem prevents network clients from using cached or read-ahead local information, which may affect performance when multiple network clients attempt to detect file data.

For more information about oplock behavior, view both the MORE INFORMATION and REFERENCES sections in this article.

CAUSE

This problem occurs because the file system architecture in the products that are listed at the beginning of this article do not provide a mechanism to synchronize file locks and oplocks. As a result, Level II oplocks cannot be safely granted for a given file after a file lock has been granted for that file.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

You cannot remove the described restrictions on grantable oplock levels without alteratering the system kernel and the Installable File System (IFS) toolkit. This requires redevelopment and redeployment of all file systems (NTFS, CDFS, FastFat, UDFS, and so on, including those file systems that are provided by third parties). The impact of these changes are beyond the scope of hotfixes and service packs for existing operating systems.

Steps to Reproduce the Problem

The following steps require a Windows 2000-based server, and two Windows NT or Windows 2000-based clients.
  1. Client 1 opens the file, requesting read and write access and sharing. For example, this code generates NT_CREATE_ANDX SMB to the server:
    HANDLE h = CreateFile( "\\server\share\filename.ext",
                           GENERIC_WRITE | GENERIC_READ,
                           FILE_SHARE_WRITE | FILE_SHARE_READ,
                           0, OPEN_EXISTING,
                           FILE_ATTRIBUTE_NORMAL, 0 );
    					
  2. The server responds to client 1 with NT_CREATE_ANDX SMB with the oplock level set to "Batch".
  3. Client 2 opens the file, requesting read and write access and sharing.
  4. The server sends LOCKING_AND_X SMB to client 1, with the Break Oplock flag set.
  5. The server responds to client 2 with NT_CREATE_ANDX SMB with the oplock level set to "II".
  6. Client 2 requests an exclusive lock against the file. For example, this code generates LOCKING_ANDX SMB to the server:
    OVERLAPPED o = { NULL, NULL, 0, 0, NULL };
    LockFileEx( h, LOCKFILE_EXCLUSIVE_LOCK, 0, 0, 0, &o );
    					
  7. The server notifies both client 1 and client 2 of the lock (LOCKING_ANDX SMB).
  8. Client 1 and client 2 close the file.
  9. Client 1 opens the file, requesting read and write access and sharing.
  10. The server responds to client 1 with NT_CREATE_ANDX SMB with the oplock level set to "Batch".
  11. Client 2 opens the file, requesting read and write access and sharing.
  12. The server sends LOCKING_AND_X SMB to client 1, with the Break Oplock flag set.
  13. The server responds to client 2 with NT_CREATE_ANDX SMB with the oplock level set to "None".

REFERENCES

For additional information about opportunistic locks, click the article number below to view the article in the Microsoft Knowledge Base:

129202 PC Ext: Explanation of Opportunistic Locking on Windows NT


Modification Type:MajorLast Reviewed:12/4/2003
Keywords:kbfile kbnofix kbprb KB306981