3.3.5.14.2 Processing Locks
If the Locks array has more than one entry and the Flags field in any of these entries does not have SMB2_LOCKFLAG_FAIL_IMMEDIATELY set, the server SHOULD<370> fail the request with STATUS_INVALID_PARAMETER. For each SMB2_LOCK_ELEMENT entry in the Locks array, if SMB2_LOCKFLAG_UNLOCK is set, the server MUST fail the request with STATUS_INVALID_PARAMETER and stop processing further entries in the Locks array. All successfully processed Lock operations are not rolled back. For combinations of Lock Flags other than those that are defined in the Flags field of section 2.2.26.1, the server SHOULD fail the request with STATUS_INVALID_PARAMETER.
The server MUST issue a byte-range lock request to the underlying object store using Open.LocalOpen and passing the Offset and Length (in bytes) from the SMB2_LOCK_ELEMENT entry.<371> If SMB2_LOCKFLAG_SHARED_LOCK is set, the lock MUST be acquired in a manner that allows read operations and other shared lock operations from other opens, but disallows writes to the region specified by the lock. If SMB2_LOCKFLAG_EXCLUSIVE_LOCK is set, the lock MUST be acquired in a manner that does not allow read, write, or lock operations from other opens for the range specified.<372>
If the range being locked is already locked by another open in a way that does not allow this open to take a lock on the range, and if SMB2_LOCKFLAG_FAIL_IMMEDIATELY is set, the server MUST fail the request with STATUS_LOCK_NOT_GRANTED and MUST unlock any ranges locked as part of processing the previous entries in the Locks array of this request. It MUST decrement Open.LockCount by the number of locks unlocked. It MUST stop processing any remaining entries in the Locks array and MUST fail the operation with the error code received from the lock operation.
Otherwise, the server MUST increase Open.LockCount by 1. If there are remaining entries in the Locks array, the server MUST continue processing the next entry in the Locks array as described previously.
If Connection.Dialect is not "2.0.2" and if Open.IsResilient or Open.IsDurable, or Open.IsPersistent is TRUE or Connection.ServerCapabilities includes SMB2_GLOBAL_CAP_MULTI_CHANNEL bit, the server MUST set Valid to TRUE and set SequenceNumber to LockSequenceNumber in the entry specified by Open.LockSequenceArray[LockSequenceIndex] to indicate that the lock request has been successfully processed by the server.
The server MUST construct an SMB2 LOCK Response following the syntax specified in section 2.2.27, and the SMB2 LOCK Response MUST be sent to the client.