xfs.rst 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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. attr2 or noattr2
  29. The options enable/disable an "opportunistic" improvement to
  30. be made in the way inline extended attributes are stored
  31. on-disk. When the new form is used for the first time when
  32. ``attr2`` is selected (either when setting or removing extended
  33. attributes) the on-disk superblock feature bit field will be
  34. updated to reflect this format being in use.
  35. The default behaviour is determined by the on-disk feature
  36. bit indicating that ``attr2`` behaviour is active. If either
  37. mount option is set, then that becomes the new default used
  38. by the filesystem.
  39. CRC enabled filesystems always use the ``attr2`` format, and so
  40. will reject the ``noattr2`` mount option if it is set.
  41. discard or nodiscard (default)
  42. Enable/disable the issuing of commands to let the block
  43. device reclaim space freed by the filesystem. This is
  44. useful for SSD devices, thinly provisioned LUNs and virtual
  45. machine images, but may have a performance impact.
  46. Note: It is currently recommended that you use the ``fstrim``
  47. application to ``discard`` unused blocks rather than the ``discard``
  48. mount option because the performance impact of this option
  49. is quite severe.
  50. grpid/bsdgroups or nogrpid/sysvgroups (default)
  51. These options define what group ID a newly created file
  52. gets. When ``grpid`` is set, it takes the group ID of the
  53. directory in which it is created; otherwise it takes the
  54. ``fsgid`` of the current process, unless the directory has the
  55. ``setgid`` bit set, in which case it takes the ``gid`` from the
  56. parent directory, and also gets the ``setgid`` bit set if it is
  57. a directory itself.
  58. filestreams
  59. Make the data allocator use the filestreams allocation mode
  60. across the entire filesystem rather than just on directories
  61. configured to use it.
  62. ikeep or noikeep (default)
  63. When ``ikeep`` is specified, XFS does not delete empty inode
  64. clusters and keeps them around on disk. When ``noikeep`` is
  65. specified, empty inode clusters are returned to the free
  66. space pool.
  67. inode32 or inode64 (default)
  68. When ``inode32`` is specified, it indicates that XFS limits
  69. inode creation to locations which will not result in inode
  70. numbers with more than 32 bits of significance.
  71. When ``inode64`` is specified, it indicates that XFS is allowed
  72. to create inodes at any location in the filesystem,
  73. including those which will result in inode numbers occupying
  74. more than 32 bits of significance.
  75. ``inode32`` is provided for backwards compatibility with older
  76. systems and applications, since 64 bits inode numbers might
  77. cause problems for some applications that cannot handle
  78. large inode numbers. If applications are in use which do
  79. not handle inode numbers bigger than 32 bits, the ``inode32``
  80. option should be specified.
  81. largeio or nolargeio (default)
  82. If ``nolargeio`` is specified, the optimal I/O reported in
  83. ``st_blksize`` by **stat(2)** will be as small as possible to allow
  84. user applications to avoid inefficient read/modify/write
  85. I/O. This is typically the page size of the machine, as
  86. this is the granularity of the page cache.
  87. If ``largeio`` is specified, a filesystem that was created with a
  88. ``swidth`` specified will return the ``swidth`` value (in bytes)
  89. in ``st_blksize``. If the filesystem does not have a ``swidth``
  90. specified but does specify an ``allocsize`` then ``allocsize``
  91. (in bytes) will be returned instead. Otherwise the behaviour
  92. is the same as if ``nolargeio`` was specified.
  93. logbufs=value
  94. Set the number of in-memory log buffers. Valid numbers
  95. range from 2-8 inclusive.
  96. The default value is 8 buffers.
  97. If the memory cost of 8 log buffers is too high on small
  98. systems, then it may be reduced at some cost to performance
  99. on metadata intensive workloads. The ``logbsize`` option below
  100. controls the size of each buffer and so is also relevant to
  101. this case.
  102. logbsize=value
  103. Set the size of each in-memory log buffer. The size may be
  104. specified in bytes, or in kilobytes with a "k" suffix.
  105. Valid sizes for version 1 and version 2 logs are 16384 (16k)
  106. and 32768 (32k). Valid sizes for version 2 logs also
  107. include 65536 (64k), 131072 (128k) and 262144 (256k). The
  108. logbsize must be an integer multiple of the log
  109. stripe unit configured at **mkfs(8)** time.
  110. The default value for version 1 logs is 32768, while the
  111. default value for version 2 logs is MAX(32768, log_sunit).
  112. logdev=device and rtdev=device
  113. Use an external log (metadata journal) and/or real-time device.
  114. An XFS filesystem has up to three parts: a data section, a log
  115. section, and a real-time section. The real-time section is
  116. optional, and the log section can be separate from the data
  117. section or contained within it.
  118. noalign
  119. Data allocations will not be aligned at stripe unit
  120. boundaries. This is only relevant to filesystems created
  121. with non-zero data alignment parameters (``sunit``, ``swidth``) by
  122. **mkfs(8)**.
  123. norecovery
  124. The filesystem will be mounted without running log recovery.
  125. If the filesystem was not cleanly unmounted, it is likely to
  126. be inconsistent when mounted in ``norecovery`` mode.
  127. Some files or directories may not be accessible because of this.
  128. Filesystems mounted ``norecovery`` must be mounted read-only or
  129. the mount will fail.
  130. nouuid
  131. Don't check for double mounted file systems using the file
  132. system ``uuid``. This is useful to mount LVM snapshot volumes,
  133. and often used in combination with ``norecovery`` for mounting
  134. read-only snapshots.
  135. noquota
  136. Forcibly turns off all quota accounting and enforcement
  137. within the filesystem.
  138. uquota/usrquota/uqnoenforce/quota
  139. User disk quota accounting enabled, and limits (optionally)
  140. enforced. Refer to **xfs_quota(8)** for further details.
  141. gquota/grpquota/gqnoenforce
  142. Group disk quota accounting enabled and limits (optionally)
  143. enforced. Refer to **xfs_quota(8)** for further details.
  144. pquota/prjquota/pqnoenforce
  145. Project disk quota accounting enabled and limits (optionally)
  146. enforced. Refer to **xfs_quota(8)** for further details.
  147. sunit=value and swidth=value
  148. Used to specify the stripe unit and width for a RAID device
  149. or a stripe volume. "value" must be specified in 512-byte
  150. block units. These options are only relevant to filesystems
  151. that were created with non-zero data alignment parameters.
  152. The ``sunit`` and ``swidth`` parameters specified must be compatible
  153. with the existing filesystem alignment characteristics. In
  154. general, that means the only valid changes to ``sunit`` are
  155. increasing it by a power-of-2 multiple. Valid ``swidth`` values
  156. are any integer multiple of a valid ``sunit`` value.
  157. Typically the only time these mount options are necessary if
  158. after an underlying RAID device has had it's geometry
  159. modified, such as adding a new disk to a RAID5 lun and
  160. reshaping it.
  161. swalloc
  162. Data allocations will be rounded up to stripe width boundaries
  163. when the current end of file is being extended and the file
  164. size is larger than the stripe width size.
  165. wsync
  166. When specified, all filesystem namespace operations are
  167. executed synchronously. This ensures that when the namespace
  168. operation (create, unlink, etc) completes, the change to the
  169. namespace is on stable storage. This is useful in HA setups
  170. where failover must not result in clients seeing
  171. inconsistent namespace presentation during or after a
  172. failover event.
  173. Deprecation of V4 Format
  174. ========================
  175. The V4 filesystem format lacks certain features that are supported by
  176. the V5 format, such as metadata checksumming, strengthened metadata
  177. verification, and the ability to store timestamps past the year 2038.
  178. Because of this, the V4 format is deprecated. All users should upgrade
  179. by backing up their files, reformatting, and restoring from the backup.
  180. Administrators and users can detect a V4 filesystem by running xfs_info
  181. against a filesystem mountpoint and checking for a string containing
  182. "crc=". If no such string is found, please upgrade xfsprogs to the
  183. latest version and try again.
  184. The deprecation will take place in two parts. Support for mounting V4
  185. filesystems can now be disabled at kernel build time via Kconfig option.
  186. The option will default to yes until September 2025, at which time it
  187. will be changed to default to no. In September 2030, support will be
  188. removed from the codebase entirely.
  189. Note: Distributors may choose to withdraw V4 format support earlier than
  190. the dates listed above.
  191. Deprecated Mount Options
  192. ========================
  193. =========================== ================
  194. Name Removal Schedule
  195. =========================== ================
  196. Mounting with V4 filesystem September 2030
  197. ikeep/noikeep September 2025
  198. attr2/noattr2 September 2025
  199. =========================== ================
  200. Removed Mount Options
  201. =====================
  202. =========================== =======
  203. Name Removed
  204. =========================== =======
  205. delaylog/nodelaylog v4.0
  206. ihashsize v4.0
  207. irixsgid v4.0
  208. osyncisdsync/osyncisosync v4.0
  209. barrier v4.19
  210. nobarrier v4.19
  211. =========================== =======
  212. sysctls
  213. =======
  214. The following sysctls are available for the XFS filesystem:
  215. fs.xfs.stats_clear (Min: 0 Default: 0 Max: 1)
  216. Setting this to "1" clears accumulated XFS statistics
  217. in /proc/fs/xfs/stat. It then immediately resets to "0".
  218. fs.xfs.xfssyncd_centisecs (Min: 100 Default: 3000 Max: 720000)
  219. The interval at which the filesystem flushes metadata
  220. out to disk and runs internal cache cleanup routines.
  221. fs.xfs.filestream_centisecs (Min: 1 Default: 3000 Max: 360000)
  222. The interval at which the filesystem ages filestreams cache
  223. references and returns timed-out AGs back to the free stream
  224. pool.
  225. fs.xfs.speculative_prealloc_lifetime
  226. (Units: seconds Min: 1 Default: 300 Max: 86400)
  227. The interval at which the background scanning for inodes
  228. with unused speculative preallocation runs. The scan
  229. removes unused preallocation from clean inodes and releases
  230. the unused space back to the free pool.
  231. fs.xfs.error_level (Min: 0 Default: 3 Max: 11)
  232. A volume knob for error reporting when internal errors occur.
  233. This will generate detailed messages & backtraces for filesystem
  234. shutdowns, for example. Current threshold values are:
  235. XFS_ERRLEVEL_OFF: 0
  236. XFS_ERRLEVEL_LOW: 1
  237. XFS_ERRLEVEL_HIGH: 5
  238. fs.xfs.panic_mask (Min: 0 Default: 0 Max: 256)
  239. Causes certain error conditions to call BUG(). Value is a bitmask;
  240. OR together the tags which represent errors which should cause panics:
  241. XFS_NO_PTAG 0
  242. XFS_PTAG_IFLUSH 0x00000001
  243. XFS_PTAG_LOGRES 0x00000002
  244. XFS_PTAG_AILDELETE 0x00000004
  245. XFS_PTAG_ERROR_REPORT 0x00000008
  246. XFS_PTAG_SHUTDOWN_CORRUPT 0x00000010
  247. XFS_PTAG_SHUTDOWN_IOERROR 0x00000020
  248. XFS_PTAG_SHUTDOWN_LOGERROR 0x00000040
  249. XFS_PTAG_FSBLOCK_ZERO 0x00000080
  250. XFS_PTAG_VERIFIER_ERROR 0x00000100
  251. This option is intended for debugging only.
  252. fs.xfs.irix_symlink_mode (Min: 0 Default: 0 Max: 1)
  253. Controls whether symlinks are created with mode 0777 (default)
  254. or whether their mode is affected by the umask (irix mode).
  255. fs.xfs.irix_sgid_inherit (Min: 0 Default: 0 Max: 1)
  256. Controls files created in SGID directories.
  257. If the group ID of the new file does not match the effective group
  258. ID or one of the supplementary group IDs of the parent dir, the
  259. ISGID bit is cleared if the irix_sgid_inherit compatibility sysctl
  260. is set.
  261. fs.xfs.inherit_sync (Min: 0 Default: 1 Max: 1)
  262. Setting this to "1" will cause the "sync" flag set
  263. by the **xfs_io(8)** chattr command on a directory to be
  264. inherited by files in that directory.
  265. fs.xfs.inherit_nodump (Min: 0 Default: 1 Max: 1)
  266. Setting this to "1" will cause the "nodump" flag set
  267. by the **xfs_io(8)** chattr command on a directory to be
  268. inherited by files in that directory.
  269. fs.xfs.inherit_noatime (Min: 0 Default: 1 Max: 1)
  270. Setting this to "1" will cause the "noatime" flag set
  271. by the **xfs_io(8)** chattr command on a directory to be
  272. inherited by files in that directory.
  273. fs.xfs.inherit_nosymlinks (Min: 0 Default: 1 Max: 1)
  274. Setting this to "1" will cause the "nosymlinks" flag set
  275. by the **xfs_io(8)** chattr command on a directory to be
  276. inherited by files in that directory.
  277. fs.xfs.inherit_nodefrag (Min: 0 Default: 1 Max: 1)
  278. Setting this to "1" will cause the "nodefrag" flag set
  279. by the **xfs_io(8)** chattr command on a directory to be
  280. inherited by files in that directory.
  281. fs.xfs.rotorstep (Min: 1 Default: 1 Max: 256)
  282. In "inode32" allocation mode, this option determines how many
  283. files the allocator attempts to allocate in the same allocation
  284. group before moving to the next allocation group. The intent
  285. is to control the rate at which the allocator moves between
  286. allocation groups when allocating extents for new files.
  287. Deprecated Sysctls
  288. ==================
  289. =========================== ================
  290. Name Removal Schedule
  291. =========================== ================
  292. fs.xfs.irix_sgid_inherit September 2025
  293. fs.xfs.irix_symlink_mode September 2025
  294. =========================== ================
  295. Removed Sysctls
  296. ===============
  297. ============================= =======
  298. Name Removed
  299. ============================= =======
  300. fs.xfs.xfsbufd_centisec v4.0
  301. fs.xfs.age_buffer_centisecs v4.0
  302. ============================= =======
  303. Error handling
  304. ==============
  305. XFS can act differently according to the type of error found during its
  306. operation. The implementation introduces the following concepts to the error
  307. handler:
  308. -failure speed:
  309. Defines how fast XFS should propagate an error upwards when a specific
  310. error is found during the filesystem operation. It can propagate
  311. immediately, after a defined number of retries, after a set time period,
  312. or simply retry forever.
  313. -error classes:
  314. Specifies the subsystem the error configuration will apply to, such as
  315. metadata IO or memory allocation. Different subsystems will have
  316. different error handlers for which behaviour can be configured.
  317. -error handlers:
  318. Defines the behavior for a specific error.
  319. The filesystem behavior during an error can be set via ``sysfs`` files. Each
  320. error handler works independently - the first condition met by an error handler
  321. for a specific class will cause the error to be propagated rather than reset and
  322. retried.
  323. The action taken by the filesystem when the error is propagated is context
  324. dependent - it may cause a shut down in the case of an unrecoverable error,
  325. it may be reported back to userspace, or it may even be ignored because
  326. there's nothing useful we can with the error or anyone we can report it to (e.g.
  327. during unmount).
  328. The configuration files are organized into the following hierarchy for each
  329. mounted filesystem:
  330. /sys/fs/xfs/<dev>/error/<class>/<error>/
  331. Where:
  332. <dev>
  333. The short device name of the mounted filesystem. This is the same device
  334. name that shows up in XFS kernel error messages as "XFS(<dev>): ..."
  335. <class>
  336. The subsystem the error configuration belongs to. As of 4.9, the defined
  337. classes are:
  338. - "metadata": applies metadata buffer write IO
  339. <error>
  340. The individual error handler configurations.
  341. Each filesystem has "global" error configuration options defined in their top
  342. level directory:
  343. /sys/fs/xfs/<dev>/error/
  344. fail_at_unmount (Min: 0 Default: 1 Max: 1)
  345. Defines the filesystem error behavior at unmount time.
  346. If set to a value of 1, XFS will override all other error configurations
  347. during unmount and replace them with "immediate fail" characteristics.
  348. i.e. no retries, no retry timeout. This will always allow unmount to
  349. succeed when there are persistent errors present.
  350. If set to 0, the configured retry behaviour will continue until all
  351. retries and/or timeouts have been exhausted. This will delay unmount
  352. completion when there are persistent errors, and it may prevent the
  353. filesystem from ever unmounting fully in the case of "retry forever"
  354. handler configurations.
  355. Note: there is no guarantee that fail_at_unmount can be set while an
  356. unmount is in progress. It is possible that the ``sysfs`` entries are
  357. removed by the unmounting filesystem before a "retry forever" error
  358. handler configuration causes unmount to hang, and hence the filesystem
  359. must be configured appropriately before unmount begins to prevent
  360. unmount hangs.
  361. Each filesystem has specific error class handlers that define the error
  362. propagation behaviour for specific errors. There is also a "default" error
  363. handler defined, which defines the behaviour for all errors that don't have
  364. specific handlers defined. Where multiple retry constraints are configured for
  365. a single error, the first retry configuration that expires will cause the error
  366. to be propagated. The handler configurations are found in the directory:
  367. /sys/fs/xfs/<dev>/error/<class>/<error>/
  368. max_retries (Min: -1 Default: Varies Max: INTMAX)
  369. Defines the allowed number of retries of a specific error before
  370. the filesystem will propagate the error. The retry count for a given
  371. error context (e.g. a specific metadata buffer) is reset every time
  372. there is a successful completion of the operation.
  373. Setting the value to "-1" will cause XFS to retry forever for this
  374. specific error.
  375. Setting the value to "0" will cause XFS to fail immediately when the
  376. specific error is reported.
  377. Setting the value to "N" (where 0 < N < Max) will make XFS retry the
  378. operation "N" times before propagating the error.
  379. retry_timeout_seconds (Min: -1 Default: Varies Max: 1 day)
  380. Define the amount of time (in seconds) that the filesystem is
  381. allowed to retry its operations when the specific error is
  382. found.
  383. Setting the value to "-1" will allow XFS to retry forever for this
  384. specific error.
  385. Setting the value to "0" will cause XFS to fail immediately when the
  386. specific error is reported.
  387. Setting the value to "N" (where 0 < N < Max) will allow XFS to retry the
  388. operation for up to "N" seconds before propagating the error.
  389. **Note:** The default behaviour for a specific error handler is dependent on both
  390. the class and error context. For example, the default values for
  391. "metadata/ENODEV" are "0" rather than "-1" so that this error handler defaults
  392. to "fail immediately" behaviour. This is done because ENODEV is a fatal,
  393. unrecoverable error no matter how many times the metadata IO is retried.