VFP
Transcript of VFP
-
7/29/2019 VFP
1/2
25/01/13 Opportunistic Locks (Windows)
msdn.microsoft.com/en-us/library/windows/desktop/aa365433(v=vs.85).aspx 1/3
Opportunistic Locks (Windows)
5 out of 5 rated this helpful
An opportunistic lock (also called an oplock) is a lock placed by a client on a file residing on a server. Inmost cases, a client requests 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 with
remote servers, as well as by client applications on local 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 suchlocks whenever other factors make the locks possible.
When a local application requests access to a remote file, the implementation of opportunistic locks is
transparent to the application. The network redirector and the server involved open and close the
opportunistic locks automatically. However, opportunistic locks can also be used when a local application
requests access to a local file, and access by other applications and processes must be delegated to
prevent corruption of the file. In this case, the local application directly requests an opportunistic lock from
the local file system and caches the file locally. When used in this way, the opportunistic lock is effectively a
semaphore managed by the local server, and is mainly used for the purposes of data coherency in the file
and file access notification.
Before using opportunistic locks in your application, you should be familiar with the file access and sharing
modes described in Creating and Opening Files.
The maximum number of concurrent opportunistic locks that you can create is limited only by the amount
of available memory.
Local applications should not attempt to request opportunistic locks from remote servers. An error will be
returned by DeviceIoControl if an attempt is made to do this.
Opportunistic locks are of very limited use for applications. The only practical use is to test a network
redirector or a server opportunistic lock handler. Typically, file systems implement support for opportunistic
locks. Applications generally leave opportunistic lock management to the file system drivers. Anyone
implementing a file system should use the Installable File System (IFS) Kit. Anyone developing a device
driver other than an installable file system should use the Windows Driver Kit (WDK).
Opportunistic locks and the associated operations 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, see Microsoft SMB Protocol and CIFSProtocol Overview. The CIFS Internet Draft explicitly identifies that a CIFS implementation may implement
opportunistic locks by refusing to grant them.
The following topics identify opportunistic locks.
http://go.microsoft.com/fwlink/p/?linkid=84078http://msdn.microsoft.com/en-us/library/windows/desktop/aa363874(v=vs.85).aspxhttp://msdn.microsoft.com/en-us/library/windows/desktop/aa365233(v=vs.85).aspxhttp://go.microsoft.com/fwlink/p/?linkid=84080http://go.microsoft.com/fwlink/p/?linkid=84078http://msdn.microsoft.com/en-us/library/windows/desktop/aa363216(v=vs.85).aspxhttp://msdn.microsoft.com/en-us/library/windows/desktop/aa363874(v=vs.85).aspx -
7/29/2019 VFP
2/2
25/01/13 Opportunistic Locks (Windows)
msdn.microsoft.com/en-us/library/windows/desktop/aa365433(v=vs.85).aspx 2/3
In this section
Topic Description
Local Caching Local caching of data is a technique used to speed network access to data files. It
involves caching data on clients rather than on servers when possible.
Data
Coherency
If data is coherent, data on the server and all the clients is synchronized. One type of
software system that provides data coherency is a revision control system (RCS).
How to
Request an
Opportunistic
Lock
Opportunistic locks are requested by first opening a file with permissions and flags
appropriate to the application opening the file. All files for which opportunistic locks will
be requested must be opened for overlapped (asynchronous) operation.
ServerResponse to
Open
Requests on
Locked Files
You can minimize the impact your application has on other clients and the impact theyhave on your application by granting as much sharing as possible, requesting the
minimum access level necessary, and using the least intrusive opportunistic lock
suitable for your application.
Types of
Opportunistic
Locks
Describes level 1, level 2, batch, and filter opportunistic locks.
Breaking
Opportunistic
Locks
Breaking an opportunistic lock is the process of degrading the lock that one client has
on a file so that another client can open the file, with or without an opportunistic lock.
Opportunistic
Lock Examples
Diagrams of network-traffic views for a level 1 opportunistic lock, a batch opportunistic
lock, and a filter opportunistic lock.
Opportunistic
LockOperations
If an application requests opportunistic locks, all files for which it requests locks must
be opened for overlapped (asynchronous) input and output by using the CreateFilefunction with the FILE_FLAG_OVERLAPPED flag.
For additional information about opportunistic locks, see the CIFS Internet Draft document. Any
discrepancies between this topic and the current CIFS Internet Draft should be resolved in favor of the
CIFS Internet Draft.
Send comments about this topic to Microsoft
Build date: 11/8/2012
mailto:[email protected]?subject=Documentation%20feedback%20[fileio\fs]:%20Opportunistic%20Locks%20%20RELEASE:%20(11/8/2012)&body=%0A%0APRIVACY%20STATEMENT%0A%0AThe%20doc%20team%20uses%20your%20feedback%20to%20improve%20the%20documentation.%20We%20don%27t%20use%20your%20email%20address%20for%20any%20other%20purpose.%20We%27ll%20remove%20your%20email%20address%20from%20our%20system%20after%20the%20issue%20that%20you%20are%20reporting%20is%20resolved.%20While%20we%20are%20working%20to%20resolve%20this%20issue,%20we%20may%20send%20you%20an%20email%20message%20to%20request%20more%20info%20about%20your%20feedback.%20After%20the%20issue%20is%20addressed,%20we%20may%20send%20you%20an%20email%20message%20to%20let%20you%20know%20that%20your%20feedback%20has%20been%20addressed.%0A%0AFor%20more%20info%20about%20Microsoft%27s%20privacy%20policy,%20see%20http://privacy.microsoft.com/en-us/default.aspx.http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspxhttp://msdn.microsoft.com/en-us/library/windows/desktop/aa365438(v=vs.85).aspxhttp://msdn.microsoft.com/en-us/library/windows/desktop/aa365436(v=vs.85).aspxhttp://msdn.microsoft.com/en-us/library/windows/desktop/aa363786(v=vs.85).aspxhttp://msdn.microsoft.com/en-us/library/windows/desktop/aa365713(v=vs.85).aspxhttp://msdn.microsoft.com/en-us/library/windows/desktop/aa365529(v=vs.85).aspxhttp://msdn.microsoft.com/en-us/library/windows/desktop/aa365007(v=vs.85).aspxhttp://msdn.microsoft.com/en-us/library/windows/desktop/aa363880(v=vs.85).aspxhttp://msdn.microsoft.com/en-us/library/windows/desktop/aa365201(v=vs.85).aspx