XFS
| Company type | File system |
|---|---|
| Industry | Computer software |
| Founded | 1993 |
| Founder | Silicon Graphics, Inc. (SGI) |
| Products | Journaling file system optimized for 64-bit environments |
XFS is a robust journaling file system optimized for 64-bit environments, originally created by Silicon Graphics, Inc (SGI) in 1993. It served as the standard file system for SGI's IRIX operating system beginning with version 5.3. The file system was later adapted for the Linux kernel in 2001 and, by June 2014, gained widespread support across numerous Linux distributions; notably, Red Hat Enterprise Linux designated it as the default file system.
Designed around the concept of allocation groups (AGs), which segment physical storage into smaller units, XFS delivers exceptional parallel input/output (I/O) performance. This architecture allows for significant scalability in terms of I/O threads, overall file system throughput, and capacity across multiple storage devices. Data integrity is preserved through journaling of metadata, and XFS also supports write barriers to ensure write order. File space is allocated using extents, organized via B+ tree structures, which boosts efficiency especially when handling large files. Additional capabilities include delayed allocation to minimize fragmentation and the ability to perform online defragmentation.
Initial development of XFS
In 1993, Silicon Graphics initiated work on XFS[1] as a file system for its UNIX System V-based IRIX operating system. The source code was released under the terms of the GNU General Public License (GPL) in May 1999.[2]
Porting XFS to Linux
Under the direction of Steve Lord, SGI undertook porting XFS to the Linux platform,[3] with initial inclusion in Linux distributions occurring in 2001 and expanding steadily afterward.
Integration of XFS into the mainline Linux kernel began with the 2.6 series and was backported into version 2.4.25 of the 2.4 series in February 2004,[4] thereby making it accessible on a broad range of Linux platforms.[5] By mid-2002, Gentoo Linux became the first distribution to provide XFS as a selectable default filesystem option.[6]
FreeBSD added read-only compatibility with XFS in December 2005 and introduced experimental write functionality in June 2006 primarily aimed at facilitating migration from Linux; nonetheless, support for XFS was eventually removed in FreeBSD 10.[7]
In 2009, kernel-level support for creating and managing XFS filesystems was incorporated into version 5.4 of the 64-bit Red Hat Enterprise Linux (RHEL), although command-line utilities were not included by default and had to be obtained through CentOS or directly from Red Hat.[8] RHEL 6.0 (2010) offered XFS as a commercially supported "scalable file system add-on".[9] Similarly, optional XFS support was included with Oracle Linux 6 (2011).[10]
With the release of RHEL 7.0 in June 2014, XFS became the default filesystem,[11] including enhanced support that allowed deployment on the /boot partition—resolving earlier bootloader constraints.[12]
The Linux kernel version 4.8, released in August 2016, introduced a "reverse mapping" feature within XFS which paved the way for advanced capabilities such as snapshots, copy-on-write operations, deduplication processes, reflink copies, online scrubbing routines, detailed data loss diagnostics, and improved recovery mechanisms—necessitating updates to the on-disk format.[13][14]
Third generation XFS
With the release of Linux kernel 5.10 in December 2020, XFS introduced a new on-disk format known as XFS v5, representing a significant departure since it is not backward compatible with XFS v4. To transition from XFS v4 to v5, users must back up all existing data because reformatting to XFS v5 results in complete data loss. Additionally, support for the older XFS v4 format is scheduled for removal from the Linux kernel by September 2030.
XFS version 5 incorporates the "bigtime" feature, which records inode timestamps using a 64-bit nanosecond counter instead of the previous 32-bit seconds counter, effectively postponing the Year 2038 issue until the year 2486. This version also introduces metadata checksumming for improved reliability.
Since June 2023, the Gentoo Handbook has designated XFS as the preferred "all-purpose all-platform filesystem," replacing Ext4 as the recommended default.
Capacity
As a 64-bit file system, XFS supports an immense maximum size of up to 8 exbibytes minus one byte (263 − 1 bytes), although operating system restrictions may impose lower limits. On 32-bit Linux platforms, both file and file system sizes are capped at 16 tebibytes.
Journaling
XFS employs journaling specifically for file system metadata by initially recording changes in a sequential journal before applying them to disk blocks. This journal acts as a circular buffer and can be stored either internally or externally on a separate device to minimize disk contention.
The journal entries detail modifications to disk block segments, and updates are performed asynchronously to preserve system performance. In the event of a crash, any operations recorded but not completed are automatically replayed during the next mount, maintaining data integrity. The duration of recovery depends on how many operations need replaying rather than the total size of the file system.
Allocation groups
The XFS file system is partitioned into allocation groups, which are equally sized linear sections that independently manage their own inodes and free space. Files and directories can extend across multiple allocation groups, facilitating scalability and enabling concurrent I/O operations by multiple threads or processes.
This architecture enhances parallel I/O efficiency on multi-core or multi-processor systems by distributing metadata updates across allocation groups. Furthermore, allocation groups improve throughput when the file system spans several physical devices, optimizing the utilization of storage hardware.
Striped allocation
When formatting an XFS file system on a striped RAID setup, specifying a stripe unit ensures that data allocations, inode placements, and the internal log align with stripe boundaries. This alignment boosts throughput and enhances performance on RAID-based storage configurations.
Extent-based allocation
XFS handles file block management through variable-length extents, each representing contiguous block ranges. This approach reduces overhead compared to tracking individual blocks.
Instead of relying on block-oriented bitmaps, each allocation group uses two B+ tree structures—one keyed by free extent length and another by starting block number—which facilitates efficient allocation of free extents and improves overall file system performance.
Variable block sizes
Supporting block sizes from 512 bytes up to 64 KB, XFS allows configuration tailored to specific workloads. Smaller block sizes optimize storage efficiency for numerous small files, whereas larger blocks enhance performance for environments predominantly dealing with large files.
Deferred allocation
XFS utilizes a lazy allocation approach for file storage. When data is initially written to the buffer cache, it reserves space without immediately assigning extents. The actual allocation of disk blocks takes place during the flush to disk process, which enhances the chance of writing contiguous blocks, minimizes fragmentation, and improves overall system performance.
Sparse files
With support for a 64-bit sparse address space per file, XFS can handle extremely large files featuring unallocated "holes" that consume no physical storage. The file allocation map is maintained compactly through an extent map; if this map grows too large for the inode, it transitions to a B+ tree structure to allow efficient access across the full 64-bit address range.
Extended attributes
XFS incorporates extended attributes, enabling multiple named data streams within a single file using name/value pairs. Names are nul-terminated strings with a maximum length of 256 bytes, while values can contain up to 64 KB of binary data. Attributes are categorized into root (modifiable exclusively by the superuser) and user namespaces (modifiable by authorized users). These extended attributes apply universally to all inode types, including symbolic links and directories. Command-line management is facilitated through the attr utility, and backup and restoration of these attributes are supported by xfsdump and xfsrestore, features often absent in alternative backup solutions.
Direct I/O
To optimize disk throughput, XFS provides direct I/O capabilities that bypass the cache layer, enabling direct data transfer between application buffers and disk via DMA. This approach allows applications with critical performance needs to fully exploit the underlying disk I/O bandwidth.
Snapshots
Native snapshot functionality is not currently available in XFS; instead, it depends on volume managers for snapshot implementation. The process involves suspending I/O operations using xfs_freeze, executing the snapshot at the volume manager level, then resuming I/O activity. Snapshots can be mounted as read-only volumes for backup purposes.
Earlier versions of IRIX integrated the XLV volume manager with XFS; however, XLV was not ported to Linux systems, which typically use Logical Volume Manager (LVM). Modern Linux kernels incorporate xfs_freeze within the VFS layer, automatically triggered during volume manager snapshot operations. This feature once provided an advantage over ext3, which lacked freeze support necessary for consistent hot snapshots on busy database systems. Since Linux kernel 2.6.29, freeze support has been adopted by ext3, ext4, GFS2, and JFS as well.
Online defragmentation
Although XFS’s extent-based structure and deferred allocation reduce fragmentation significantly, it offers the xfs_fsr tool to perform defragmentation on mounted and active filesystems, helping maintain optimal performance and system health.
Online expansion
The xfs_growfs utility allows XFS filesystems to be expanded while online, provided there is unallocated space available on the device. This functionality is frequently used alongside volume management solutions to avoid the need for separate partition resizing procedures.
DMAPI
Within IRIX environments, XFS supports the DMAPI interface designed for Hierarchical Storage Management. While Linux implementations provide on-disk metadata support for DMAPI, kernel-level functionality remains underdeveloped due to discontinued maintenance of earlier SGI development efforts.
Guaranteed-rate I/O
Exclusive to XFS, the guaranteed-rate I/O interface enables applications to allocate filesystem bandwidth through real-time assessments of the storage system's performance. It offers both "hard" and "soft" reservation options, catering mainly to real-time use cases such as video streaming. Initially, this capability was limited to IRIX systems and required dedicated hardware components.
Limitations
- As of 2023, shrinking XFS filesystems in place is not supported, although certain alternative methods are available.
- Disabling journaling is not possible; however, XFS allows the journal to be maintained externally on a separate block device.
Past Limitations
- Older iterations of XFS experienced slower metadata handling compared to more recent journaling filesystems, which affected operations like bulk file deletions. The implementation of delayed logging starting with Linux kernel version 2.6.39 greatly enhanced metadata throughput, delivering performance on par with or surpassing ext4 when under heavy multithreaded workloads.
See also
- Comparison of file systems
- CXFS
- List of file systems
- List of default file systems
- Stratis (configuration daemon)
Further reading
- Scalability in the XFS Filesystem (Original XFS research paper presented at Usenix 1996 Annual Technical Conference)
External links
- The XFS Linux wiki, up-to-date community resource
- XFS.org, archived community wiki
- crossmeta.org, archived project focused on XFS support for Windows
- ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).
- ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).
- ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).
- ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).
- ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).
- ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).
- ↑ Cite error: Invalid
<ref>tag; no text was provided for refs namedfreebsdremoved - ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).
- ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).
- ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).
- ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).
- ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).
- ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).
- ↑ Lua error in Module:Citation/CS1/Configuration at line 2123: attempt to index field '?' (a nil value).