Jump to content

XFS: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m Online resizing: one year later; nothing new
Back in 2019 someone changed all the attributions to the long standing (and still current) XFS developer Dave Chinner to "John Nelson". Fix the attributions to be correct again.
 
(385 intermediate revisions by more than 100 users not shown)
Line 1: Line 1:
{{Short description|Journaling file system}}
{{otheruses}}
{{distinguish|Xiafs}}
{{other uses}}


{{Infobox Filesystem
{{Infobox filesystem
|name = XFS
| name = XFS
|full_name = XFS
| full_name = XFS
|developer = [[Silicon Graphics Inc.]]
| developer = {{Unbulleted list | [[Silicon Graphics]] | [[Red Hat]]}}
|introduction_os = [[IRIX]] v5.3
| introduction_os = [[IRIX]] 5.3
|introduction_date = 1994
| introduction_date = {{Start date and age|1994}}
|partition_id =
| partition_id = {{unbulleted list
| '''[[Master boot record|MBR]]''': 0x83: Linux filesystem
|directory_struct = [[B+ tree]]s
| '''[[GUID Partition Table|GPT]]''': 0FC63DAF-8483-4772-8E79-3D69D8477DE4: Linux filesystem<ref>{{Cite web|url=https://wiki.archlinux.org/index.php/GPT_fdisk|title = GPT fdisk - ArchWiki}}</ref>
|file_struct = [[B+ tree]]s
}}
|bad_blocks_struct =
| directory_struct = [[B+ tree]]s
|max_filename_size = 255 [[byte]]s
| file_struct = B+ trees
|max_files_no =
| bad_blocks_struct =
|max_volume_size = 16 [[exabyte]]s
| max_filename_size = 255&nbsp;[[byte]]s
| max_file_size = 8 [[exabyte]]s <br/> (minus 1 byte)
| max_volume_size = 8&nbsp;[[exbibyte]]s&nbsp;− 1 byte
|filename_character_set = All bytes except NUL
| max_file_size = 8&nbsp;[[exbibyte]]s&nbsp;− 1 byte
|dates_recorded = Yes
| max_files_no = 2<sup>64</sup><ref>{{cite web
|date_range =
| url = https://www.quora.com/What-is-the-maximum-number-of-inodes-in-Linux-filesystems-I-found-suggestion-that-for-Ext4-it-is-4-billion-files-32-bit-number-Is-it-true-for-XFS-and-or-BtrFS
|date_resolution = 1ns
| title = What is the maximum number of inodes in Linux filesystems?
|forks_streams =
| date = 2014-06-17}}</ref>
|attributes = Yes
| filename_character_set = All except NUL and "/"
|file_system_permissions = Yes
| dates_recorded = atime, mtime, ctime,<ref name="xfsfs">{{cite web
|compression = No
| title = XFS Filesystem Structure 2nd Edition, Revision 1
|single_instance_storage = No
| url = http://oss.sgi.com/projects/xfs/papers/xfs_filesystem_structure.pdf#page=25
|encryption = No (provided at the block device level)
| page = 25
|OS = [[IRIX]], [[Linux]], [[FreeBSD]]&nbsp;(experimental)
| format = PDF
| archive-url = https://web.archive.org/web/20171031110501/http://oss.sgi.com/projects/xfs/papers/xfs_filesystem_structure.pdf#page=25
| archive-date = 2017-10-31}}</ref> version 5: crtime<ref>{{cite web
| url = https://git.kernel.org/pub/scm/fs/xfs/xfs-documentation.git/tree/design/XFS_Filesystem_Structure/ondisk_inode.asciidoc
| title = ondisk_inode.asciidoc\XFS_Filesystem_Structure\design - xfs/xfs-documentation.git - XFS AsciiDoc Documentation tree
| website = git.kernel.org}}</ref>
|date_range = December 13, 1901 – July 2, 2486<ref name="bigtime">{{cite web
| url = https://lwn.net/Articles/829314/
| title = xfs: widen timestamps to deal with y2038
| author = Darrick J. Wong
| date = 2020-08-10}}</ref>
| date_resolution = 1&nbsp;ns
| forks_streams =
| attributes = Yes
| file_system_permissions = Yes
| compression = No
| single_instance_storage = Experimental, Linux only<ref>{{cite web
| url = https://github.com/markfasheh/duperemove
| title = Duperemove
| work = [[GitHub]]
| access-date = 21 August 2016
| archive-url = https://web.archive.org/web/20160306015221/https://github.com/markfasheh/duperemove
| archive-date = 6 March 2016
| url-status = live
}}</ref>
| encryption = No (provided at the block device level)
| OS = {{Unbulleted list|[[IRIX]]|[[Linux]]}}
| variants =
}}
}}

'''XFS''' is a high-performance [[journaling file system]] created by [[Silicon Graphics]], originally for their [[IRIX]] [[operating system]] and later ported to the [[Linux kernel]]. XFS is particularly proficient at handling large files and at offering smooth [[data transfer]]s.
'''XFS''' is a high-performance [[64-bit computing|64-bit]] [[journaling file system]] created by [[Silicon Graphics, Inc.|Silicon Graphics, Inc]] (SGI) in 1993.<ref>{{cite web |url=http://xfs.org/docs/xfsdocs-xml-dev/XFS_User_Guide/tmp/en-US/html/ch01s02.html |title=xFS: The Extension of EFS - "x" for To-be-Determined (but the Name Stuck) |archive-url=https://web.archive.org/web/20140714224038/http://xfs.org/docs/xfsdocs-xml-dev/XFS_User_Guide/tmp/en-US/html/ch01s02.html |archive-date=2014-07-14 |website=XFS.org}}</ref> It was the default file system in SGI's [[IRIX]] operating system starting with its version 5.3. XFS was ported to the [[Linux kernel]] in 2001; as of June 2014, XFS is supported by most [[Linux distribution]]s; [[Red Hat Enterprise Linux]] uses it as its default file system.

XFS excels in the execution of parallel [[input/output]] (I/O) operations due to its design, which is based on [[allocation group]]s (a type of subdivision of the physical volumes in which XFS is used- also shortened to ''AGs''). Because of this, XFS enables extreme scalability of I/O threads, file system bandwidth, and size of files and of the file system itself when spanning multiple physical storage devices. XFS ensures the consistency of data by employing [[metadata]] [[Journaling file system|journaling]] and supporting [[write barrier]]s. Space allocation is performed via [[Extent (file systems)|extents]] with data structures stored in [[B+ tree]]s, improving the overall performance of the file system, especially when handling large files. [[Delayed allocation]] assists in the prevention of file system fragmentation; online [[defragmentation]] is also supported.


==History==
==History==
=== First generation XFS ===
Development of XFS was started by [[Silicon Graphics]] in 1993, with first deployment being seen on IRIX 5.3 in 1994. The filesystem was released under the [[GNU General Public License]] in May 2000, and ported to Linux, with the first distribution support appearing in 2001. It is available in almost all Linux distributions today.
[[Silicon Graphics]] began development of XFS<ref>{{cite book
|last1 = Smith
|first1 = Roderick W.
|title = Linux Administrator Street Smarts: A Real World Guide to Linux Certification Skills
|url = https://books.google.com/books?id=Ll_ETPXJE5wC
|series = Street smarts series
|publisher = John Wiley & Sons
|date = 2007
|page = 204
|isbn = 9780470116746
|access-date = 2016-03-21
|quote = Silicon Graphics (SGI) created its ''Extents File System (XFS)'' for its IRIX OS and [...] later donated the code to Linux.
|archive-url = https://web.archive.org/web/20160821163053/https://books.google.com/books?id=Ll_ETPXJE5wC
|archive-date = 2016-08-21
|url-status = live
}}</ref> ("X" was meant to be filled in later but never was) in 1993 for its [[UNIX System V]] based [[IRIX]] operating system. The file system was released under the [[GNU General Public License]] (GPL) in May 1999.<ref>{{cite web | url= https://slashdot.org/story/99/05/20/0243235/sgi-open-sourcing-xfs | title= SGI open-sourcing XFS | website= [[slashdot.org]] | date= 1999-05-19 | access-date= 2023-04-12 }}</ref>

=== Second generation XFS ===
A team led by Steve Lord at SGI ported XFS to Linux,<ref>{{cite web | url= http://olstrans.sourceforge.net/release/OLS2000-xfs/OLS2000-xfs.html | title= Porting XFS to Linux | website= Olstrans.SourceForge.net | date= 2000-07-21 | access-date= 2013-04-29 | archive-url= https://web.archive.org/web/20130225112334/http://olstrans.sourceforge.net/release/OLS2000-xfs/OLS2000-xfs.html | archive-date= 2013-02-25 | url-status= live }}</ref> and first support by a [[Linux distribution]] came in 2001. This support gradually became available in almost all Linux distributions.{{citation needed|date=March 2016}}

Initial support for XFS in the Linux kernel came through [[Patch (computing)|patches]] from SGI. It merged into the [[Linux kernel mainline]] for the 2.6 series, and separately merged in February 2004 into the 2.4 series in version 2.4.25,<ref>{{cite web | url= https://www.kernel.org/pub/linux/kernel/v2.4/ChangeLog-2.4.25 | title= Linux kernel 2.4.25 changelog | website= [[kernel.org]] | date= 2004-02-18 | access-date= 2014-08-14 | archive-url= https://web.archive.org/web/20140819083123/https://www.kernel.org/pub/linux/kernel/v2.4/ChangeLog-2.4.25 | archive-date= 2014-08-19 | url-status= live }}</ref> making XFS almost universally available on Linux systems.<ref>{{cite web |title= Common threads: Advanced filesystem implementor's guide, Part 9, Introducing XFS |author= Daniel Robbins |work= Developer Works |publisher= IBM |date= January 1, 2002 |url= http://www.ibm.com/developerworks/library/l-fs9/index.html | access-date=November 6, 2011 | url-status= dead | archive-url= https://web.archive.org/web/20150904032700/http://www.ibm.com/developerworks/library/l-fs9/index.html| archive-date= September 4, 2015 }}</ref> [[Gentoo Linux]] became the first [[Linux distribution]] to introduce an option for XFS as the default filesystem in mid-2002.<ref>{{cite web | title = Common threads: Advanced filesystem implementor's guide, Part 10, Deploying XFS | author = Daniel Robbins | work = Developer Works | publisher = IBM | date = April 1, 2002 | url = http://www.ibm.com/developerworks/linux/library/l-fs10/index.html | access-date = November 6, 2011 | archive-url = https://web.archive.org/web/20111224220036/http://www.ibm.com/developerworks/linux/library/l-fs10/index.html | archive-date = December 24, 2011 | url-status = live }}</ref>

[[FreeBSD]] added [[File system permissions|read-only]] support for XFS in December 2005, and in June 2006 introduced experimental write support. However, this was intended only as an aid in migration from Linux, not as a "main" file system. FreeBSD 10 removed support for XFS.<ref name="freebsdremoved">{{cite web | url = http://lists.freebsd.org/pipermail/freebsd-questions/2013-October/254143.html | title = Has FreeBSD 10 Dropped Support For XFS? | website = Lists.freebsd.org | date = 2013-10-27 | access-date = 2014-03-30 | archive-url = https://web.archive.org/web/20140330082123/http://lists.freebsd.org/pipermail/freebsd-questions/2013-October/254143.html | archive-date = 2014-03-30 | url-status = live }}</ref>

In 2009, version 5.4 of 64-bit [[Red Hat Enterprise Linux]] (RHEL) Linux distribution contained the necessary kernel support for the creation and usage of XFS file systems, but lacked the corresponding command-line tools. The tools available from [[CentOS]] could operate for that purpose, and Red Hat also provided them to RHEL customers on request.<ref>{{cite web | title = Bug 521173 -xfsprogs is missing in RHEL-5.4 | date = May 24, 2010 | website = RedHat.com | url = http://bugzilla.redhat.com/show_bug.cgi?id=521173 | access-date = November 6, 2011 | archive-url = https://archive.today/20120710060100/http://bugzilla.redhat.com/show_bug.cgi?id=521173 | archive-date = July 10, 2012 | url-status = live }}</ref> RHEL&nbsp;6.0, released in 2010, includes XFS support for a fee as part of Red Hat's "scalable file system add-on".<ref>{{cite web | title = Red Hat Enterprise Linux Scalable File System Add-On | url = http://ca.redhat.com/products/enterprise-linux-add-ons/file-systems/ | access-date = 2014-05-22 | website = RedHat.com | archive-url = https://web.archive.org/web/20140529025913/http://ca.redhat.com/products/enterprise-linux-add-ons/file-systems/ | archive-date = 2014-05-29 | url-status = live }}</ref> [[Oracle Linux]] 6, released in 2011, also includes an option for using XFS.<ref>{{cite web
|url = https://oss.oracle.com/el6/docs/RELEASE-NOTES-GA-en.html
|title = Oracle Linux 6 Release Notes
|date = February 2011
|publisher = Oracle Corporation
|access-date = 2013-04-07
|quote = Oracle Linux 6 includes many new features, including [...] XFS [:] Oracle Linux 6 includes XFS as an optional filesystem.
|archive-url = https://web.archive.org/web/20120328031356/http://oss.oracle.com/el6/docs/RELEASE-NOTES-GA-en.html
|archive-date = 2012-03-28
|url-status = live
}}</ref>

RHEL&nbsp;7.0, released in June 2014, uses XFS as its default file system,<ref>{{cite web
|url = http://www.redhat.com/about/news/press-archive/2014/6/red-hat-unveils-rhel-7
|title = Red Hat Unveils Red Hat Enterprise Linux 7, Redefining the Enterprise Operating System
|date = 2014-06-10
|access-date = 2014-06-10
|publisher = [[Red Hat]]
|archive-url = https://web.archive.org/web/20140613005526/http://www.redhat.com/about/news/press-archive/2014/6/red-hat-unveils-rhel-7
|archive-date = 2014-06-13
|url-status = live
}}</ref> including support for using XFS for the <code>/boot</code> partition, which previously was not practical due to bugs in the [[GRUB]] bootloader.<ref>{{cite web | title = Bug 250843 -grub-install hangs on xfs | date = May 4, 2009 | website = Redhat.com | url = http://bugzilla.redhat.com/show_bug.cgi?id=250843 | access-date = November 6, 2011 | archive-url = https://archive.today/20120710160608/http://bugzilla.redhat.com/show_bug.cgi?id=250843 | archive-date = July 10, 2012 | url-status = live }}</ref>

Linux kernel 4.8 in August 2016 added a new feature, "reverse mapping". This is the foundation for a large set of planned features: [[Snapshot (computer storage)|snapshots]], [[copy-on-write]] (COW) data, [[data deduplication]], reflink copies, online data and metadata [[Data scrubbing|scrubbing]], highly accurate reporting of data loss or bad sectors, and significantly improved reconstruction of damaged or corrupted filesystems. This work required changes to XFS's on-disk format.<ref>{{cite web|url=https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=0cbbc422d56668528f6efd1234fe908010284082|title=kernel/git/torvalds/linux.git - Linux kernel source tree|website=git.kernel.org}}</ref><ref>{{Cite web |url=https://kernelnewbies.org/Linux_4.8#XFS_reverse_mapping |title=Linux_4.8 - Linux Kernel Newbies |access-date=2018-10-19 |archive-url=https://web.archive.org/web/20181019164144/https://kernelnewbies.org/Linux_4.8#XFS_reverse_mapping |archive-date=2018-10-19 |url-status=live }}</ref>

=== Third generation XFS===
[[File:XFS v4 Linux Kernel Option.jpg|thumb|XFS v4 is deprecated. Partitions have to be reformatted with XFS v5.]]
Linux kernel 5.10, released in December 2020, included the new on-disk format XFS v5. This was a hard break, since the deprecated XFS v4 can not be converted to XFS v5. Data on partitions formatted with XFS v4 has to be backed up to another partition or media in order to restore it after formatting the old partition with XFS v5, which completely wipes all data on it. The support for XFS v4 will be removed from the Linux kernel in September 2030.<ref>https://www.haiku-os.org/docs/develop/file_systems/xfs.html</ref>

XFS v5 introduced "bigtime", to store inode timestamps as a 64-bit nanosecond counter instead of the traditional 32-bit seconds counter. This postpones the previous [[Year 2038 problem]] until the year 2486.<ref name="bigtime"/> It also introduced metadata checksums.

The Gentoo Handbook, [[Gentoo Linux]]'s official installation manual, has recommended XFS as the "all-purpose all-platform filesystem" since 28 Jun 2023, succeeding [[Ext4]].<ref>{{Cite web |title=Difference between revisions of "Handbook:Parts/Installation/Disks" - Gentoo wiki |url=https://wiki.gentoo.org/index.php?title=Handbook:Parts/Installation/Disks&diff=prev&oldid=1248552 |access-date=2024-04-25 |website=wiki.gentoo.org}}</ref>


==Features==
XFS was first merged into mainline [[Linux (kernel)|Linux]] in version 2.4, making it almost universally available on Linux systems. Installation programs for the [[Arch Linux|Arch]], [[Debian]], [[Fedora (operating system)|Fedora]], [[openSUSE]], [[Gentoo Linux|Gentoo]], [[Kate OS]], [[Mandriva]], [[Slackware]], [[Ubuntu Linux|Ubuntu]], [[VectorLinux]] and [[Zenwalk]] [[Linux distributions]] all offer XFS as a choice of filesystem, but few of these let the user create XFS for the /boot filesystems due to deficiencies and unpredictable behavior in [[GNU GRUB|GRUB]], often the default bootloader.<ref>[https://bugzilla.redhat.com/show_bug.cgi?id=250843 Redhat.com]</ref> [[FreeBSD]] gained read-only support for XFS in December 2005 and in June 2006 experimental write support was introduced; however this is supposed to be used only as an aid in migration from Linux, not to be used as a "main" filesystem. [[Red Hat Enterprise Linux]] 5.4 64 bit version has all needed kernel support but does not include command line tools for creating and using the system ([[CentOS]] tools are known to work in some extent). The motivation is that the system port may not yet be stable enough <ref>[https://bugzilla.redhat.com/show_bug.cgi?id=521173 Red Hat Linux Bugzilla entry on XFS implementation]</ref>.


==Specifications==
===Capacity===
===Capacity===
XFS is a [[64-bit]] file system. It supports a maximum file system size of 8 [[exabyte|binary exabytes]] minus one byte, though this is subject to block limits imposed by the host operating system. On [[32-bit]] Linux systems, this limits the file and file system sizes to 16 [[terabyte|binary terabytes]].
XFS is a 64-bit file system<ref>{{cite web |url=http://oss.sgi.com/projects/xfs/index.html |title=XFS Overview |publisher=Silicon Graphics International Corp |date=2013-07-02 |access-date=2013-07-02 |url-status=dead |archive-url=https://web.archive.org/web/20130606024601/http://oss.sgi.com/projects/xfs/index.html |archive-date=2013-06-06 }}</ref> and supports a maximum file system size of 8 [[exbibyte]]s minus one byte (2<sup>63</sup>&nbsp;− 1 bytes), but limitations imposed by the host operating system can decrease this limit. [[32-bit]] Linux systems limit the size of both the file and file system to 16 [[tebibyte]]s.


===Journaling===
===Journaling===
{{Details|Journaling file system}}
[[Journaling file system|Journaling]] is an approach to guaranteeing file system consistency even in presence of power failures or system crashes. XFS provides journaling for file system metadata, where file system updates are first written to a serial journal before the actual disk blocks are updated. The journal is a circular buffer of disk blocks that is never read in normal filesystem operation. The XFS journal is limited to a maximum size of both 64k blocks and 128MB with the minimum size dependent upon a calculation of the filesystem block size and directory block size. Placing the journal on an external device larger than the maximum journal size will cause the extra space to be unused. It can be stored within the data section of the filesystem (an internal log), or on a separate device to minimize disk contention. On XFS the journal contains “logical” entries that describe at a high level what operations are being performed (as opposed to a “physical” journal that stores a copy of the blocks modified during each transaction). Journal updates are performed asynchronously to avoid incurring a performance penalty. In the event of a system crash, operations immediately prior to the crash can be redone using data in the journal, which allows XFS to retain file system consistency. Recovery is performed automatically at file system mount time, and the recovery speed is independent of the size of the file system. Where recently modified data has not been flushed to disk before a system crash, XFS ensures that any unwritten data blocks are zeroed on reboot, obviating any possible security issues arising from residual data (as far as access through the filesystem interface is concerned, as distinct from accessing the raw device or raw hardware).

In modern computing, journaling is a capability which ensures consistency of data in the file system, despite any power outages or system crash that may occur. XFS provides journaling for file system metadata, where file system updates are first written to a serial journal before the actual disk blocks are updated. The journal is a circular buffer of disk blocks that is not read in normal file system operation.

The XFS journal can be stored within the data section of the file system (as an internal log), or on a separate device to minimize disk contention.

In XFS, the journal primarily contains entries that describe the portions of the disk blocks changed by filesystem operations. Journal updates are performed asynchronously to avoid a decrease in performance speed.

In the event of a system crash, file system operations which occurred immediately prior to the crash can be reapplied and completed as recorded in the journal, which is how data stored in XFS file systems remain consistent. Recovery is performed automatically the first time the file system is mounted after the crash. The speed of recovery is independent of the size of the file system, instead depending on the amount of file system operations to be reapplied.


===Allocation groups===
===Allocation groups===
XFS filesystems are internally partitioned into ''allocation groups'', which are equally sized linear regions within the file system. Files and directories can span allocation groups. Each allocation group manages its own [[inode]]s and free space separately, providing scalability and parallelism &mdash; multiple threads and processes can perform I/O operations on the same filesystem simultaneously. This architecture helps to optimise parallel I/O performance on multiprocessor or multicore systems, as metadata updates are also parallelizable. The internal partitioning provided by allocation groups can be especially beneficial when the file system spans multiple physical devices, allowing for optimal usage of throughput of the underlying storage components..
XFS file systems are internally partitioned into ''allocation groups'', which are equally sized linear regions within the file system. [[Computer file|Files]] and directories can span allocation groups. Each allocation group manages its own [[inode]]s and free space separately, providing scalability and parallelism so multiple threads and processes can perform I/O operations on the same file system simultaneously.
This architecture helps to optimize parallel I/O performance on systems with multiple processors and/or cores, as metadata updates can also be parallelized. The internal partitioning provided by allocation groups can be especially beneficial when the file system spans multiple physical devices, allowing optimal usage of throughput of the underlying storage components.


===Striped allocation===
===Striped allocation===
If an XFS filesystem is to be created on a striped [[redundant array of independent disks|RAID]] array, a ''[[Data striping|stripe]] unit'' can be specified when the file system is created. This maximises throughput by ensuring that data allocations, [[inode]] allocations and the internal log (journal) are aligned with the stripe unit.
If an XFS file system is to be created on a striped [[redundant array of independent disks|RAID]] array, a ''[[Data striping|stripe]] unit'' can be specified when the file system is created. This maximizes throughput by ensuring that data allocations, inode allocations and the internal log (the journal) are aligned with the stripe unit.


===Extent based allocation===
===Extent-based allocation===
Blocks used in files stored on XFS filesystems are managed with variable length [[extent (file systems)|extent]]s where one extent describes one or more contiguous blocks. This can shorten the list considerably compared to file systems that list all blocks used by a file individually. Also many file systems manage space allocation with one or more block oriented bitmaps &mdash; in XFS these structures are replaced with an extent oriented structure consisting of a pair of [[B+ tree]]s for each filesystem allocation group (AG). One of the [[B+ tree]]s is indexed by the length of the free extents, while the other is indexed by the starting block of the free extents. This dual indexing scheme allows for highly efficient location of free extents for file system operations.
Blocks used in files stored on XFS file systems are managed with variable length [[extent (file systems)|extents]] where one extent describes one or more contiguous blocks. This can shorten the list of blocks considerably, compared to file systems that list all blocks used by a file individually.
Block-oriented file systems manage space allocation with one or more block-oriented bitmaps; in XFS, these structures are replaced with an extent oriented structure consisting of a pair of [[B+ tree]]s for each file system allocation group. One of the B+ trees is indexed by the length of the free extents, while the other is indexed by the starting block of the free extents. This dual indexing scheme allows for the highly efficient allocation of free extents for file system operations.


===Variable block sizes===
===Variable block sizes===
The file system block size represents the minimum allocation unit. XFS allows file systems to be created with block sizes ranging between 512 bytes and 64 kilobytes, allowing the file system to be tuned for the expected use. Where a large amount of small files is to be expected, a small block size would typically be used to maximize capacity, but for a system dealing mainly with large files, a larger block size can provide a performance advantage.
The file system block size represents the minimum allocation unit. XFS allows file systems to be created with block sizes ranging between 512&nbsp;bytes and 64&nbsp;KB, allowing the file system to be tuned for the expected degree of usage. When many small files are expected, a small block size would typically maximize capacity, but for a system dealing mainly with large files, a larger block size can provide a performance efficiency advantage.


===Delayed allocation===
===Delayed allocation===
{{Main|Delayed allocation}}
{{Main|Delayed allocation}}


XFS makes use of lazy evaluation techniques for file allocation. When a file is written to the buffer cache, rather than allocating extents for the data, XFS simply reserves the appropriate number of file system blocks for the data held in memory. The actual block allocation occurs only when the data is finally flushed to disk. This improves the chance that the file will be written in a contiguous group of blocks, reducing [[file system fragmentation|fragmentation]] problems and increasing performance.
XFS makes use of [[lazy evaluation]] techniques for file allocation. When a file is written to the buffer cache, rather than allocating extents for the data, XFS simply reserves the appropriate number of file system blocks for the data held in memory. The actual block allocation occurs only when the data is finally flushed to disk. This improves the chance that the file will be written in a contiguous group of blocks, reducing [[file system fragmentation|fragmentation]] problems and increasing performance.


===Sparse files===
===Sparse files===
XFS provides a 64-bit sparse address space for each file, which allows both for very large file sizes, and for ''holes'' within files for which no disk space is allocated. As the file system uses an extent map for each file, the file allocation map size is kept small. Where the size of the allocation map is too large for it to be stored within the [[inode]], the map is moved into a [[B+ tree]] which allows for rapid access to data anywhere in the 64-bit address space provided for the file.
XFS provides a 64-bit sparse address space for each file, which allows both for very large file sizes, and for "holes" within files in which no disk space is allocated. As the file system uses an extent map for each file, the file allocation map size is kept small. Where the size of the allocation map is too large for it to be stored within the inode, the map is moved into a B+ tree which allows for rapid access to data anywhere in the 64-bit address space provided for the file.


===Extended attributes===
===Extended attributes===
XFS provides multiple data streams for files through its implementation of [[extended file attributes|extended attributes]]. These allow the storage of a number of name/value pairs attached to a file. Names are null-terminated printable character strings of up to 256&nbsp;bytes in length, while their associated values can contain up to 64&nbsp;[[kilobyte|KB]] of binary data. They are further subdivided into two namespaces, <code>root</code> and <code>user</code>. Extended attributes stored in the root namespace can be modified only by the superuser, while attributes in the user namespace can be modified by any user with permission to write to the file. Extended attributes can be attached to any kind of XFS inode, including symbolic links, device nodes, directories, etc. The <code>attr</code> program can be used to manipulate extended attributes from the command line, and the <code>xfsdump</code> and <code>xfsrestore</code> utilities are aware of them and will back up and restore their contents. Most other backup systems are not aware of extended attributes.
XFS provides multiple data streams for files; this is made possible by its implementation of [[extended file attributes|extended attributes]]. These allow the storage of a number of name/value pairs attached to a file. Names are nul-terminated printable character strings which are up to 256&nbsp;bytes in length, while their associated values can contain up to 64&nbsp;[[kilobyte|KB]] of binary data.


They are further subdivided into two namespaces: <code>root</code> and <code>user</code>. Extended attributes stored in the root namespace can be modified only by the superuser, while attributes in the user namespace can be modified by any user with permission to write to the file.
===Direct I/O===
For applications requiring high throughput to disk, XFS provides a direct I/O implementation that allows non-cached I/O directly to userspace. Data is transferred between the application's buffer and the disk using [[Direct memory access|DMA]], which allows access to the full I/O bandwidth of the underlying disk devices.


Extended attributes can be attached to any kind of XFS inode, including symbolic links, device nodes, directories, etc. The <code>attr</code> utility can be used to manipulate extended attributes from the command line, and the <code>xfsdump</code> and <code>xfsrestore</code> utilities are aware of extended attributes, and will back up and restore their contents. Many other backup systems do not support working with extended attributes.
===Guaranteed-rate I/O===
The XFS guaranteed-rate I/O system provides an API that allows applications to reserve bandwidth to the filesystem. XFS will dynamically calculate the performance available from the underlying storage devices, and will reserve bandwidth sufficient to meet the requested performance for a specified time. This feature is unique to the XFS file system. Guarantees can be ''hard'' or ''soft'', representing a trade off between reliability and performance, though XFS will only allow ''hard'' guarantees if the underlying storage subsystem supports it. This facility is most used by real-time applications, such as video-streaming.


===DMAPI===
===Direct I/O===
For applications requiring high throughput to disk, XFS provides a direct I/O implementation that allows non-cached I/O operations to be applied directly to the userspace. Data is transferred between the buffer of the application and the disk using [[Direct memory access|DMA]], which allows access to the full I/O bandwidth of the underlying disk devices.
XFS implements the [[DMAPI]] interface to support [[Hierarchical Storage Management]]. While this functionality has been ported to the Linux implementations of XFS, it is not yet a part of the mainline Linux kernel source.


===Snapshots===
===Snapshots===
XFS does not provide direct support for snapshots, as it expects the snapshot process to be implemented by the volume manager. Taking a snapshot of an XFS filesystem involves freezing I/O to the filesystem using the <code>xfs_freeze</code> utility, having the volume manager perform the actual snapshot, and then unfreezing I/O to resume normal operations. The snapshot can then be mounted read-only for backup purposes. XFS releases on IRIX incorporated an integrated volume manager called XLV. This volume manager has not been ported to Linux and XFS works with standard [[Logical Volume Manager (Linux)|LVM]] instead. In recent Linux kernels, the <code>xfs_freeze</code> functionality is implemented in the VFS layer, and happens automatically when the Volume Manager's snapshot functionality is invoked. This was once a valuable advantage as Ext3 system could not be suspended<ref>[http://www.linuxquestions.org/questions/linuxquestions-org-member-intro-24/how-to-freeze-ext3-file-system-229914/ Linux questions about freezing Ext3]</ref> and volume manager was unable to create a consistent 'hot' snapshot to backup a heavily busy database<ref>[http://www.linuxquestions.org/questions/linux-server-73/lvm-snapshots-how-to-use-622084/ Linux questions on LVM snapshots for database backup]</ref>. Fortunately this is no longer the case. Since Linux 2.6.29 ext3, ext4, gfs2 and jfs have the freeze feature as well<ref>[http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=c4be0c1dc4cdc37b175579be1460f15ac6495e9a Freeze Feature Commit to Linux kernel]</ref>.
XFS does not yet<ref>{{cite web|url=https://lwn.net/Articles/638546/|title=XFS: There and back ... and there again? [LWN.net]|website=lwn.net|access-date=2016-10-27|archive-url=https://web.archive.org/web/20161027192827/https://lwn.net/Articles/638546/|archive-date=2016-10-27|url-status=live}}</ref> provide direct support for snapshots, as it currently expects the snapshot process to be implemented by the volume manager. Taking a snapshot of an XFS filesystem involves temporarily halting I/O to the filesystem using the <code>xfs_freeze</code> utility, having the volume manager perform the actual snapshot, and then resuming I/O to continue with normal operations. The snapshot can then be mounted read-only for backup purposes.

Releases of XFS in IRIX incorporated an integrated volume manager called XLV. This volume manager has not been ported to Linux, and XFS works with standard [[Logical Volume Manager (Linux)|LVM]] in Linux systems instead.

In recent Linux kernels, the <code>xfs_freeze</code> functionality is implemented in the VFS layer, and is executed automatically when the Volume Manager's snapshot functionality is invoked. This was once a valuable advantage as the [[ext3]] file system could not be suspended<ref>{{cite web|url=http://www.linuxquestions.org/questions/programming-9/how-to-freeze-ext3-file-system-229937/|title=How to freeze ext3 file system|website=www.linuxquestions.org|access-date=2011-08-24|archive-url=https://web.archive.org/web/20110428190523/http://www.linuxquestions.org/questions/programming-9/how-to-freeze-ext3-file-system-229937/|archive-date=2011-04-28|url-status=live}}</ref> and the volume manager was unable to create a consistent "hot" snapshot to back up a heavily busy database.<ref>{{cite web|url=http://www.linuxquestions.org/questions/linux-server-73/lvm-snapshots-how-to-use-622084/|title=LVM snapshots: How to use?|website=www.linuxquestions.org|access-date=2010-04-17|archive-url=https://web.archive.org/web/20110117044017/http://www.linuxquestions.org/questions/linux-server-73/lvm-snapshots-how-to-use-622084/|archive-date=2011-01-17|url-status=live}}</ref> Fortunately this is no longer the case. Since Linux 2.6.29, the file systems ext3, [[ext4]], [[GFS2]] and [[JFS (file system)|JFS]] have the freeze feature as well.<ref>{{cite web|url=https://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=c4be0c1dc4cdc37b175579be1460f15ac6495e9a|title=kernel/git/torvalds/linux.git - Linux kernel source tree|website=git.kernel.org}}</ref>


===Online defragmentation===
===Online defragmentation===
Although the extent-based nature of XFS and the delayed allocation strategy it uses significantly improves the file system's resistance to fragmentation problems, XFS provides a filesystem [[defragmentation]] utility (<code>xfs_fsr</code>, short for XFS filesystem reorganizer) that can defragment the files on a mounted and active XFS filesystem.<ref>[http://bitubique.com/content/defragment-xfs-file-system Bitubique.com]</ref>
Although the extent-based nature of XFS and the delayed allocation strategy it uses significantly improves the file system's resistance to fragmentation problems, XFS provides a filesystem [[defragmentation]] utility (<code>xfs_fsr</code>, short for XFS filesystem reorganizer) that can defragment the files on a mounted and active XFS filesystem.<ref>[http://bitubique.com/content/defragment-xfs-file-system Bitubique.com] {{webarchive |url=https://web.archive.org/web/20090401211105/http://bitubique.com/content/defragment-xfs-file-system |date=April 1, 2009 }}</ref>


===Online resizing===
===Online growth===
XFS provides the <code>xfs_growfs</code> utility to perform online resizing of XFS file systems. XFS filesystems can be grown provided there is remaining unallocated space on the device holding the filesystem. This feature is typically used in conjunction with volume management, as otherwise the [[Disk partitioning|partition]] holding the filesystem will need enlarging separately. XFS partitions cannot (as of August 2010) be shrunk in place,<ref>[http://xfs.org/index.php/XFS_FAQ#Q:_Is_there_a_way_to_make_a_XFS_filesystem_larger_or_smaller.3F XFS.org], FAQ</ref> although several possible workarounds have been discussed.<ref>[http://oss.sgi.com/archives/xfs/2002-01/msg02379.html SGI.com]</ref>
XFS provides the <code>xfs_growfs</code> utility to perform online expansion of XFS file systems. XFS filesystems can be grown so long as there is remaining unallocated space on the device holding the filesystem. This feature is typically used in conjunction with volume management, as otherwise the [[Disk partitioning|partition]] holding the filesystem will need enlarging separately.


===IRIX-only features===
===Native backup/restore utilities===
XFS provides the <code>xfsdump</code> and <code>xfsrestore</code> utilities to aid in backup of data held on XFS file systems. The <code>xfsdump</code> utility backs up an XFS filesystem in [[inode]] order, and in contrast to traditional UNIX file systems which must be unmounted before dumping to guarantee a consistent dump image, XFS file systems can be dumped while the file system is in use. This is not the same as a snapshot since files are not frozen during the dump. XFS dumps and restores are also resumable, and can be interrupted without difficulty. The multi-threaded operation of <code>xfsdump</code> provides high performance of backup operations by splitting the dump into multiple streams, which can be sent to different dump destinations. The multi stream capabilities have not been fully ported to Linux yet, however.


===Atomic disk quotas===
====DMAPI====
XFS implemented the [[DMAPI]] interface to support [[Hierarchical Storage Management]] in IRIX. As of October 2010, the Linux implementation of XFS supported the required on-disk metadata for DMAPI implementation, but the kernel support was reportedly not usable. For some time, SGI hosted a kernel tree which included the DMAPI hooks, but this support has not been adequately maintained, although kernel developers have stated an intention to bring this support up to date.<ref>{{Cite mailing list |url= http://oss.sgi.com/archives/xfs/2010-10/msg00025.html |title= Re: Linux and DMAPI |author= Christoph Hellwig |date= October 3, 2010 |mailing-list= XFS mailing list |publisher= SGI |access-date= November 6, 2011 |archive-url= https://web.archive.org/web/20110927020239/http://oss.sgi.com/archives/xfs/2010-10/msg00025.html |archive-date= September 27, 2011 |url-status= dead }}</ref>
Quotas for XFS filesystems are turned on when initially mounted; this fixes a race window that is present with most other filesystems that first require to be mounted and where no quotas are enforced until quotaon(8) is called.


====Guaranteed-rate I/O====
==Performance considerations==
The XFS guaranteed-rate I/O system provides an API that allows applications to reserve bandwidth to the filesystem. XFS dynamically calculates the performance available from the underlying storage devices, and will reserve bandwidth sufficient to meet the requested performance for a specified time. This is a feature unique to the XFS file system. Guaranteed rates can be "hard" or "soft", representing a trade off between reliability and performance; however, XFS will only allow "hard" guarantees if the underlying storage subsystem supports it. This facility is used mostly for real-time applications, such as video streaming.
===Write barriers===

XFS filesystems mount by default with "write barriers" enabled. This feature will cause the write back cache of the underlying storage device to be flushed at appropriate times, particularly on write operations to the XFS log. This feature is intended to assure filesystem consistency, and its implementation is device specific - not all underlying hardware will support cache flush requests. When an XFS filesystem is used on a logical device provided by a hardware RAID controller with battery backed cache, this feature can cause significant performance degradation, as the filesystem code is not aware that the cache is nonvolatile, and if the controller honours the flush requests, data will be written to physical disk more often than necessary. To avoid this problem, where the data in the device cache is protected from power failure or other host problems, the filesystem should be mounted with the "nobarrier" option.
Guaranteed-rate I/O was only supported under [[IRIX]], and required special hardware for that purpose.<ref>{{Cite mailing list |url= http://oss.sgi.com/archives/xfs/2012-07/msg00432.html |title= Re: Re: realtime section bugs still around |author= Dave Chinner |date= July 30, 2012 |mailing-list= XFS mailing list |publisher= SGI |access-date= April 13, 2014 |archive-url= https://web.archive.org/web/20140414085238/http://oss.sgi.com/archives/xfs/2012-07/msg00432.html |archive-date= April 14, 2014 |url-status= live }}</ref>


==Disadvantages==
==Disadvantages==
* XFS filesystems cannot ({{as of|2023|12|lc=on}}) be shrunk in place,<ref>[http://xfs.org/index.php/XFS_FAQ#Q:_Is_there_a_way_to_make_a_XFS_filesystem_larger_or_smaller.3F XFS.org] {{Webarchive|url=https://web.archive.org/web/20090105174540/http://www.xfs.org/index.php/XFS_FAQ#Q:_Is_there_a_way_to_make_a_XFS_filesystem_larger_or_smaller.3F |date=2009-01-05 }}, FAQ</ref> although several possible workarounds have been discussed.<ref>{{Cite mailing list |url= http://oss.sgi.com/archives/xfs/2002-01/msg02379.html |title= Re: Shrink an XFS filesystem? (LVM) |author= Eric Sandeen |date= Jan 18, 2002 |mailing-list=XFS mailing list |publisher= SGI | url-status=dead |archive-url=https://web.archive.org/web/20160203194451/http://oss.sgi.com/archives/xfs/2002-01/msg02379.html |archive-date=2016-02-03}}</ref>
* An XFS file system cannot be shrunk.

* Creation and deletion of directory entries can be a much slower metadata operation than other file systems, depending on configuration.<ref>{{cite web|url = http://everything2.com/index.pl?node_id=1479435|author=Simon Kongshøj|title = Filesystem performance tweaking with XFS on Linux}}</ref>
* Journaling cannot be disabled. However, XFS can write to an external journal on a separate block device instead.<ref>{{cite web |title=About External XFS Journals |url=https://docs.oracle.com/cd/E37670_01/E37355/html/ol_extjnl_xfs.html |website=oracle.com |access-date=16 November 2022}}</ref>

===Historic Disadvantages===
* Metadata operations in XFS were slower compared to journaling file systems implemented later and designed to work with much larger logs resulting in, for example, slower performance with operations such as deletions of large numbers of files. However, a new XFS feature implemented by Dave Chinner and called ''delayed logging'', available since version 2.6.39 of the Linux kernel mainline, is said to resolve this;<ref>{{cite web |title= Improving Metadata Performance By Reducing Journal Overhead |date= December 23, 2010 |work= XFS.org wiki |first=Dave |last=Chinner |url= http://xfs.org/index.php/Improving_Metadata_Performance_By_Reducing_Journal_Overhead |access-date= November 6, 2011 |archive-url= https://web.archive.org/web/20111006152854/http://xfs.org/index.php/Improving_Metadata_Performance_By_Reducing_Journal_Overhead |archive-date= October 6, 2011 |url-status= live }}</ref> performance benchmarks done by the developer in 2010 revealed performance levels to be similar to [[ext4]] at low thread counts, and superior at high thread counts.<ref>{{Cite mailing list |title=Re: PATCH 0/12 xfs: delayed logging V6 |first=Dave |last=Chinner |url=http://oss.sgi.com/archives/xfs/2010-05/msg00329.html |mailing-list=XFS Mailing List Message |date=May 24, 2010 |access-date=November 6, 2011 |archive-url=https://web.archive.org/web/20111205021317/http://oss.sgi.com/archives/xfs/2010-05/msg00329.html |archive-date=December 5, 2011 |url-status=live }}</ref>


==See also==
==See also==
* [[Comparison of file systems]]
* [[Comparison of file systems]]
* [[CXFS]], the clustered form of XFS
* [[CXFS]]
* [[List of file systems]]
* [[List of file systems]]
* [[List of default file systems]]
* [[Stratis (configuration daemon)]]


==References==
==References==
{{Reflist}}
{{Reflist}}
*[http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi?coll=linux&db=bks&srch=&fname=/SGI_Admin/LX_XFS_AG/sgi_html/ch01.html XFS for Linux Administration (SGI Document Number: 007-4273-003)]


==Further reading==
{{No footnotes|date=April 2009}}
* [https://web.archive.org/web/20200225131110/https://pdfs.semanticscholar.org/aa38/59fe0e2d987a2c2859d539dee6724f59a163.pdf Scalability in the XFS Filesystem] (First XFS paper presented at the Usenix 1996 Annual Technical Conference)
* {{cite web|url=https://www.kernel.org/pub/linux/utils/fs/xfs/docs/xfs_filesystem_structure.pdf |access-date=2019-09-17 |date=June 2017 |publisher=Silicon Graphics |title=XFS Filesystem Disk Structures 3rd Edition}}


==External links==
==External links==
* [http://xfs.org XFS.org], community wiki
* [https://xfs.wiki.kernel.org/ The XFS Linux wiki], current community wiki
* [http://xfs.org/ XFS.org] {{Webarchive|url=https://web.archive.org/web/20161104195105/http://www.xfs.org/ |date=2016-11-04 }}, old community wiki
* [http://oss.sgi.com/projects/xfs/ SGI.com], a high-performance journaling filesystem
* [http://www.crossmeta.org/ crossmeta.org] {{Webarchive|url=https://web.archive.org/web/20150808093756/http://www.crossmeta.org/ |date=2015-08-08 }}, community port of XFS on Windows
* [http://www-106.ibm.com/developerworks/linux/library/l-fs9.html IBM.com], Advanced filesystem implementor's guide - Introducing XFS
* [http://www-106.ibm.com/developerworks/linux/library/l-fs10.html IBM.com], Advanced filesystem implementor's guide - Deploying XFS
* [http://madpenguin.org/cms/?m=show&opt=printable&id=6045 Madpenguin.org], File System Design part 1: XFS by Narayan Newton on madpenguin.org


{{Filesystem}}
{{File systems}}


[[Category:1994 software]]
[[Category:1994 software]]
[[Category:Disk file systems]]
[[Category:Disk file systems]]
[[Category:Linux file systems]]
[[Category:File systems supported by the Linux kernel]]
[[Category:Formerly proprietary software]]
[[Category:Formerly proprietary software]]
[[Category:IRIX]]

<!--Interlanguage links-->
[[cs:XFS]]
[[da:XFS]]
[[de:XFS (Dateisystem)]]
[[es:XFS]]
[[eu:XFS]]
[[fr:XFS]]
[[gl:XFS]]
[[it:XFS (file system)]]
[[lt:XFS]]
[[hu:XFS]]
[[nl:XFS]]
[[ja:XFS]]
[[no:XFS]]
[[pl:XFS]]
[[pt:XFS]]
[[ru:XFS]]
[[sk:XFS]]
[[sv:XFS]]
[[uk:Xfs]]

Latest revision as of 04:45, 8 November 2024

XFS
Developer(s)
Full nameXFS
Introduced1994; 31 years ago (1994) with IRIX 5.3
Partition IDs
  • MBR: 0x83: Linux filesystem
  • GPT: 0FC63DAF-8483-4772-8E79-3D69D8477DE4: Linux filesystem[1]
Structures
Directory contentsB+ trees
File allocationB+ trees
Limits
Max volume sizeexbibytes − 1 byte
Max file sizeexbibytes − 1 byte
Max no. of files264[2]
Max filename length255 bytes
Allowed filename
characters
All except NUL and "/"
Features
Dates recordedatime, mtime, ctime,[3] version 5: crtime[4]
Date rangeDecember 13, 1901 – July 2, 2486[5]
Date resolution1 ns
AttributesYes
File system
permissions
Yes
Transparent
compression
No
Transparent
encryption
No (provided at the block device level)
Data deduplicationExperimental, Linux only[6]
Other
Supported
operating systems

XFS is a high-performance 64-bit journaling file system created by Silicon Graphics, Inc (SGI) in 1993.[7] It was the default file system in SGI's IRIX operating system starting with its version 5.3. XFS was ported to the Linux kernel in 2001; as of June 2014, XFS is supported by most Linux distributions; Red Hat Enterprise Linux uses it as its default file system.

XFS excels in the execution of parallel input/output (I/O) operations due to its design, which is based on allocation groups (a type of subdivision of the physical volumes in which XFS is used- also shortened to AGs). Because of this, XFS enables extreme scalability of I/O threads, file system bandwidth, and size of files and of the file system itself when spanning multiple physical storage devices. XFS ensures the consistency of data by employing metadata journaling and supporting write barriers. Space allocation is performed via extents with data structures stored in B+ trees, improving the overall performance of the file system, especially when handling large files. Delayed allocation assists in the prevention of file system fragmentation; online defragmentation is also supported.

History

[edit]

First generation XFS

[edit]

Silicon Graphics began development of XFS[8] ("X" was meant to be filled in later but never was) in 1993 for its UNIX System V based IRIX operating system. The file system was released under the GNU General Public License (GPL) in May 1999.[9]

Second generation XFS

[edit]

A team led by Steve Lord at SGI ported XFS to Linux,[10] and first support by a Linux distribution came in 2001. This support gradually became available in almost all Linux distributions.[citation needed]

Initial support for XFS in the Linux kernel came through patches from SGI. It merged into the Linux kernel mainline for the 2.6 series, and separately merged in February 2004 into the 2.4 series in version 2.4.25,[11] making XFS almost universally available on Linux systems.[12] Gentoo Linux became the first Linux distribution to introduce an option for XFS as the default filesystem in mid-2002.[13]

FreeBSD added read-only support for XFS in December 2005, and in June 2006 introduced experimental write support. However, this was intended only as an aid in migration from Linux, not as a "main" file system. FreeBSD 10 removed support for XFS.[14]

In 2009, version 5.4 of 64-bit Red Hat Enterprise Linux (RHEL) Linux distribution contained the necessary kernel support for the creation and usage of XFS file systems, but lacked the corresponding command-line tools. The tools available from CentOS could operate for that purpose, and Red Hat also provided them to RHEL customers on request.[15] RHEL 6.0, released in 2010, includes XFS support for a fee as part of Red Hat's "scalable file system add-on".[16] Oracle Linux 6, released in 2011, also includes an option for using XFS.[17]

RHEL 7.0, released in June 2014, uses XFS as its default file system,[18] including support for using XFS for the /boot partition, which previously was not practical due to bugs in the GRUB bootloader.[19]

Linux kernel 4.8 in August 2016 added a new feature, "reverse mapping". This is the foundation for a large set of planned features: snapshots, copy-on-write (COW) data, data deduplication, reflink copies, online data and metadata scrubbing, highly accurate reporting of data loss or bad sectors, and significantly improved reconstruction of damaged or corrupted filesystems. This work required changes to XFS's on-disk format.[20][21]

Third generation XFS

[edit]
XFS v4 is deprecated. Partitions have to be reformatted with XFS v5.

Linux kernel 5.10, released in December 2020, included the new on-disk format XFS v5. This was a hard break, since the deprecated XFS v4 can not be converted to XFS v5. Data on partitions formatted with XFS v4 has to be backed up to another partition or media in order to restore it after formatting the old partition with XFS v5, which completely wipes all data on it. The support for XFS v4 will be removed from the Linux kernel in September 2030.[22]

XFS v5 introduced "bigtime", to store inode timestamps as a 64-bit nanosecond counter instead of the traditional 32-bit seconds counter. This postpones the previous Year 2038 problem until the year 2486.[5] It also introduced metadata checksums.

The Gentoo Handbook, Gentoo Linux's official installation manual, has recommended XFS as the "all-purpose all-platform filesystem" since 28 Jun 2023, succeeding Ext4.[23]

Features

[edit]

Capacity

[edit]

XFS is a 64-bit file system[24] and supports a maximum file system size of 8 exbibytes minus one byte (263 − 1 bytes), but limitations imposed by the host operating system can decrease this limit. 32-bit Linux systems limit the size of both the file and file system to 16 tebibytes.

Journaling

[edit]

In modern computing, journaling is a capability which ensures consistency of data in the file system, despite any power outages or system crash that may occur. XFS provides journaling for file system metadata, where file system updates are first written to a serial journal before the actual disk blocks are updated. The journal is a circular buffer of disk blocks that is not read in normal file system operation.

The XFS journal can be stored within the data section of the file system (as an internal log), or on a separate device to minimize disk contention.

In XFS, the journal primarily contains entries that describe the portions of the disk blocks changed by filesystem operations. Journal updates are performed asynchronously to avoid a decrease in performance speed.

In the event of a system crash, file system operations which occurred immediately prior to the crash can be reapplied and completed as recorded in the journal, which is how data stored in XFS file systems remain consistent. Recovery is performed automatically the first time the file system is mounted after the crash. The speed of recovery is independent of the size of the file system, instead depending on the amount of file system operations to be reapplied.

Allocation groups

[edit]

XFS file systems are internally partitioned into allocation groups, which are equally sized linear regions within the file system. Files and directories can span allocation groups. Each allocation group manages its own inodes and free space separately, providing scalability and parallelism so multiple threads and processes can perform I/O operations on the same file system simultaneously.

This architecture helps to optimize parallel I/O performance on systems with multiple processors and/or cores, as metadata updates can also be parallelized. The internal partitioning provided by allocation groups can be especially beneficial when the file system spans multiple physical devices, allowing optimal usage of throughput of the underlying storage components.

Striped allocation

[edit]

If an XFS file system is to be created on a striped RAID array, a stripe unit can be specified when the file system is created. This maximizes throughput by ensuring that data allocations, inode allocations and the internal log (the journal) are aligned with the stripe unit.

Extent-based allocation

[edit]

Blocks used in files stored on XFS file systems are managed with variable length extents where one extent describes one or more contiguous blocks. This can shorten the list of blocks considerably, compared to file systems that list all blocks used by a file individually.

Block-oriented file systems manage space allocation with one or more block-oriented bitmaps; in XFS, these structures are replaced with an extent oriented structure consisting of a pair of B+ trees for each file system allocation group. One of the B+ trees is indexed by the length of the free extents, while the other is indexed by the starting block of the free extents. This dual indexing scheme allows for the highly efficient allocation of free extents for file system operations.

Variable block sizes

[edit]

The file system block size represents the minimum allocation unit. XFS allows file systems to be created with block sizes ranging between 512 bytes and 64 KB, allowing the file system to be tuned for the expected degree of usage. When many small files are expected, a small block size would typically maximize capacity, but for a system dealing mainly with large files, a larger block size can provide a performance efficiency advantage.

Delayed allocation

[edit]

XFS makes use of lazy evaluation techniques for file allocation. When a file is written to the buffer cache, rather than allocating extents for the data, XFS simply reserves the appropriate number of file system blocks for the data held in memory. The actual block allocation occurs only when the data is finally flushed to disk. This improves the chance that the file will be written in a contiguous group of blocks, reducing fragmentation problems and increasing performance.

Sparse files

[edit]

XFS provides a 64-bit sparse address space for each file, which allows both for very large file sizes, and for "holes" within files in which no disk space is allocated. As the file system uses an extent map for each file, the file allocation map size is kept small. Where the size of the allocation map is too large for it to be stored within the inode, the map is moved into a B+ tree which allows for rapid access to data anywhere in the 64-bit address space provided for the file.

Extended attributes

[edit]

XFS provides multiple data streams for files; this is made possible by its implementation of extended attributes. These allow the storage of a number of name/value pairs attached to a file. Names are nul-terminated printable character strings which are up to 256 bytes in length, while their associated values can contain up to 64 KB of binary data.

They are further subdivided into two namespaces: root and user. Extended attributes stored in the root namespace can be modified only by the superuser, while attributes in the user namespace can be modified by any user with permission to write to the file.

Extended attributes can be attached to any kind of XFS inode, including symbolic links, device nodes, directories, etc. The attr utility can be used to manipulate extended attributes from the command line, and the xfsdump and xfsrestore utilities are aware of extended attributes, and will back up and restore their contents. Many other backup systems do not support working with extended attributes.

Direct I/O

[edit]

For applications requiring high throughput to disk, XFS provides a direct I/O implementation that allows non-cached I/O operations to be applied directly to the userspace. Data is transferred between the buffer of the application and the disk using DMA, which allows access to the full I/O bandwidth of the underlying disk devices.

Snapshots

[edit]

XFS does not yet[25] provide direct support for snapshots, as it currently expects the snapshot process to be implemented by the volume manager. Taking a snapshot of an XFS filesystem involves temporarily halting I/O to the filesystem using the xfs_freeze utility, having the volume manager perform the actual snapshot, and then resuming I/O to continue with normal operations. The snapshot can then be mounted read-only for backup purposes.

Releases of XFS in IRIX incorporated an integrated volume manager called XLV. This volume manager has not been ported to Linux, and XFS works with standard LVM in Linux systems instead.

In recent Linux kernels, the xfs_freeze functionality is implemented in the VFS layer, and is executed automatically when the Volume Manager's snapshot functionality is invoked. This was once a valuable advantage as the ext3 file system could not be suspended[26] and the volume manager was unable to create a consistent "hot" snapshot to back up a heavily busy database.[27] Fortunately this is no longer the case. Since Linux 2.6.29, the file systems ext3, ext4, GFS2 and JFS have the freeze feature as well.[28]

Online defragmentation

[edit]

Although the extent-based nature of XFS and the delayed allocation strategy it uses significantly improves the file system's resistance to fragmentation problems, XFS provides a filesystem defragmentation utility (xfs_fsr, short for XFS filesystem reorganizer) that can defragment the files on a mounted and active XFS filesystem.[29]

Online growth

[edit]

XFS provides the xfs_growfs utility to perform online expansion of XFS file systems. XFS filesystems can be grown so long as there is remaining unallocated space on the device holding the filesystem. This feature is typically used in conjunction with volume management, as otherwise the partition holding the filesystem will need enlarging separately.

IRIX-only features

[edit]

DMAPI

[edit]

XFS implemented the DMAPI interface to support Hierarchical Storage Management in IRIX. As of October 2010, the Linux implementation of XFS supported the required on-disk metadata for DMAPI implementation, but the kernel support was reportedly not usable. For some time, SGI hosted a kernel tree which included the DMAPI hooks, but this support has not been adequately maintained, although kernel developers have stated an intention to bring this support up to date.[30]

Guaranteed-rate I/O

[edit]

The XFS guaranteed-rate I/O system provides an API that allows applications to reserve bandwidth to the filesystem. XFS dynamically calculates the performance available from the underlying storage devices, and will reserve bandwidth sufficient to meet the requested performance for a specified time. This is a feature unique to the XFS file system. Guaranteed rates can be "hard" or "soft", representing a trade off between reliability and performance; however, XFS will only allow "hard" guarantees if the underlying storage subsystem supports it. This facility is used mostly for real-time applications, such as video streaming.

Guaranteed-rate I/O was only supported under IRIX, and required special hardware for that purpose.[31]

Disadvantages

[edit]
  • XFS filesystems cannot (as of December 2023) be shrunk in place,[32] although several possible workarounds have been discussed.[33]
  • Journaling cannot be disabled. However, XFS can write to an external journal on a separate block device instead.[34]

Historic Disadvantages

[edit]
  • Metadata operations in XFS were slower compared to journaling file systems implemented later and designed to work with much larger logs resulting in, for example, slower performance with operations such as deletions of large numbers of files. However, a new XFS feature implemented by Dave Chinner and called delayed logging, available since version 2.6.39 of the Linux kernel mainline, is said to resolve this;[35] performance benchmarks done by the developer in 2010 revealed performance levels to be similar to ext4 at low thread counts, and superior at high thread counts.[36]

See also

[edit]

References

[edit]
  1. ^ "GPT fdisk - ArchWiki".
  2. ^ "What is the maximum number of inodes in Linux filesystems?". 2014-06-17.
  3. ^ "XFS Filesystem Structure 2nd Edition, Revision 1" (PDF). p. 25. Archived from the original (PDF) on 2017-10-31.
  4. ^ "ondisk_inode.asciidoc\XFS_Filesystem_Structure\design - xfs/xfs-documentation.git - XFS AsciiDoc Documentation tree". git.kernel.org.
  5. ^ a b Darrick J. Wong (2020-08-10). "xfs: widen timestamps to deal with y2038".
  6. ^ "Duperemove". GitHub. Archived from the original on 6 March 2016. Retrieved 21 August 2016.
  7. ^ "xFS: The Extension of EFS - "x" for To-be-Determined (but the Name Stuck)". XFS.org. Archived from the original on 2014-07-14.
  8. ^ Smith, Roderick W. (2007). Linux Administrator Street Smarts: A Real World Guide to Linux Certification Skills. Street smarts series. John Wiley & Sons. p. 204. ISBN 9780470116746. Archived from the original on 2016-08-21. Retrieved 2016-03-21. Silicon Graphics (SGI) created its Extents File System (XFS) for its IRIX OS and [...] later donated the code to Linux.
  9. ^ "SGI open-sourcing XFS". slashdot.org. 1999-05-19. Retrieved 2023-04-12.
  10. ^ "Porting XFS to Linux". Olstrans.SourceForge.net. 2000-07-21. Archived from the original on 2013-02-25. Retrieved 2013-04-29.
  11. ^ "Linux kernel 2.4.25 changelog". kernel.org. 2004-02-18. Archived from the original on 2014-08-19. Retrieved 2014-08-14.
  12. ^ Daniel Robbins (January 1, 2002). "Common threads: Advanced filesystem implementor's guide, Part 9, Introducing XFS". Developer Works. IBM. Archived from the original on September 4, 2015. Retrieved November 6, 2011.
  13. ^ Daniel Robbins (April 1, 2002). "Common threads: Advanced filesystem implementor's guide, Part 10, Deploying XFS". Developer Works. IBM. Archived from the original on December 24, 2011. Retrieved November 6, 2011.
  14. ^ "Has FreeBSD 10 Dropped Support For XFS?". Lists.freebsd.org. 2013-10-27. Archived from the original on 2014-03-30. Retrieved 2014-03-30.
  15. ^ "Bug 521173 -xfsprogs is missing in RHEL-5.4". RedHat.com. May 24, 2010. Archived from the original on July 10, 2012. Retrieved November 6, 2011.
  16. ^ "Red Hat Enterprise Linux Scalable File System Add-On". RedHat.com. Archived from the original on 2014-05-29. Retrieved 2014-05-22.
  17. ^ "Oracle Linux 6 Release Notes". Oracle Corporation. February 2011. Archived from the original on 2012-03-28. Retrieved 2013-04-07. Oracle Linux 6 includes many new features, including [...] XFS [:] Oracle Linux 6 includes XFS as an optional filesystem.
  18. ^ "Red Hat Unveils Red Hat Enterprise Linux 7, Redefining the Enterprise Operating System". Red Hat. 2014-06-10. Archived from the original on 2014-06-13. Retrieved 2014-06-10.
  19. ^ "Bug 250843 -grub-install hangs on xfs". Redhat.com. May 4, 2009. Archived from the original on July 10, 2012. Retrieved November 6, 2011.
  20. ^ "kernel/git/torvalds/linux.git - Linux kernel source tree". git.kernel.org.
  21. ^ "Linux_4.8 - Linux Kernel Newbies". Archived from the original on 2018-10-19. Retrieved 2018-10-19.
  22. ^ https://www.haiku-os.org/docs/develop/file_systems/xfs.html
  23. ^ "Difference between revisions of "Handbook:Parts/Installation/Disks" - Gentoo wiki". wiki.gentoo.org. Retrieved 2024-04-25.
  24. ^ "XFS Overview". Silicon Graphics International Corp. 2013-07-02. Archived from the original on 2013-06-06. Retrieved 2013-07-02.
  25. ^ "XFS: There and back ... and there again? [LWN.net]". lwn.net. Archived from the original on 2016-10-27. Retrieved 2016-10-27.
  26. ^ "How to freeze ext3 file system". www.linuxquestions.org. Archived from the original on 2011-04-28. Retrieved 2011-08-24.
  27. ^ "LVM snapshots: How to use?". www.linuxquestions.org. Archived from the original on 2011-01-17. Retrieved 2010-04-17.
  28. ^ "kernel/git/torvalds/linux.git - Linux kernel source tree". git.kernel.org.
  29. ^ Bitubique.com Archived April 1, 2009, at the Wayback Machine
  30. ^ Christoph Hellwig (October 3, 2010). "Re: Linux and DMAPI". XFS mailing list (Mailing list). SGI. Archived from the original on September 27, 2011. Retrieved November 6, 2011.
  31. ^ Dave Chinner (July 30, 2012). "Re: Re: realtime section bugs still around". XFS mailing list (Mailing list). SGI. Archived from the original on April 14, 2014. Retrieved April 13, 2014.
  32. ^ XFS.org Archived 2009-01-05 at the Wayback Machine, FAQ
  33. ^ Eric Sandeen (Jan 18, 2002). "Re: Shrink an XFS filesystem? (LVM)". XFS mailing list (Mailing list). SGI. Archived from the original on 2016-02-03.
  34. ^ "About External XFS Journals". oracle.com. Retrieved 16 November 2022.
  35. ^ Chinner, Dave (December 23, 2010). "Improving Metadata Performance By Reducing Journal Overhead". XFS.org wiki. Archived from the original on October 6, 2011. Retrieved November 6, 2011.
  36. ^ Chinner, Dave (May 24, 2010). "Re: PATCH 0/12 xfs: delayed logging V6". XFS Mailing List Message (Mailing list). Archived from the original on December 5, 2011. Retrieved November 6, 2011.

Further reading

[edit]
[edit]