Platform SDK: Files and I/O

Opportunistic Locks

An opportunistic lock (also called an oplock) is a lock placed by a client on a file residing on a server. A client places an opportunistic lock so it can cache data locally, thus reducing network traffic and improving apparent response time. Opportunistic locks are used by network redirectors on clients and by servers.

Opportunistic locks coordinate data caching and coherency between clients and servers and among multiple clients. Data that is coherent is data that is the same across the network. In other words, if data is coherent, data on the server and all the clients is synchronized.

Opportunistic locks are not commands by the client to the server. They are requests from the client to the server. From the point of view of the client, they are opportunistic. In other words, the server grants such locks whenever other factors make the locks possible.

Opportunistic locks and the associated operations implemented in the Microsoft® Windows® 2000 operating system are a superset of the opportunistic lock portion of the Common Internet File System (CIFS) protocol, an Internet Draft. The CIFS protocol is an enhanced version of the Server Message Block (SMB) protocol. For more information on the CIFS protocol, see Common Internet File System Protocol in the Networking Services section of the Platform Software Development Kit (SDK).

Note that the CIFS Internet Draft explicitly provides that a CIFS implementation may implement opportunistic locks by refusing to grant them.

For additional information on opportunistic locks, see the CIFS Internet Draft discussion on the topic.

Any discrepancies between this discussion and the current CIFS Internet Draft should be resolved in favor of the Internet Draft.