3.3.5.14 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<366> validate the open before session verification.

The server MUST locate the Session, as specified in section 3.3.5.2.9.

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

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 Open.IsPersistent is FALSE and Open.IsReplayEligible is TRUE, the server MUST set Open.IsReplayEligible to FALSE.

If Connection.Dialect is not "2.0.2", 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[LockSequenceIndex].Valid is FALSE, the server MUST continue lock/unlock processing. Otherwise, if Open.IsResilient or Open.IsDurable or Open.IsPersistent is TRUE or if Connection.Dialect belongs to the SMB 3.x dialect family and Connection.ServerCapabilities includes SMB2_GLOBAL_CAP_MULTI_CHANNEL bit, the server SHOULD<367> perform lock sequence verification by comparing LockSequenceNumber to the SequenceNumber located above. If the sequence numbers are not equal, the server MUST reset the entry by setting Open.LockSequenceArray[LockSequenceIndex].Valid to FALSE and continue with regular processing. If the sequence numbers are equal, success is returned to the client without further 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:

  • STATUS_SUCCESS

  • STATUS_INSUFFICIENT_RESOURCES

  • STATUS_ACCESS_DENIED

  • STATUS_FILE_CLOSED

  • STATUS_NETWORK_NAME_DELETED

  • STATUS_USER_SESSION_DELETED

  • STATUS_NETWORK_SESSION_EXPIRED

  • STATUS_INVALID_PARAMETER

  • STATUS_FILE_LOCK_CONFLICT

  • STATUS_CANCELLED

  • STATUS_LOCK_NOT_GRANTED

  • STATUS_RANGE_NOT_LOCKED