Receiving an SMB2 LOCK Request

When the server receives a request that has an SMB2 header (section 2.2.1) with a Command value equal to SMB2 LOCK, message handling proceeds as follows:

The server MAY<308> validate the open before session verification.

The server MUST locate the Session, as specified in section

The server MUST locate the Tree Connect, as specified in section

Next, the server MUST locate the Open on which the client is requesting a lock or unlock by performing a lookup in the Session.OpenTable, using the FileId.Volatile of the request as the lookup key. If no Open is found, or if Open.DurableFileId is not equal to FileId.Persistent, the server MUST fail the request with STATUS_FILE_CLOSED. Otherwise, the server MUST locate the Request in Connection.RequestList for which Request.MessageId matches the MessageId value in the SMB2 header, and set Request.Open to the Open.

If the LockSequence value in the SMB2 LOCK Request (section 2.2.26) is not zero, and either one of the following conditions is TRUE, the server SHOULD verify whether the lock/unlock request with that LockSequence value has been successfully processed before:

  • Connection.Dialect is "2.1" and Open.IsResilient is TRUE.

  • Connection.Dialect belongs to the SMB 3.x dialect family.<309>

The server verifies the LockSequence by performing the following steps:

  1. The server MUST use LockSequenceIndex as an index into Open.LockSequenceArray in order to locate the sequence number entry. If the index exceeds the maximum extent of the Open.LockSequenceArray, or LockSequenceIndex is 0, or if the Open.LockSequenceArray.Valid is FALSE, the server MUST skip step 2 and continue lock/unlock processing.

  2. The server MUST compare LockSequenceNumber to the SequenceNumber of the entry located in step 1. If the sequence numbers are equal, the server MUST complete the lock/unlock request with success. Otherwise, the server MUST reset the entry by setting Valid to FALSE and continue lock/unlock processing.

If the flags of the initial SMB2_LOCK_ELEMENT in the Locks array of the request has SMB2_LOCKFLAG_UNLOCK set, the server MUST process the lock array as a series of unlocks. Otherwise, it MUST process the lock array as a series of lock requests.

The status code returned by this operation MUST be one of those defined in [MS-ERREF]. Common status codes returned by this operation include: