3 xfs_io \- debug the I/O path of an XFS filesystem
23 is a debugging tool like
25 but is aimed at examining the regular file I/O paths rather than the
26 raw XFS volume itself.
27 These code paths include not only the obvious read/write/mmap interfaces
28 for manipulating files, but also cover all of the XFS extensions (such
29 as space preallocation, additional inode flags, etc).
32 commands may be run interactively (the default) or as arguments on the
34 Interactive mode always runs commands on the current open file, whilst commands
35 run from the command line may be repeated on all open files rather than just the current
37 In general, open file iteration will occur for commands that operate on file
38 content or state. In contrast, commands that operate on filesystem or
39 system-wide state will only be run on the current file regardless of how many
40 files are currently open.
41 Multiple arguments may be given on the command line and they are run in the
42 sequence given. The program exits one all commands have
46 Run the specified command on all currently open files.
47 To maintain compatibility with historical usage, commands that can not be run on
48 all open files will still be run but only execute once on the current open file.
51 arguments may be given and may be interleaved on the command line in any order
57 Run the specified command only on the current open file.
60 arguments may be given and may be interleaved on the command line in any order
66 Set the program name for prompts and some error messages,
73 if it does not already exist.
78 read-only, initially. This is required if
80 is immutable or append-only.
83 Start an idle thread. The purpose of this idle thread is to test io
84 from a multi threaded process. With single threaded process,
85 the file table is not shared and file structs are not reference counted.
86 Spawning an idle thread can help detecting file struct reference leaks.
89 Expert mode. Dangerous commands are only available in this mode.
90 These commands also tend to require additional privileges.
93 Prints the version number and exits.
97 options described below are also available from the command line.
100 maintains a number of open files and memory mappings.
101 Files can be initially opened on the command line (optionally),
102 and additional files can also be opened later.
105 commands can be broken up into three groups.
106 Some commands are aimed at doing regular file I/O - read, write,
107 sync, space preallocation, etc.
109 The second set of commands exist for manipulating memory mapped regions
110 of a file - mapping, accessing, storing, unmapping, flushing, etc.
112 The remaining commands are for the navigation and display of data
113 structures relating to the open files, mappings, and the filesystems
116 Many commands have extensive online help. Use the
118 command for more details on any command.
119 .SH FILE I/O COMMANDS
122 Display a list of all open files and (optionally) switch to an alternate
125 .BI "open [[ \-acdfrstRT ] " path " ]"
126 Closes the current file, and opens the file specified by
128 instead. Without any arguments, displays statistics about the current
136 opens append-only (O_APPEND).
139 opens for direct I/O (O_DIRECT).
142 creates the file if it doesn't already exist (O_CREAT).
145 opens read-only (O_RDONLY).
148 opens for synchronous I/O (O_SYNC).
151 truncates on open (O_TRUNC).
154 opens in non-blocking mode if possible (O_NONBLOCK).
157 create a temporary file not linked into the filesystem namespace
158 (O_TMPFILE). The pathname passed must refer to a directory which
159 is treated as virtual parent for the newly created invisible file.
160 Can not be used together with the
165 marks the file as a realtime XFS file after
166 opening it, if it is not already marked as such.
176 Closes the current open file, marking the next open file as current
184 .BI "pread [ \-b " bsize " ] [ \-v ] [ \-FBR [ \-Z " seed " ] ] [ \-V " vectors " ] " "offset length"
185 Reads a range of bytes in a specified blocksize from the given
191 can be used to set the blocksize into which the
193 requests will be split. The default blocksize is 4096 bytes.
196 dump the contents of the buffer after reading,
197 by default only the count of bytes actually read is dumped.
200 read the buffers in a forwards sequential direction.
203 read the buffers in a reserve sequential direction.
206 read the buffers in the give range in a random order.
209 specify the random number seed used for random reads.
212 Use the vectored IO read syscall
214 with a number of blocksize length iovecs. The number of iovecs is set by the
225 .BI "pwrite [ \-i " file " ] [ \-d ] [ \-s " skip " ] [ \-b " size " ] [ \-S " seed " ] [ \-FBR [ \-Z " zeed " ] ] [ \-wW ] [ \-V " vectors " ] " "offset length"
226 Writes a range of bytes in a specified blocksize from the given
228 The bytes written can be either a set pattern or read in from another
236 to be specified as the source of the data to be written.
239 causes direct I/O, rather than the usual buffered
240 I/O, to be used when reading the input file.
243 specifies the number of bytes to
245 from the start of the input file before starting to read.
248 used to set the blocksize into which the
250 requests will be split. The default blocksize is 4096 bytes.
253 used to set the (repeated) fill pattern which
254 is used when the data to write is not coming from a file.
255 The default buffer fill pattern value is 0xcdcdcdcd.
258 write the buffers in a forwards sequential direction.
261 write the buffers in a reserve sequential direction.
264 write the buffers in the give range in a random order.
267 specify the random number seed used for random write
272 once all writes are complete (included in timing results)
277 once all writes are complete (included in timing results)
280 Use the vectored IO write syscall
282 with a number of blocksize length iovecs. The number of iovecs is set by the
293 .BI "bmap [ \-acdelpv ] [ \-n " nx " ]"
294 Prints the block mapping for the current open file. Refer to the
296 manual page for complete documentation.
298 .BI "fiemap [ \-alv ] [ \-n " nx " ]"
299 Prints the block mapping for the current open file using the fiemap
300 ioctl. Options behave as described in the
304 .BI "extsize [ \-R | \-D ] [ " value " ]"
305 Display and/or modify the preferred extent size used when allocating
306 space for the currently open file. If the
308 option is specified, a recursive descent is performed
309 for all directory entries below the currently open file
311 can be used to restrict the output to directories only).
312 If the target file is a directory, then the inherited extent size
313 is set for that directory (new files created in that directory
314 inherit that extent size).
317 should be specified in bytes, or using one of the usual units suffixes
318 (k, m, g, b, etc). The extent size is always reported in units of bytes.
320 .BI "cowextsize [ \-R | \-D ] [ " value " ]"
321 Display and/or modify the preferred copy-on-write extent size used
322 when allocating space for the currently open file. If the
324 option is specified, a recursive descent is performed
325 for all directory entries below the currently open file
327 can be used to restrict the output to directories only).
328 If the target file is a directory, then the inherited CoW extent size
329 is set for that directory (new files created in that directory
330 inherit that CoW extent size).
333 should be specified in bytes, or using one of the usual units suffixes
334 (k, m, g, b, etc). The extent size is always reported in units of bytes.
336 .BI "allocsp " size " 0"
337 Sets the size of the file to
339 and zeroes any additional space allocated using the
340 XFS_IOC_ALLOCSP/XFS_IOC_FREESP system call described in the
346 do exactly the same thing.
348 .BI "freesp " size " 0"
353 .BI "fadvise [ \-r | \-s | [[ \-d | \-n | \-w ] " "offset length " ]]
354 On platforms which support it, allows hints be given to the system
355 regarding the expected I/O patterns on the file.
356 The range arguments are required by some advise commands ([*] below), and
357 the others must have no range arguments.
358 With no arguments, the POSIX_FADV_NORMAL advice is implied (default readahead).
363 the data will not be accessed again in the near future (POSIX_FADV_DONTNEED[*]).
366 data will be accessed once and not be reused (POSIX_FADV_NOREUSE[*]).
369 expect access to data in random order (POSIX_FADV_RANDOM), which sets readahead to zero.
372 expect access to data in sequential order (POSIX_FADV_SEQUENTIAL),
373 which doubles the default readahead on the file.
376 advises the specified data will be needed again (POSIX_FADV_WILLNEED[*])
377 which forces the maximum readahead.
384 to flush the file's in-core data to disk.
389 to flush all in-core file state to disk.
396 .BI "sync_range [ \-a | \-b | \-w ] offset length "
397 On platforms which support it, allows control of syncing a range of the file to
398 disk. With no options, SYNC_FILE_RANGE_WRITE is implied on the range supplied.
403 wait for IO in the given range to finish after writing
404 (SYNC_FILE_RANGE_WAIT_AFTER).
407 wait for IO in the given range to finish before writing
408 (SYNC_FILE_RANGE_WAIT_BEFORE).
411 start writeback of dirty data in the given range (SYNC_FILE_RANGE_WRITE).
418 to flush all filesystems' in-core data to disk.
423 to flush this filesystem's in-core data to disk.
425 .BI resvsp " offset length"
426 Allocates reserved, unwritten space for part of a file using the
427 XFS_IOC_RESVSP system call described in the
431 .BI unresvsp " offset length"
432 Frees reserved space for part of a file using the XFS_IOC_UNRESVSP
433 system call described in the
437 .BI "falloc [ \-k ]" " offset length"
438 Allocates reserved, unwritten space for part of a file using the
439 fallocate routine as described in the
446 will set the FALLOC_FL_KEEP_SIZE flag as described in
451 .BI fcollapse " offset length"
452 Call fallocate with FALLOC_FL_COLLAPSE_RANGE flag as described in the
454 manual page to de-allocates blocks and eliminates the hole created in this process
455 by shifting data blocks into the hole.
457 .BI finsert " offset length"
458 Call fallocate with FALLOC_FL_INSERT_RANGE flag as described in the
460 manual page to create the hole by shifting data blocks.
462 .BI fpunch " offset length"
463 Punches (de-allocates) blocks in the file by calling fallocate with
464 the FALLOC_FL_PUNCH_HOLE flag as described in the
468 .BI funshare " offset length"
469 Call fallocate with FALLOC_FL_UNSHARE_RANGE flag as described in the
471 manual page to unshare all shared blocks within the range.
473 .BI fzero " offset length"
474 Call fallocate with FALLOC_FL_ZERO_RANGE flag as described in the
476 manual page to allocate and zero blocks within the range.
478 .BI zero " offset length"
480 .B XFS_IOC_ZERO_RANGE
483 manual page to allocate and zero blocks within the range.
485 .BI truncate " offset"
486 Truncates the current file at the given offset using
489 .BI "sendfile \-i " srcfile " | \-f " N " [ " "offset length " ]
490 On platforms which support it, allows a direct in-kernel copy between
491 two file descriptors. The current open file is the target, the source
492 must be specified as another open file
497 .BI "readdir [ -v ] [ -o " offset " ] [ -l " length " ] "
498 Read a range of directory entries from a given offset of a directory.
503 verbose mode - dump dirent content as defined in
517 .BI "seek \-a | \-d | \-h [ \-r ] [ \-s ] offset"
518 On platforms that support the
523 options, display the offsets of the specified segments.
532 segments starting at the specified
538 segment starting at the specified
544 segment starting at the specified
548 Recursively display all the specified segments starting at the specified
552 Display the starting lseek(2) offset. This offset will be a calculated value when
553 both data and holes are displayed together or performing a recusively display.
557 .BI "reflink [ \-C ] [ \-q ] src_file [src_offset dst_offset length]"
558 On filesystems that support the
561 .B BTRFS_IOC_CLONE_RANGE
566 in the open file to the same physical blocks that are mapped at offset
570 , replacing any contents that may already have been there. If a program
571 writes into a reflinked block range of either file, the dirty blocks will be
572 cloned, written to, and remapped ("copy on write") in the affected file,
573 leaving the other file(s) unchanged. If src_offset, dst_offset, and length
574 are omitted, all contents of src_file will be reflinked into the open file.
579 Print timing statistics in a condensed format.
582 Do not print timing statistics at all.
586 .BI "dedupe [ \-C ] [ \-q ] src_file src_offset dst_offset length"
587 On filesystems that support the
590 .B BTRFS_IOC_FILE_EXTENT_SAME
595 in the open file to the same physical blocks that are mapped at offset
599 , but only if the contents of both ranges are identical. This is known as
600 block-based deduplication. If a program writes into a reflinked block range of
601 either file, the dirty blocks will be cloned, written to, and remapped ("copy
602 on write") in the affected file, leaving the other file(s) unchanged.
607 Print timing statistics in a condensed format.
610 Do not print timing statistics at all.
614 .BI "copy_range [ -s " src_offset " ] [ -d " dst_offset " ] [ -l " length " ] src_file"
615 On filesystems that support the
616 .BR copy_file_range (2)
617 system call, copies data from the
619 into the open file. If
624 are omitted the contents of src_file will be copied to the beginning of the
625 open file, overwriting any data already there.
636 Copy data into the open file beginning at
646 .BI utimes " atime_sec atime_nsec mtime_sec mtime_nsec"
647 The utimes command changes the atime and mtime of the current file.
648 sec uses UNIX timestamp notation and is the seconds elapsed since
649 1970-01-01 00:00:00 UTC.
650 nsec is the nanoseconds since the sec. This value needs to be in
651 the range 0-999999999 with UTIME_NOW and UTIME_OMIT being exceptions.
652 Each (sec, nsec) pair constitutes a single timestamp value.
654 .SH MEMORY MAPPED I/O COMMANDS
656 .BI "mmap [ " N " | [[ \-rwx ] [\-s " size " ] " "offset length " ]]
659 shows the current mappings. Specifying a single numeric argument
661 sets the current mapping. If two arguments are specified (a range specified by
665 a new mapping is created spanning the range, and the protection mode can
666 be given as a combination of PROT_READ
673 is used to do a mmap(size) && munmap(size) operation at first, try to reserve some
674 extendible free memory space, if
678 parameter. But there's not guarantee that the memory after
684 "mmap -rw -s 8192 1024" will mmap 0 ~ 1024 bytes memory, but try to reserve 1024 ~ 8192
685 free space(no guarantee). This free space will helpful for "mremap 8192" without
693 .BI "mremap [ \-f <new_address> ] [ \-m ] " new_length
694 Changes the current mapping size to
696 Whether the mapping may be moved is controlled by the flags passed;
702 specifies a page-aligned address to which the mapping must be moved. It
703 can be setted to 139946004389888, 4096k or 1g etc.
711 Unmaps the current memory mapping.
718 .BI "mread [ \-f | \-v ] [ \-r ] [" " offset length " ]
719 Accesses a segment of the current memory mapping, optionally dumping it to
720 the standard output stream (with
724 option) for inspection. The accesses are performed sequentially from the start
726 by default, but can also be done from the end backwards through the
730 The two verbose modes differ only in the relative offsets they display, the
732 option is relative to file start, whereas
734 shows offsets relative to the start of the mapping.
741 .BI "mwrite [ \-r ] [ \-S " seed " ] [ " "offset length " ]
742 Stores a byte into memory for a range within a mapping.
743 The default stored value is 'X', repeated to fill the range specified,
744 but this can be changed using the
747 The memory stores are performed sequentially from the start offset by default,
748 but can also be done from the end backwards through the mapping if the
757 .BI "msync [ \-i ] [ \-a | \-s ] [ " "offset length " ]
758 Writes all modified copies of pages over the specified range (or entire
759 mapping if no range specified) to their backing storage locations.
760 Also, optionally invalidates
762 so that subsequent references to the pages will be obtained from their
763 backing storage locations (instead of cached copies).
764 The flush can be done synchronously
774 .BI "madvise [ \-d | \-r | \-s | \-w ] [ " "offset length " ]
775 Modifies page cache behavior when operating on the current mapping.
776 The range arguments are required by some advise commands ([*] below).
777 With no arguments, the POSIX_MADV_NORMAL advice is implied (default readahead).
782 the pages will not be needed (POSIX_MADV_DONTNEED[*]).
785 expect random page references (POSIX_MADV_RANDOM), which sets readahead to zero.
788 expect sequential page references (POSIX_MADV_SEQUENTIAL),
789 which doubles the default readahead on the file.
792 advises the specified pages will be needed again (POSIX_MADV_WILLNEED[*])
793 which forces the maximum readahead.
798 Dumps a list of pages or ranges of pages that are currently in core,
799 for the current memory mapping.
803 .BR "help [ " command " ]"
804 Display a brief description of one or all commands.
807 Display a list of all open files and memory mapped regions.
808 The current file and current mapping are distinguishable from
825 .BR lsattr " [ " \-R " | " \-D " | " \-a " | " \-v " ]"
826 List extended inode flags on the currently open file. If the
828 option is specified, a recursive descent is performed
829 for all directory entries below the currently open file
831 can be used to restrict the output to directories only).
832 This is a depth first descent, it does not follow symlinks and
833 it also does not cross mount points.
835 .BR chattr " [ " \-R " | " \-D " ] [ " + / \-riasAdtPneEfSxC " ]"
836 Change extended inode flags on the currently open file. The
840 options have the same meaning as above. The mapping between each
841 letter and the inode flags (refer to
843 for the full list) is available via the
848 Suspend all write I/O requests to the filesystem of the current file.
849 Only available in expert mode and requires privileges.
852 Undo the effects of a filesystem freeze operation.
853 Only available in expert mode and requires privileges.
856 Link the currently open file descriptor into the filesystem namespace.
858 .BI "inject [ " tag " ]"
859 Inject errors into a filesystem to observe filesystem behavior at
860 specific points under adverse conditions. Without the
862 argument, displays the list of error tags available.
863 Only available in expert mode and requires privileges.
865 .BI "resblks [ " blocks " ]"
866 Get and/or set count of reserved filesystem blocks using the
867 XFS_IOC_GET_RESBLKS or XFS_IOC_SET_RESBLKS system calls.
868 Note \-\- this can be useful for exercising out of space behavior.
869 Only available in expert mode and requires privileges.
871 .BR shutdown " [ " \-f " ]"
872 Force the filesystem to shutdown (with or without flushing the log).
873 Only available in expert mode and requires privileges.
875 .BR stat " [ " \-v "|" \-r " ]"
876 Selected statistics from
878 and the XFS_IOC_GETXATTR system call on the current file. If the
880 option is specified, the atime (last access), mtime
881 (last modify), and ctime (last change) timestamps are also displayed. The
883 option dumps raw fields from the stat structure.
885 .BI "statx [ \-v|\-r ][ \-m " basic " | \-m " all " | -m " <mask> " ][ \-FD ]"
886 Selected statistics from
888 and the XFS_IOC_GETXATTR system call on the current file.
896 Dump raw statx structure values.
899 Set the field mask for the statx call to STATX_BASIC_STATS.
902 Set the the field mask for the statx call to STATX_ALL (default).
905 Specify a numeric field mask for the statx call.
908 Force the attributes to be synced with the server.
911 Don't sync attributes with the server.
916 Selected statistics from
918 and the XFS_IOC_FSGEOMETRY
919 system call on the filesystem where the current file resides.
921 .BR chproj " [ " \-R | \-D " ]"
922 Modifies the project identifier associated with the current path. The
924 option will recursively descend if the current path is a directory. The
926 option will also recursively descend, only setting modifying projects
927 on subdirectories. See the
929 manual page for more information about project identifiers.
931 .BR lsproj " [ " \-R | \-D " ]"
932 Displays the project identifier associated with the current path. The
936 options behave as described above, in
939 .BR parent " [ " \-cpv " ]"
940 By default this command prints out the parent inode numbers,
941 inode generation numbers and basenames of all the hardlinks which
942 point to the inode of the current file.
947 the output is similar to the default output except pathnames up to
948 the mount-point are printed out instead of the component name.
951 the file's filesystem will check all the parent attributes for consistency.
954 verbose output will be printed.
957 .B [NOTE: Not currently operational on Linux.]
960 .BI "set_encpolicy [ \-c " mode " ] [ \-n " mode " ] [ \-f " flags " ] [ \-v " version " ] [ " keydesc " ]
961 On filesystems that support encryption, assign an encryption policy to the
964 is a 16-byte hex string which identifies the encryption key to use.
965 If not specified, a "default" key descriptor of all 0's will be used.
970 contents encryption mode (e.g. AES-256-XTS)
973 filenames encryption mode (e.g. AES-256-CTS)
976 policy flags (numeric)
979 version of policy structure (numeric)
984 On filesystems that support encryption, display the encryption policy of the