xfs.rst 22 KB

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