Understanding z/OS UNIX System Services latch contention

This section is designed to help you understand the global resource serialization latches that the z/OS UNIX System Services logical file system (LFS) uses to provide serialization for file systems. It also contains procedure to help you diagnose and resolve mount latch contention and file system latch contention in this section. See Procedure: Diagnosing and resolving latch contention.

The z/OS UNIX System Services LFS uses three levels of global resource serialization latches to provide serialization for file systems:
  • Mount latch: The mount latch provides serialization for operations involving the LFS and is the latch number two in the SYS.BPX.A000.FSLIT.FILESYS.LSN latch set. The mount latch is obtained exclusively:
    • When a file system is mounted or unmounted.
    • In a sysplex configuration, for operations such as file system moves, lost system recovery, system initialization, and reading from or writing to a couple data set.
    Obtaining the mount latch exclusively ensures that only one of these activities is going on at the same time.

    Use the DISPLAY GRS,LATCH,CONTENTION command to look for mount latch contention.

  • File system latch: There is a latch for each file system mounted. These latches are within the SYS.BPX.A000.FSLIT.FILESYS.LSN latch set. The file system latch is:
    • Obtained exclusively every time that file system is unmounted, synchronized, exported or unexported by the server message block (SMB) server, moved or recovered within a sysplex.
    • Obtained in shared mode for the duration of any operation within the file system, such as reads from or writes to a file. This prevents the file system from being unmounted or moved, for example, while there is an operation in progress on a file within the file system.

    Use the DISPLAY GRS,LATCH,CONTENTION command to look for file system latch contention.

  • File latch: There is file latch associated with each active file or directory. A file latch can be obtained in either exclusive or shared mode, depending on the operation involved. For example, the file latch for a directory would be obtained in shared mode to read a name from the directory. But it would be obtained exclusively to write a name to the directory during a file create operation.

    File latches are not used with the z/OS® File System (zFS) physical file system because the zFS has its own file level serialization mechanisms. File latches are used with shared file system, TFS, pipes, character special, and NFS client physical file systems.

    File latches are in a special group of latches with names in the form of SYS.BPX.A000.FSLIT.LSN.nn, where nn is a hexadecimal number.

    Use the DISPLAY GRS,LATCH,CONTENTION command to look for file latch contention.

In addition to these three levels, the LFS also uses a quiesce latch, which is assigned to any file system that is:
  • Quiesced by the BPX1QSE callable service, which is used by HSM and other utilities to backup or dump file systems.
  • For sysplex operations that operate against the file system as a whole, such as moving and recovering.

When a file system is quiesced, normal operations are suspended, and threads wait suspended for the file system's quiesce latch. The system may hold the quiesce latch for longer than the duration of a system call. Note that HSM does not use the quiesce latch for zFS file systems.

Use the DISPLAY OMVS,FILE command to look for quiesce latch contention on your system.

Diagnosing latch contention: You will know that you have a case of latch contention by symptoms such as the following:
  • One or more systems issue message BPXM056E z/OS UNIX SYSTEM SERVICES LATCH CONTENTION DETECTED
  • z/OS UNIX System Services users are hung
  • z/OS UNIX System Services itself seems to be hung
In general, the key to resolving latch contention lies in finding the latch holder. There are two kinds of z/OS UNIX System Services tasks that can hold a latch, potentially causing contention:
  • User programs: When a user program invokes a file operation, the system obtains the file system latch and possibly the file latch, and holds the latches for the duration of the operation.
  • z/OS UNIX System services (OMVS task): z/OS UNIX System Services may hold the mount latch or a file system latch for more extended periods of time for operations such as system recovery and file system moves.