How do you enable "location based readdir cookies" for gfs2 filesystems exported via NFS?

Solution Unverified - Updated

Environment

  • Red Hat Enterprise Linux Server 6 (with the High Availability and Resilient Storage Add Ons)
  • Red Hat Enterprise Linux Server 7 (with the High Availability and Resilient Storage Add Ons)
  • A gfs2 filesystem that is exported with NFS

Issue

  • How do you enable "location based readdir cookies" for gfs2 filesystems exported via NFS?

Resolution

The mount option loccookie for gfs2 filesystems is used to enable "location based readdir cookies" (instead of hash-based cookies) when the gfs2 filesystem is being exported by NFS. The "location based readdir cookies" prevent duplicate NFS cookies from occurring.

When first enabling the mount option loccookie for gfs2 filesystems on a filesystem that had been previously mounted without it, you must make sure that there are no outstanding cookies are being cached by other software, such as NFS which requires that the NFS server service is restarted.

The mount option loccookie can be enabled when the filesystem is mounted or remounted. Then the nfs service should be restarted. For example on RHEL 6:

# mount -o "noatime,loccookie" /dev/mapper/vgShared1-lv1 /mnt/gfs2lvol1
# service nfs restart

This mount option loccookie for gfs2 filesystems was added to resolve the following: When listing a directory on an NFS share, directory listing fails half way through with 'ls: reading directory .: Too many levels of symbolic links'

Root Cause

When exporting a gfs2 filesystems via NFS hash cookies are used uniqueness, but there is no guarantee of uniqueness. Readdir cookies allow multiple readdirs() to read all of the files in a directory without returning duplicates. While most applications will continue to work correctly if multiple files in a directory have the same cookies, NFS will not. It requires every file in a directory to have a unique readdir cookie. As the number of files in a directory increases, so does the likelihood of a collision. When directories get very large (over 100,000 files), collisions are likely.

SBR
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.