Atomic Test & Set (ATS)
In VMware vSphere VMFS, many operations must establish a lock on the volume when updating a resource.
Because VMFS is a clustered file system, many ESXi hosts can share the volume. When one host must make an
update to the VMFS metadata, a locking mechanism is required to maintain file system integrity and prevent
another host from coming in and updating the same metadata. The following operations require this lock:
1. Acquire on-disk locks
2. Upgrade an optimistic lock to an exclusive/physical lock
3. Unlock a read-only/multiwriter lock
4. Acquire a heartbeat
5. Clear a heartbeat
6. Replay a heartbeat
7. Reclaim a heartbeat
8. Acquire on-disk lock with dead owner
It is not essential to understand all of these operations in the context of this whitepaper. It is sufficient to
understand that various VMFS metadata operations require a lock.
ATS is an enhanced locking mechanism designed to replace the use of SCSI reservations on VMFS volumes
when doing metadata updates. A SCSI reservation locks a whole LUN and prevents other hosts from doing
metadata updates of a VMFS volume when one host sharing the volume has a lock. This can lead to various
contention issues when many virtual machines are using the same datastore. It is a limiting factor for scaling to
very large VMFS volumes. ATS is a lock mechanism that must modify only a disk sector on the VMFS volume.
When successful, it enables an ESXi host to perform a metadata update on the volume. This includes allocating
space to a VMDK during provisioning, because certain characteristics must be updated in the metadata to
reflect the new size of the file. The introduction of ATS addresses the contention issues with SCSI reservations
and enables VMFS volumes to scale to much larger sizes.
In vSphere 4.0, VMFS3 used SCSI reservations for establishing the lock, because there was no VAAI support in
that release. In vSphere 4.1, on a VAAI-enabled array, VMFS3 used ATS for only operations 1 and 2 listed
previously, and only when there was no contention for disk lock acquisitions. VMFS3 reverted to using SCSI
reservations if there was a multihost collision when acquiring an on-disk lock using ATS.
In the initial VAAI release, the ATS primitives had to be implemented differently on each storage array, requiring
a different ATS opcode depending on the vendor. ATS is now a standard T10 SCSI command and uses opcode
0x89 (COMPARE AND WRITE).
For VMFS5 datastores formatted on a VAAI-enabled array, all the critical section functionality from operations 1
to 8 is done using ATS. There no longer should be any SCSI reservations on VAAI-enabled VMFS5. ATS continues
to be used even if there is contention. On non-VAAI arrays, SCSI reservations continue to be used for
establishing critical sections in VMFS5.


