xref: /linux/Documentation/admin-guide/xfs.rst (revision 6f7e6393d1ce636bb7ec77a7fe7b77458fddf701)
1.. SPDX-License-Identifier: GPL-2.0
2
3======================
4The SGI XFS Filesystem
5======================
6
7XFS is a high performance journaling filesystem which originated
8on the SGI IRIX platform.  It is completely multi-threaded, can
9support large files and large filesystems, extended attributes,
10variable block sizes, is extent based, and makes extensive use of
11Btrees (directories, extents, free space) to aid both performance
12and scalability.
13
14Refer to the documentation at https://xfs.wiki.kernel.org/
15for further details.  This implementation is on-disk compatible
16with the IRIX version of XFS.
17
18
19Mount Options
20=============
21
22When mounting an XFS filesystem, the following options are accepted.
23
24  allocsize=size
25	Sets the buffered I/O end-of-file preallocation size when
26	doing delayed allocation writeout (default size is 64KiB).
27	Valid values for this option are page size (typically 4KiB)
28	through to 1GiB, inclusive, in power-of-2 increments.
29
30	The default behaviour is for dynamic end-of-file
31	preallocation size, which uses a set of heuristics to
32	optimise the preallocation size based on the current
33	allocation patterns within the file and the access patterns
34	to the file. Specifying a fixed ``allocsize`` value turns off
35	the dynamic behaviour.
36
37  discard or nodiscard (default)
38	Enable/disable the issuing of commands to let the block
39	device reclaim space freed by the filesystem.  This is
40	useful for SSD devices, thinly provisioned LUNs and virtual
41	machine images, but may have a performance impact.
42
43	Note: It is currently recommended that you use the ``fstrim``
44	application to ``discard`` unused blocks rather than the ``discard``
45	mount option because the performance impact of this option
46	is quite severe.
47
48  grpid/bsdgroups or nogrpid/sysvgroups (default)
49	These options define what group ID a newly created file
50	gets.  When ``grpid`` is set, it takes the group ID of the
51	directory in which it is created; otherwise it takes the
52	``fsgid`` of the current process, unless the directory has the
53	``setgid`` bit set, in which case it takes the ``gid`` from the
54	parent directory, and also gets the ``setgid`` bit set if it is
55	a directory itself.
56
57  filestreams
58	Make the data allocator use the filestreams allocation mode
59	across the entire filesystem rather than just on directories
60	configured to use it.
61
62  inode32 or inode64 (default)
63	When ``inode32`` is specified, it indicates that XFS limits
64	inode creation to locations which will not result in inode
65	numbers with more than 32 bits of significance.
66
67	When ``inode64`` is specified, it indicates that XFS is allowed
68	to create inodes at any location in the filesystem,
69	including those which will result in inode numbers occupying
70	more than 32 bits of significance.
71
72	``inode32`` is provided for backwards compatibility with older
73	systems and applications, since 64 bits inode numbers might
74	cause problems for some applications that cannot handle
75	large inode numbers.  If applications are in use which do
76	not handle inode numbers bigger than 32 bits, the ``inode32``
77	option should be specified.
78
79  largeio or nolargeio (default)
80	If ``nolargeio`` is specified, the optimal I/O reported in
81	``st_blksize`` by **stat(2)** will be as small as possible to allow
82	user applications to avoid inefficient read/modify/write
83	I/O.  This is typically the page size of the machine, as
84	this is the granularity of the page cache.
85
86	If ``largeio`` is specified, a filesystem that was created with a
87	``swidth`` specified will return the ``swidth`` value (in bytes)
88	in ``st_blksize``. If the filesystem does not have a ``swidth``
89	specified but does specify an ``allocsize`` then ``allocsize``
90	(in bytes) will be returned instead. Otherwise the behaviour
91	is the same as if ``nolargeio`` was specified.
92
93  logbufs=value
94	Set the number of in-memory log buffers.  Valid numbers
95	range from 2-8 inclusive.
96
97	The default value is 8 buffers.
98
99	If the memory cost of 8 log buffers is too high on small
100	systems, then it may be reduced at some cost to performance
101	on metadata intensive workloads. The ``logbsize`` option below
102	controls the size of each buffer and so is also relevant to
103	this case.
104
105  lifetime (default) or nolifetime
106	Enable data placement based on write life time hints provided
107	by the user. This turns on co-allocation of data of similar
108	life times when statistically favorable to reduce garbage
109	collection cost.
110
111	These options are only available for zoned rt file systems.
112
113  logbsize=value
114	Set the size of each in-memory log buffer.  The size may be
115	specified in bytes, or in kilobytes with a "k" suffix.
116	Valid sizes for version 1 and version 2 logs are 16384 (16k)
117	and 32768 (32k).  Valid sizes for version 2 logs also
118	include 65536 (64k), 131072 (128k) and 262144 (256k). The
119	logbsize must be an integer multiple of the log
120	stripe unit configured at **mkfs(8)** time.
121
122	The default value for version 1 logs is 32768, while the
123	default value for version 2 logs is MAX(32768, log_sunit).
124
125  logdev=device and rtdev=device
126	Use an external log (metadata journal) and/or real-time device.
127	An XFS filesystem has up to three parts: a data section, a log
128	section, and a real-time section.  The real-time section is
129	optional, and the log section can be separate from the data
130	section or contained within it.
131
132  max_atomic_write=value
133	Set the maximum size of an atomic write.  The size may be
134	specified in bytes, in kilobytes with a "k" suffix, in megabytes
135	with a "m" suffix, or in gigabytes with a "g" suffix.  The size
136	cannot be larger than the maximum write size, larger than the
137	size of any allocation group, or larger than the size of a
138	remapping operation that the log can complete atomically.
139
140	The default value is to set the maximum I/O completion size
141	to allow each CPU to handle one at a time.
142
143  max_open_zones=value
144	Specify the max number of zones to keep open for writing on a
145	zoned rt device. Many open zones aids file data separation
146	but may impact performance on HDDs.
147
148	If ``max_open_zones`` is not specified, the value is determined
149	by the capabilities and the size of the zoned rt device.
150
151  noalign
152	Data allocations will not be aligned at stripe unit
153	boundaries. This is only relevant to filesystems created
154	with non-zero data alignment parameters (``sunit``, ``swidth``) by
155	**mkfs(8)**.
156
157  norecovery
158	The filesystem will be mounted without running log recovery.
159	If the filesystem was not cleanly unmounted, it is likely to
160	be inconsistent when mounted in ``norecovery`` mode.
161	Some files or directories may not be accessible because of this.
162	Filesystems mounted ``norecovery`` must be mounted read-only or
163	the mount will fail.
164
165  nouuid
166	Don't check for double mounted file systems using the file
167	system ``uuid``.  This is useful to mount LVM snapshot volumes,
168	and often used in combination with ``norecovery`` for mounting
169	read-only snapshots.
170
171  noquota
172	Forcibly turns off all quota accounting and enforcement
173	within the filesystem.
174
175  uquota/usrquota/uqnoenforce/quota
176	User disk quota accounting enabled, and limits (optionally)
177	enforced.  Refer to **xfs_quota(8)** for further details.
178
179  gquota/grpquota/gqnoenforce
180	Group disk quota accounting enabled and limits (optionally)
181	enforced.  Refer to **xfs_quota(8)** for further details.
182
183  pquota/prjquota/pqnoenforce
184	Project disk quota accounting enabled and limits (optionally)
185	enforced.  Refer to **xfs_quota(8)** for further details.
186
187  sunit=value and swidth=value
188	Used to specify the stripe unit and width for a RAID device
189	or a stripe volume.  "value" must be specified in 512-byte
190	block units. These options are only relevant to filesystems
191	that were created with non-zero data alignment parameters.
192
193	The ``sunit`` and ``swidth`` parameters specified must be compatible
194	with the existing filesystem alignment characteristics.  In
195	general, that means the only valid changes to ``sunit`` are
196	increasing it by a power-of-2 multiple. Valid ``swidth`` values
197	are any integer multiple of a valid ``sunit`` value.
198
199	Typically the only time these mount options are necessary if
200	after an underlying RAID device has had its geometry
201	modified, such as adding a new disk to a RAID5 lun and
202	reshaping it.
203
204  swalloc
205	Data allocations will be rounded up to stripe width boundaries
206	when the current end of file is being extended and the file
207	size is larger than the stripe width size.
208
209  wsync
210	When specified, all filesystem namespace operations are
211	executed synchronously. This ensures that when the namespace
212	operation (create, unlink, etc) completes, the change to the
213	namespace is on stable storage. This is useful in HA setups
214	where failover must not result in clients seeing
215	inconsistent namespace presentation during or after a
216	failover event.
217
218  errortag=tagname
219	When specified, enables the error inject tag named "tagname" with the
220	default frequency.  Can be specified multiple times to enable multiple
221	errortags.  Specifying this option on remount will reset the error tag
222	to the default value if it was set to any other value before.
223	This option is only supported when CONFIG_XFS_DEBUG is enabled, and
224	will not be reflected in /proc/self/mounts.
225
226Deprecation of V4 Format
227========================
228
229The V4 filesystem format lacks certain features that are supported by
230the V5 format, such as metadata checksumming, strengthened metadata
231verification, and the ability to store timestamps past the year 2038.
232Because of this, the V4 format is deprecated.  All users should upgrade
233by backing up their files, reformatting, and restoring from the backup.
234
235Administrators and users can detect a V4 filesystem by running xfs_info
236against a filesystem mountpoint and checking for a string containing
237"crc=".  If no such string is found, please upgrade xfsprogs to the
238latest version and try again.
239
240The deprecation will take place in two parts.  Support for mounting V4
241filesystems can now be disabled at kernel build time via Kconfig option.
242These options were changed to default to no in September 2025.  In
243September 2030, support will be removed from the codebase entirely.
244
245Note: Distributors may choose to withdraw V4 format support earlier than
246the dates listed above.
247
248Deprecated Mount Options
249========================
250
251============================    ================
252  Name				Removal Schedule
253============================    ================
254Mounting with V4 filesystem     September 2030
255Mounting ascii-ci filesystem    September 2030
256============================    ================
257
258
259Removed Mount Options
260=====================
261
262===========================     =======
263  Name				Removed
264===========================	=======
265  delaylog/nodelaylog		v4.0
266  ihashsize			v4.0
267  irixsgid			v4.0
268  osyncisdsync/osyncisosync	v4.0
269  barrier			v4.19
270  nobarrier			v4.19
271  ikeep/noikeep			v6.18
272  attr2/noattr2			v6.18
273===========================     =======
274
275sysctls
276=======
277
278The following sysctls are available for the XFS filesystem:
279
280  fs.xfs.stats_clear		(Min: 0  Default: 0  Max: 1)
281	Setting this to "1" clears accumulated XFS statistics
282	in /proc/fs/xfs/stat.  It then immediately resets to "0".
283
284  fs.xfs.xfssyncd_centisecs	(Min: 100  Default: 3000  Max: 720000)
285	The interval at which the filesystem flushes metadata
286	out to disk and runs internal cache cleanup routines.
287
288  fs.xfs.filestream_centisecs	(Min: 1  Default: 3000  Max: 360000)
289	The interval at which the filesystem ages filestreams cache
290	references and returns timed-out AGs back to the free stream
291	pool.
292
293  fs.xfs.speculative_prealloc_lifetime
294	(Units: seconds   Min: 1  Default: 300  Max: 86400)
295	The interval at which the background scanning for inodes
296	with unused speculative preallocation runs. The scan
297	removes unused preallocation from clean inodes and releases
298	the unused space back to the free pool.
299
300  fs.xfs.error_level		(Min: 0  Default: 3  Max: 11)
301	A volume knob for error reporting when internal errors occur.
302	This will generate detailed messages & backtraces for filesystem
303	shutdowns, for example.  Current threshold values are:
304
305		XFS_ERRLEVEL_OFF:       0
306		XFS_ERRLEVEL_LOW:       1
307		XFS_ERRLEVEL_HIGH:      5
308
309  fs.xfs.panic_mask		(Min: 0  Default: 0  Max: 511)
310	Causes certain error conditions to call BUG(). Value is a bitmask;
311	OR together the tags which represent errors which should cause panics:
312
313		XFS_NO_PTAG                     0
314		XFS_PTAG_IFLUSH                 0x00000001
315		XFS_PTAG_LOGRES                 0x00000002
316		XFS_PTAG_AILDELETE              0x00000004
317		XFS_PTAG_ERROR_REPORT           0x00000008
318		XFS_PTAG_SHUTDOWN_CORRUPT       0x00000010
319		XFS_PTAG_SHUTDOWN_IOERROR       0x00000020
320		XFS_PTAG_SHUTDOWN_LOGERROR      0x00000040
321		XFS_PTAG_FSBLOCK_ZERO           0x00000080
322		XFS_PTAG_VERIFIER_ERROR         0x00000100
323
324	This option is intended for debugging only.
325
326  fs.xfs.inherit_sync		(Min: 0  Default: 1  Max: 1)
327	Setting this to "1" will cause the "sync" flag set
328	by the **xfs_io(8)** chattr command on a directory to be
329	inherited by files in that directory.
330
331  fs.xfs.inherit_nodump		(Min: 0  Default: 1  Max: 1)
332	Setting this to "1" will cause the "nodump" flag set
333	by the **xfs_io(8)** chattr command on a directory to be
334	inherited by files in that directory.
335
336  fs.xfs.inherit_noatime	(Min: 0  Default: 1  Max: 1)
337	Setting this to "1" will cause the "noatime" flag set
338	by the **xfs_io(8)** chattr command on a directory to be
339	inherited by files in that directory.
340
341  fs.xfs.inherit_nosymlinks	(Min: 0  Default: 1  Max: 1)
342	Setting this to "1" will cause the "nosymlinks" flag set
343	by the **xfs_io(8)** chattr command on a directory to be
344	inherited by files in that directory.
345
346  fs.xfs.inherit_nodefrag	(Min: 0  Default: 1  Max: 1)
347	Setting this to "1" will cause the "nodefrag" flag set
348	by the **xfs_io(8)** chattr command on a directory to be
349	inherited by files in that directory.
350
351  fs.xfs.rotorstep		(Min: 1  Default: 1  Max: 256)
352	In "inode32" allocation mode, this option determines how many
353	files the allocator attempts to allocate in the same allocation
354	group before moving to the next allocation group.  The intent
355	is to control the rate at which the allocator moves between
356	allocation groups when allocating extents for new files.
357
358Deprecated Sysctls
359==================
360
361None currently.
362
363Removed Sysctls
364===============
365
366==========================================   =======
367  Name                                       Removed
368==========================================   =======
369  fs.xfs.xfsbufd_centisec                    v4.0
370  fs.xfs.age_buffer_centisecs                v4.0
371  fs.xfs.irix_symlink_mode                   v6.18
372  fs.xfs.irix_sgid_inherit                   v6.18
373  fs.xfs.speculative_cow_prealloc_lifetime   v6.18
374==========================================   =======
375
376Error handling
377==============
378
379XFS can act differently according to the type of error found during its
380operation. The implementation introduces the following concepts to the error
381handler:
382
383 -failure speed:
384	Defines how fast XFS should propagate an error upwards when a specific
385	error is found during the filesystem operation. It can propagate
386	immediately, after a defined number of retries, after a set time period,
387	or simply retry forever.
388
389 -error classes:
390	Specifies the subsystem the error configuration will apply to, such as
391	metadata IO or memory allocation. Different subsystems will have
392	different error handlers for which behaviour can be configured.
393
394 -error handlers:
395	Defines the behavior for a specific error.
396
397The filesystem behavior during an error can be set via ``sysfs`` files. Each
398error handler works independently - the first condition met by an error handler
399for a specific class will cause the error to be propagated rather than reset and
400retried.
401
402The action taken by the filesystem when the error is propagated is context
403dependent - it may cause a shut down in the case of an unrecoverable error,
404it may be reported back to userspace, or it may even be ignored because
405there's nothing useful we can with the error or anyone we can report it to (e.g.
406during unmount).
407
408The configuration files are organized into the following hierarchy for each
409mounted filesystem:
410
411  /sys/fs/xfs/<dev>/error/<class>/<error>/
412
413Where:
414  <dev>
415	The short device name of the mounted filesystem. This is the same device
416	name that shows up in XFS kernel error messages as "XFS(<dev>): ..."
417
418  <class>
419	The subsystem the error configuration belongs to. As of 4.9, the defined
420	classes are:
421
422		- "metadata": applies metadata buffer write IO
423
424  <error>
425	The individual error handler configurations.
426
427
428Each filesystem has "global" error configuration options defined in their top
429level directory:
430
431  /sys/fs/xfs/<dev>/error/
432
433  fail_at_unmount		(Min:  0  Default:  1  Max: 1)
434	Defines the filesystem error behavior at unmount time.
435
436	If set to a value of 1, XFS will override all other error configurations
437	during unmount and replace them with "immediate fail" characteristics.
438	i.e. no retries, no retry timeout. This will always allow unmount to
439	succeed when there are persistent errors present.
440
441	If set to 0, the configured retry behaviour will continue until all
442	retries and/or timeouts have been exhausted. This will delay unmount
443	completion when there are persistent errors, and it may prevent the
444	filesystem from ever unmounting fully in the case of "retry forever"
445	handler configurations.
446
447	Note: there is no guarantee that fail_at_unmount can be set while an
448	unmount is in progress. It is possible that the ``sysfs`` entries are
449	removed by the unmounting filesystem before a "retry forever" error
450	handler configuration causes unmount to hang, and hence the filesystem
451	must be configured appropriately before unmount begins to prevent
452	unmount hangs.
453
454Each filesystem has specific error class handlers that define the error
455propagation behaviour for specific errors. There is also a "default" error
456handler defined, which defines the behaviour for all errors that don't have
457specific handlers defined. Where multiple retry constraints are configured for
458a single error, the first retry configuration that expires will cause the error
459to be propagated. The handler configurations are found in the directory:
460
461  /sys/fs/xfs/<dev>/error/<class>/<error>/
462
463  max_retries			(Min: -1  Default: Varies  Max: INTMAX)
464	Defines the allowed number of retries of a specific error before
465	the filesystem will propagate the error. The retry count for a given
466	error context (e.g. a specific metadata buffer) is reset every time
467	there is a successful completion of the operation.
468
469	Setting the value to "-1" will cause XFS to retry forever for this
470	specific error.
471
472	Setting the value to "0" will cause XFS to fail immediately when the
473	specific error is reported.
474
475	Setting the value to "N" (where 0 < N < Max) will make XFS retry the
476	operation "N" times before propagating the error.
477
478  retry_timeout_seconds		(Min:  -1  Default:  Varies  Max: 1 day)
479	Define the amount of time (in seconds) that the filesystem is
480	allowed to retry its operations when the specific error is
481	found.
482
483	Setting the value to "-1" will allow XFS to retry forever for this
484	specific error.
485
486	Setting the value to "0" will cause XFS to fail immediately when the
487	specific error is reported.
488
489	Setting the value to "N" (where 0 < N < Max) will allow XFS to retry the
490	operation for up to "N" seconds before propagating the error.
491
492**Note:** The default behaviour for a specific error handler is dependent on both
493the class and error context. For example, the default values for
494"metadata/ENODEV" are "0" rather than "-1" so that this error handler defaults
495to "fail immediately" behaviour. This is done because ENODEV is a fatal,
496unrecoverable error no matter how many times the metadata IO is retried.
497
498Workqueue Concurrency
499=====================
500
501XFS uses kernel workqueues to parallelize metadata update processes.  This
502enables it to take advantage of storage hardware that can service many IO
503operations simultaneously.  This interface exposes internal implementation
504details of XFS, and as such is explicitly not part of any userspace API/ABI
505guarantee the kernel may give userspace.  These are undocumented features of
506the generic workqueue implementation XFS uses for concurrency, and they are
507provided here purely for diagnostic and tuning purposes and may change at any
508time in the future.
509
510The control knobs for a filesystem's workqueues are organized by task at hand
511and the short name of the data device.  They all can be found in:
512
513  /sys/bus/workqueue/devices/${task}!${device}
514
515================  ===========
516  Task            Description
517================  ===========
518  xfs_iwalk-$pid  Inode scans of the entire filesystem. Currently limited to
519                  mount time quotacheck.
520  xfs-gc          Background garbage collection of disk space that have been
521                  speculatively allocated beyond EOF or for staging copy on
522                  write operations.
523================  ===========
524
525For example, the knobs for the quotacheck workqueue for /dev/nvme0n1 would be
526found in /sys/bus/workqueue/devices/xfs_iwalk-1111!nvme0n1/.
527
528The interesting knobs for XFS workqueues are as follows:
529
530============     ===========
531  Knob           Description
532============     ===========
533  max_active     Maximum number of background threads that can be started to
534                 run the work.
535  cpumask        CPUs upon which the threads are allowed to run.
536  nice           Relative priority of scheduling the threads.  These are the
537                 same nice levels that can be applied to userspace processes.
538============     ===========
539
540Zoned Filesystems
541=================
542
543For zoned file systems, the following attributes are exposed in:
544
545  /sys/fs/xfs/<dev>/zoned/
546
547  max_open_zones		(Min:  1  Default:  Varies  Max:  UINTMAX)
548	This read-only attribute exposes the maximum number of open zones
549	available for data placement. The value is determined at mount time and
550	is limited by the capabilities of the backing zoned device, file system
551	size and the max_open_zones mount option.
552
553  zonegc_low_space		(Min:  0  Default:  0  Max:  100)
554	Define a percentage for how much of the unused space that GC should keep
555	available for writing. A high value will reclaim more of the space
556	occupied by unused blocks, creating a larger buffer against write
557	bursts at the cost of increased write amplification.  Regardless
558	of this value, garbage collection will always aim to free a minimum
559	amount of blocks to keep max_open_zones open for data placement purposes.
560