5 Managing the XFS File System

XFS is a high-performance journaling file system that was initially created by Silicon Graphics, Inc. for the IRIX OS and then later ported to Linux. The parallel I/O performance of XFS provides high scalability for I/O threads, file system bandwidth, file, and file system size, even when the file system spans many storage devices.

A typical use case for XFS is to implement a Tbyte-sized file system across several storage servers, with each server consisting of several FC-connected disk arrays.

XFS can be used with the root (/) or boot file systems on Oracle Linux 9.

XFS has many features that are suitable for deployment in an enterprise-level computing environment that requires the implementation of large file systems:

  • Implements journaling for metadata operations.

    Journaling guarantees the consistency of the file system following loss of power or a system failure. XFS records file system updates asynchronously to a circular buffer (the journal) before it can commit the actual data updates to disk. The journal can be stored either internally in the data section of the file system, or externally on a separate device to reduce contention for disk access. If the system fails or loses power, it reads the journal when the file system is remounted, and replays any pending metadata operations to ensure the consistency of the file system. The speed of this recovery doesn't depend on the size of the file system.

  • Is internally partitioned into allocation groups, which are virtual storage regions of fixed size.

    Any files and directories that you create can span several allocation groups. Each allocation group manages its own set of inodes and free space independently of other allocation groups to provide both scalability and parallelism of I/O operations. If the file system spans many physical devices, allocation groups can optimize throughput by taking advantage of the underlying separation of channels to the storage components.

  • Is an extent-based file system.

    To reduce file fragmentation and file scattering, each file's blocks can have variable length extents, where each extent consists of one or more contiguous blocks. XFS's space allocation scheme is designed to efficiently identify free extents that it can use for file system operations. XFS doesn't allocate storage to the holes in sparse files. If possible, the extent allocation map for a file is stored in its inode. Large allocation maps are stored in a data structure maintained by the allocation group.

  • Includes the reflink and deduplication features, which provides the following benefits:

    • Each copy can have different file metadata (permissions, and so on) because each copy has its own distinct inode. Only the data extents are shared.

    • The file system ensures that any write causes a copy-on-write, without applications requiring to do anything special.

    • Changing one extent continues to permit all the other extents to remain shared. In this way, space is saved on a per-extent basis. Note, however, that a change to a hard-linked file does require a new copy of the entire file.

  • Implements delayed allocation

    To reduce fragmentation and increase performance, XFS reserves file system blocks for data in the buffer cache, and allocates the block when the OS flushes that data to disk.

  • XFS recognizes extended attributes for files.

    The size of each attribute's value can be up to 64 KB, and each attribute can be allocated to either a root or a username space.

  • Direct I/O in XFS implements high throughput, noncached I/O.

    XFS performs DMA directly between an application and a storage device, using the full I/O bandwidth of the device.

  • Includes the snapshot facilities that volume managers, hardware subsystems, and databases provide.

    Use the xfs_freeze command to suspend and resume I/O for an XFS file system. See Freezing and Unfreezing an XFS File System.

  • XFS enables user, group, and project disk quotas on block and inode usage that are initialized when the file system is mounted. Project disk quotas enable you to set limits for individual directory hierarchies within an XFS file system without regard to which user or group has write access to that directory hierarchy.

To maximize throughput for XFS file systems that you create on an underlying striped software or hardware based array, you can use the su and sw arguments to the -d option of the mkfs.xfs command to specify the size of each stripe unit and the number of units per stripe. XFS uses the information to align data, inodes, and journal appropriately for the storage. On lvm and md volumes and some hardware RAID configurations, XFS can automatically select the best stripe parameters for you.

To defragment individual files in an active XFS file system, you can use the xfs_fsr command. See Defragmenting an XFS File System.

To grow an XFS file system, you can use the xfs_growfs command. See Growing an XFS File System.

To back up and restore a live XFS file system, you can use the xfsdump and xfsrestore commands. See Backing Up and Restoring an XFS File System.

For more information about XFS, see https://xfs.wiki.kernel.org/.

For an overview of local file system management, see About File System Management.