共用方式為


3.2.4.18 Application Requests an Opportunistic Lock on a File

The application requests an OpLock when opening or creating a file. See sections 3.2.4.5 and 3.2.4.6 for information on opening and creating files. The following SMB commands can be used to obtain an OpLock:

The application can request either an exclusive OpLock or a batch exclusive OpLock on a file. The server indicates the type of OpLock granted in the response. The server MUST grant the requested OpLock, a read-only (Level II) OpLock, or no OpLock. If an exclusive OpLock is not available, Level II OpLocks are granted only in response to SMB_COM_NT_CREATE_ANDX (section 2.2.4.64) or NT_TRANSACT_CREATE Requests (section 2.2.7.1.1).

  • If a Level II OpLock is granted, the server guarantees that no other process is modifying the file and that the client can perform read caching.

  • If an exclusive OpLock is granted, read caching, write caching, and byte-range lock caching can be performed on the client side.

  • If an exclusive batch OpLock is granted, the client can additionally cache file close operations, delaying sending file close operations to the server indefinitely and thus maintaining the client-side cache.

An OpLock remains in effect until the server revokes it or the file is closed by the client. For a batch OpLock, the client MAY cache file close operations from the application. The batch OpLock is released when the client performs the close operation.

Detailed information regarding OpLock semantics is provided in [FSBO].