Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

2.9.3. Troubleshooting GFS2 Performance with the GFS2 Lock Dump

If your cluster performance is suffering because of inefficient use of GFS2 caching, you may see large and increasing I/O wait times. You can make use of GFS2's lock dump information to determine the cause of the problem.
This section provides an overview of the GFS2 lock dump. For a more complete description of the GFS2 lock dump, see Appendix C, GFS2 tracepoints and the debugfs glocks File.
The GFS2 lock dump information can be gathered from the debugfs file which can be found at the following path name, assuming that debugfs is mounted on /sys/kernel/debug/:
/sys/kernel/debug/gfs2/fsname/glocks
The content of the file is a series of lines. Each line starting with G: represents one glock, and the following lines, indented by a single space, represent an item of information relating to the glock immediately before them in the file.
The best way to use the debugfs file is to use the cat command to take a copy of the complete content of the file (it might take a long time if you have a large amount of RAM and a lot of cached inodes) while the application is experiencing problems, and then looking through the resulting data at a later date.

Note

It can be useful to make two copies of the debugfs file, one a few seconds or even a minute or two after the other. By comparing the holder information in the two traces relating to the same glock number, you can tell whether the workload is making progress (that is, it is just slow) or whether it has become stuck (which is always a bug and should be reported to Red Hat support immediately).
Lines in the debugfs file starting with H: (holders) represent lock requests either granted or waiting to be granted. The flags field on the holders line f: shows which: The 'W' flag refers to a waiting request, the 'H' flag refers to a granted request. The glocks which have large numbers of waiting requests are likely to be those which are experiencing particular contention.
Table 2.1, “Glock flags” shows the meanings of the different glock flags and Table 2.2, “Glock holder flags” shows the meanings of the different glock holder flags in the order that they appear in the glock dumps.

Table 2.1. Glock flags

FlagNameMeaning
bBlockingValid when the locked flag is set, and indicates that the operation that has been requested from the DLM may block. This flag is cleared for demotion operations and for "try" locks. The purpose of this flag is to allow gathering of stats of the DLM response time independent from the time taken by other nodes to demote locks.
dPending demoteA deferred (remote) demote request
DDemoteA demote request (local or remote)
fLog flushThe log needs to be committed before releasing this glock
FFrozenReplies from remote nodes ignored - recovery is in progress. This flag is not related to file system freeze, which uses a different mechanism, but is used only in recovery.
iInvalidate in progressIn the process of invalidating pages under this glock
IInitialSet when DLM lock is associated with this glock
lLockedThe glock is in the process of changing state
LLRUSet when the glock is on the LRU list
oObjectSet when the glock is associated with an object (that is, an inode for type 2 glocks, and a resource group for type 3 glocks)
pDemote in progressThe glock is in the process of responding to a demote request
qQueuedSet when a holder is queued to a glock, and cleared when the glock is held, but there are no remaining holders. Used as part of the algorithm the calculates the minimum hold time for a glock.
rReply pendingReply received from remote node is awaiting processing
yDirtyData needs flushing to disk before releasing this glock

Table 2.2. Glock holder flags

FlagNameMeaning
aAsyncDo not wait for glock result (will poll for result later)
AAnyAny compatible lock mode is acceptable
cNo cacheWhen unlocked, demote DLM lock immediately
eNo expireIgnore subsequent lock cancel requests
EexactMust have exact lock mode
FFirstSet when holder is the first to be granted for this lock
HHolderIndicates that requested lock is granted
pPriorityEnqueue holder at the head of the queue
tTryA "try" lock
TTry 1CBA "try" lock that sends a callback
WWaitSet while waiting for request to complete
Having identified a glock which is causing a problem, the next step is to find out which inode it relates to. The glock number (n: on the G: line) indicates this. It is of the form type/number and if type is 2, then the glock is an inode glock and the number is an inode number. To track down the inode, you can then run find -inum number where number is the inode number converted from the hex format in the glocks file into decimal.

Note

If you run the find on a file system when it is experiencing lock contention, you are likely to make the problem worse. It is a good idea to stop the application before running the find when you are looking for contended inodes.
Table 2.3, “Glock types” shows the meanings of the different glock types.

Table 2.3. Glock types

Type numberLock typeUse
1TransTransaction lock
2InodeInode metadata and data
3RgrpResource group metadata
4MetaThe superblock
5IopenInode last closer detection
6Flockflock(2) syscall
8QuotaQuota operations
9JournalJournal mutex
If the glock that was identified was of a different type, then it is most likely to be of type 3: (resource group). If you see significant numbers of processes waiting for other types of glock under normal loads, then report this to Red Hat support.
If you do see a number of waiting requests queued on a resource group lock there may be a number of reason for this. One is that there are a large number of nodes compared to the number of resource groups in the file system. Another is that the file system may be very nearly full (requiring, on average, longer searches for free blocks). The situation in both cases can be improved by adding more storage and using the gfs2_grow command to expand the file system.