Scroll to navigation

xfs_io(8) System Manager's Manual xfs_io(8)

NAME

xfs_io - debug the I/O path of an XFS filesystem

SYNOPSIS

xfs_io [ -adfimrRstxT ] [ -c cmd ] ... [ -C cmd ] ... [ -p prog ] [ file ]
xfs_io -V

DESCRIPTION

xfs_io is a debugging tool like xfs_db(8), but is aimed at examining the regular file I/O paths rather than the raw XFS volume itself. These code paths include not only the obvious read/write/mmap interfaces for manipulating files, but also cover all of the XFS extensions (such as space preallocation, additional inode flags, etc).

OPTIONS

xfs_io commands may be run interactively (the default) or as arguments on the command line. Interactive mode always runs commands on the current open file, whilst commands run from the command line may be repeated on all open files rather than just the current open file. In general, open file iteration will occur for commands that operate on file content or state. In contrast, commands that operate on filesystem or system-wide state will only be run on the current file regardless of how many files are currently open. Multiple arguments may be given on the command line and they are run in the sequence given. The program exits one all commands have been run.

Run the specified command on all currently open files. To maintain compatibility with historical usage, commands that can not be run on all open files will still be run but only execute once on the current open file. Multiple -c arguments may be given and may be interleaved on the command line in any order with -C commands.
Run the specified command only on the current open file. Multiple -C arguments may be given and may be interleaved on the command line in any order with -c commands.
Set the program name for prompts and some error messages, the default value is xfs_io.
Create file if it does not already exist.
Open file read-only, initially. This is required if file is immutable or append-only.
Start an idle thread. The purpose of this idle thread is to test io from a multi threaded process. With single threaded process, the file table is not shared and file structs are not reference counted. Spawning an idle thread can help detecting file struct reference leaks.
Expert mode. Dangerous commands are only available in this mode. These commands also tend to require additional privileges.
Prints the version number and exits.

The other open(2) options described below are also available from the command line.

CONCEPTS

xfs_io maintains a number of open files and memory mappings. Files can be initially opened on the command line (optionally), and additional files can also be opened later.

xfs_io commands can be broken up into three groups. Some commands are aimed at doing regular file I/O - read, write, sync, space preallocation, etc.

The second set of commands exist for manipulating memory mapped regions of a file - mapping, accessing, storing, unmapping, flushing, etc.

The remaining commands are for the navigation and display of data structures relating to the open files, mappings, and the filesystems where they reside.

Many commands have extensive online help. Use the help command for more details on any command.

FILE I/O COMMANDS

Display a list of all open files and (optionally) switch to an alternate current open file.
Closes the current file, and opens the file specified by path instead. Without any arguments, displays statistics about the current file - see the stat command.
opens append-only (O_APPEND).
opens for direct I/O (O_DIRECT).
creates the file if it doesn't already exist (O_CREAT).
opens read-only (O_RDONLY).
opens for synchronous I/O (O_SYNC).
truncates on open (O_TRUNC).
opens in non-blocking mode if possible (O_NONBLOCK).
create a temporary file not linked into the filesystem namespace (O_TMPFILE). The pathname passed must refer to a directory which is treated as virtual parent for the newly created invisible file. Can not be used together with the -r option.
marks the file as a realtime XFS file after opening it, if it is not already marked as such.
opens the path as a referent only (O_PATH). This is incompatible with other flags specifying other O_xxx flags apart from -L.
doesn't follow symlinks (O_NOFOLLOW). This is incompatible with other flags specifying other O_xxx flags apart from -P.
See the open command.
Closes the current open file, marking the next open file as current (if one exists).
See the close command.
Change the mode of the currently open file. The -r option will set the file permissions to read-only (0444), whilst the -w option will set the file permissions to read-write (0644). This allows xfs_io to set up mismatches between the file permissions and the open file descriptor read/write mode to exercise permission checks inside various syscalls.
Reads a range of bytes in a specified blocksize from the given offset.
can be used to set the blocksize into which the read(2) requests will be split. The default blocksize is 4096 bytes.
dump the contents of the buffer after reading, by default only the count of bytes actually read is dumped.
read the buffers in a forwards sequential direction.
read the buffers in a reserve sequential direction.
read the buffers in the give range in a random order.
specify the random number seed used for random reads.
-V vectors
Use the vectored IO read syscall preadv(2) with a number of blocksize length iovecs. The number of iovecs is set by the vectors parameter.
See the pread command.
Writes a range of bytes in a specified blocksize from the given offset. The bytes written can be either a set pattern or read in from another file before writing.
allows an input file to be specified as the source of the data to be written.
causes direct I/O, rather than the usual buffered I/O, to be used when reading the input file.
call fdatasync(2) once all writes are complete (included in timing results)
Perform the pwritev2(2) call with RWF_NOWAIT.
Perform the pwritev2(2) call with RWF_DSYNC.
perform pwrite once and return the (maybe partial) bytes written.
call fsync(2) once all writes are complete (included in timing results)
specifies the number of bytes to skip from the start of the input file before starting to read.
used to set the blocksize into which the write(2) requests will be split. The default blocksize is 4096 bytes.
used to set the (repeated) fill pattern which is used when the data to write is not coming from a file. The default buffer fill pattern value is 0xcdcdcdcd.
write the buffers in a forwards sequential direction.
write the buffers in a reserve sequential direction.
write the buffers in the give range in a random order.
specify the random number seed used for random write
-V vectors
Use the vectored IO write syscall pwritev(2) with a number of blocksize length iovecs. The number of iovecs is set by the vectors parameter.
See the pwrite command.
Prints the block mapping for the current open file. Refer to the xfs_bmap(8) manual page for complete documentation.
Prints the block mapping for the current open file using the fiemap ioctl. Options behave as described in the xfs_bmap(8) manual page.

Optionally, this command also supports passing the start offset from where to begin the mapping and the length of that region. The kernel will return any full extents which intersect with the requested range, and the fiemap command will print them in their entirety. If the requested range starts or ends in a hole, fiemap will print the hole, truncated to the requested range.
Display and/or modify the preferred extent size used when allocating space for the currently open file. If the -R option is specified, a recursive descent is performed for all directory entries below the currently open file (-D can be used to restrict the output to directories only). If the target file is a directory, then the inherited extent size is set for that directory (new files created in that directory inherit that extent size). The value should be specified in bytes, or using one of the usual units suffixes (k, m, g, b, etc). The extent size is always reported in units of bytes.
Display and/or modify the preferred copy-on-write extent size used when allocating space for the currently open file. If the -R option is specified, a recursive descent is performed for all directory entries below the currently open file (-D can be used to restrict the output to directories only). If the target file is a directory, then the inherited CoW extent size is set for that directory (new files created in that directory inherit that CoW extent size). The value should be specified in bytes, or using one of the usual units suffixes (k, m, g, b, etc). The extent size is always reported in units of bytes.
Sets the size of the file to size and zeroes any additional space allocated using the XFS_IOC_ALLOCSP/XFS_IOC_FREESP system call described in the xfsctl(3) manual page. allocsp and freesp do exactly the same thing.
See the allocsp command.
On platforms which support it, allows hints be given to the system regarding the expected I/O patterns on the file. The range arguments are required by some advise commands ([*] below), and the others must have no range arguments. With no arguments, the POSIX_FADV_NORMAL advice is implied (default readahead).
the data will not be accessed again in the near future (POSIX_FADV_DONTNEED[*]).
data will be accessed once and not be reused (POSIX_FADV_NOREUSE[*]).
expect access to data in random order (POSIX_FADV_RANDOM), which sets readahead to zero.
expect access to data in sequential order (POSIX_FADV_SEQUENTIAL), which doubles the default readahead on the file.
advises the specified data will be needed again (POSIX_FADV_WILLNEED[*]) which forces the maximum readahead.
Calls fdatasync(2) to flush the file's in-core data to disk.
Calls fsync(2) to flush all in-core file state to disk.
See the fsync command.
On platforms which support it, allows control of syncing a range of the file to disk. With no options, SYNC_FILE_RANGE_WRITE is implied on the range supplied.
wait for IO in the given range to finish after writing (SYNC_FILE_RANGE_WAIT_AFTER).
wait for IO in the given range to finish before writing (SYNC_FILE_RANGE_WAIT_BEFORE).
start writeback of dirty data in the given range (SYNC_FILE_RANGE_WRITE).
Calls sync(2) to flush all filesystems' in-core data to disk.
Calls syncfs(2) to flush this filesystem's in-core data to disk.
Allocates reserved, unwritten space for part of a file using the XFS_IOC_RESVSP system call described in the xfsctl(3) manual page.
Frees reserved space for part of a file using the XFS_IOC_UNRESVSP system call described in the xfsctl(3) manual page.
Allocates reserved, unwritten space for part of a file using the fallocate routine as described in the fallocate(2) manual page.
will set the FALLOC_FL_KEEP_SIZE flag as described in fallocate(2).
Call fallocate with FALLOC_FL_COLLAPSE_RANGE flag as described in the fallocate(2) manual page to de-allocates blocks and eliminates the hole created in this process by shifting data blocks into the hole.
Call fallocate with FALLOC_FL_INSERT_RANGE flag as described in the fallocate(2) manual page to create the hole by shifting data blocks.
Punches (de-allocates) blocks in the file by calling fallocate with the FALLOC_FL_PUNCH_HOLE flag as described in the fallocate(2) manual page.
Call fallocate with FALLOC_FL_UNSHARE_RANGE flag as described in the fallocate(2) manual page to unshare all shared blocks within the range.
Call fallocate with FALLOC_FL_ZERO_RANGE flag as described in the fallocate(2) manual page to allocate and zero blocks within the range. With the -k option, use the FALLOC_FL_KEEP_SIZE flag as well.
Call xfsctl with XFS_IOC_ZERO_RANGE as described in the xfsctl(3) manual page to allocate and zero blocks within the range.
Truncates the current file at the given offset using ftruncate(2).
On platforms which support it, allows a direct in-kernel copy between two file descriptors. The current open file is the target, the source must be specified as another open file (-f) or by path (-i).
Read a range of directory entries from a given offset of a directory.
verbose mode - dump dirent content as defined in readdir(3)
specify starting offset
specify total length to read (in bytes)
On platforms that support the lseek(2) SEEK_DATA and SEEK_HOLE options, display the offsets of the specified segments.
Display both data and hole segments starting at the specified offset.
Display the data segment starting at the specified offset.
Display the hole segment starting at the specified offset.
Recursively display all the specified segments starting at the specified offset.
Display the starting lseek(2) offset. This offset will be a calculated value when both data and holes are displayed together or performing a recusively display.
On filesystems that support the FICLONERANGE or BTRFS_IOC_CLONE_RANGE ioctls, map length bytes at offset dst_offset in the open file to the same physical blocks that are mapped at offset src_offset in the file src_file , replacing any contents that may already have been there. If a program writes into a reflinked block range of either file, the dirty blocks will be cloned, written to, and remapped ("copy on write") in the affected file, leaving the other file(s) unchanged. If src_offset, dst_offset, and length are omitted, all contents of src_file will be reflinked into the open file.
Print timing statistics in a condensed format.
Do not print timing statistics at all.
On filesystems that support the FIDEDUPERANGE or BTRFS_IOC_FILE_EXTENT_SAME ioctls, map length bytes at offset dst_offset in the open file to the same physical blocks that are mapped at offset src_offset in the file src_file , but only if the contents of both ranges are identical. This is known as block-based deduplication. If a program writes into a reflinked block range of either file, the dirty blocks will be cloned, written to, and remapped ("copy on write") in the affected file, leaving the other file(s) unchanged.
Print timing statistics in a condensed format.
Do not print timing statistics at all.
On filesystems that support the copy_file_range(2) system call, copies data from the src_file into the open file. If src_offset, dst_offset, and length are omitted the contents of src_file will be copied to the beginning of the open file, overwriting any data already there.
Copy data from src_file beginning from src_offset.
Copy data into the open file beginning at dst_offset.
Copy up to length bytes of data.
Swaps extent forks between files. The current open file is the target. The donor file is specified by path. Note that file data is not copied (file content moves with the fork(s)).
On filesystems that support encryption, assign an encryption policy to the current file. keydesc is a 16-byte hex string which identifies the encryption key to use. If not specified, a "default" key descriptor of all 0's will be used.
contents encryption mode (e.g. AES-256-XTS)
filenames encryption mode (e.g. AES-256-CTS)
policy flags (numeric)
version of policy structure (numeric)
On filesystems that support encryption, display the encryption policy of the current file.

List extended inode flags on the currently open file. If the -R option is specified, a recursive descent is performed for all directory entries below the currently open file (-D can be used to restrict the output to directories only). This is a depth first descent, it does not follow symlinks and it also does not cross mount points.
Change extended inode flags on the currently open file. The -R and -D options have the same meaning as above. The mapping between each letter and the inode flags (refer to xfsctl(3) for the full list) is available via the help command.
Link the currently open file descriptor into the filesystem namespace.
Selected statistics from stat(2) and the XFS_IOC_GETXATTR system call on the current file. If the -v option is specified, the atime (last access), mtime (last modify), and ctime (last change) timestamps are also displayed. The -r option dumps raw fields from the stat structure.
Selected statistics from stat(2) and the XFS_IOC_GETXATTR system call on the current file.
Show timestamps.
Dump raw statx structure values.
-m basic
Set the field mask for the statx call to STATX_BASIC_STATS.
-m all
Set the the field mask for the statx call to STATX_ALL (default).
-m <mask>
Specify a numeric field mask for the statx call.
Force the attributes to be synced with the server.
Don't sync attributes with the server.
Modifies the project identifier associated with the current path. The -R option will recursively descend if the current path is a directory. The -D option will also recursively descend, only setting modifying projects on subdirectories. See the xfs_quota(8) manual page for more information about project identifiers.
Displays the project identifier associated with the current path. The -R and -D options behave as described above, in chproj.
By default this command prints out the parent inode numbers, inode generation numbers and basenames of all the hardlinks which point to the inode of the current file.
the output is similar to the default output except pathnames up to the mount-point are printed out instead of the component name.
the file's filesystem will check all the parent attributes for consistency.
verbose output will be printed.
[NOTE: Not currently operational on Linux.]

The utimes command changes the atime and mtime of the current file. sec uses UNIX timestamp notation and is the seconds elapsed since 1970-01-01 00:00:00 UTC. nsec is the nanoseconds since the sec. This value needs to be in the range 0-999999999 with UTIME_NOW and UTIME_OMIT being exceptions. Each (sec, nsec) pair constitutes a single timestamp value.

MEMORY MAPPED I/O COMMANDS

With no arguments, mmap shows the current mappings. Specifying a single numeric argument N sets the current mapping. If two arguments are specified (a range specified by offset and length), a new mapping is created spanning the range, and the protection mode can be given as a combination of PROT_READ (-r), PROT_WRITE (-w), and PROT_EXEC (-x). The mapping will be created with the MAP_SHARED flag by default, or with the Linux specific (MAP_SYNC | MAP_SHARED_VALIDATE) flags if -S is given. -s size is used to do a mmap(size) && munmap(size) operation at first, try to reserve some extendible free memory space, if size is bigger than length parameter. But there's not guarantee that the memory after length ( up to size ) will stay free. e.g. "mmap -rw -s 8192 1024" will mmap 0 ~ 1024 bytes memory, but try to reserve 1024 ~ 8192 free space(no guarantee). This free space will helpful for "mremap 8192" without MREMAP_MAYMOVE flag.
See the mmap command.
Changes the current mapping size to new_length. Whether the mapping may be moved is controlled by the flags passed; MREMAP_FIXED (-f), or MREMAP_MAYMOVE (-m). new_length specifies a page-aligned address to which the mapping must be moved. It can be set to 139946004389888, 4096k or 1g etc.
See the mremap command.
Unmaps the current memory mapping.
See the munmap command.
Accesses a segment of the current memory mapping, optionally dumping it to the standard output stream (with -v or -f option) for inspection. The accesses are performed sequentially from the start offset by default, but can also be done from the end backwards through the mapping if the -r option in specified. The two verbose modes differ only in the relative offsets they display, the -f option is relative to file start, whereas -v shows offsets relative to the start of the mapping.
See the mread command.
Stores a byte into memory for a range within a mapping. The default stored value is 'X', repeated to fill the range specified, but this can be changed using the -S option. The memory stores are performed sequentially from the start offset by default, but can also be done from the end backwards through the mapping if the -r option in specified.
See the mwrite command.
Writes all modified copies of pages over the specified range (or entire mapping if no range specified) to their backing storage locations. Also, optionally invalidates (-i) so that subsequent references to the pages will be obtained from their backing storage locations (instead of cached copies). The flush can be done synchronously (-s) or asynchronously (-a).
See the msync command.
Modifies page cache behavior when operating on the current mapping. The range arguments are required by some advise commands ([*] below). With no arguments, the POSIX_MADV_NORMAL advice is implied (default readahead).
the pages will not be needed (POSIX_MADV_DONTNEED[*]).
expect random page references (POSIX_MADV_RANDOM), which sets readahead to zero.
expect sequential page references (POSIX_MADV_SEQUENTIAL), which doubles the default readahead on the file.
advises the specified pages will be needed again (POSIX_MADV_WILLNEED[*]) which forces the maximum readahead.
Dumps a list of pages or ranges of pages that are currently in core, for the current memory mapping.

FILESYSTEM COMMANDS

Suspend all write I/O requests to the filesystem of the current file. Only available in expert mode and requires privileges.
Undo the effects of a filesystem freeze operation. Only available in expert mode and requires privileges.
Inject errors into a filesystem to observe filesystem behavior at specific points under adverse conditions. Without the tag argument, displays the list of error tags available. Only available in expert mode and requires privileges.
Get and/or set count of reserved filesystem blocks using the XFS_IOC_GET_RESBLKS or XFS_IOC_SET_RESBLKS system calls. Note -- this can be useful for exercising out of space behavior. Only available in expert mode and requires privileges.
Force the filesystem to shut down, preventing any further IO. XFS and other filesystems implement this functionality, although implementation details may differ slightly. Only available in expert mode and requires privileges.

By default, the filesystem will not attempt to flush completed transactions to disk before shutting down the filesystem. This simulates a disk failure or crash.
Force the filesystem to flush all completed transactions to disk before shutting down, matching XFS behavior when critical corruption is encountered.
Selected statistics from statfs(2) and the XFS_IOC_FSGEOMETRY system call on the filesystem where the current file resides.
The inode command queries physical information about an inode. With no arguments, it will return 1 or 0, indicating whether or not any inode numbers greater than 32 bits are currently in use in the filesystem. If given an inode number as an argument, the command will return the same inode number if it is in use, or 0 if not. With -n number , the next used inode number after this number will be returned, or zero if the supplied inode number is the highest one in use. With -v the command will also report the number of bits (32 or 64) used by the inode number printed in the result; if no inode number was specified on the command line, the maximum possible inode number in the system will be printed along with its size.
Scrub internal XFS filesystem metadata. The type parameter specifies which type of metadata to scrub. For AG metadata, one AG number must be specified. For file metadata, the scrub is applied to the open file unless the inode number and generation number are specified.

Repair internal XFS filesystem metadata. The type parameter specifies which type of metadata to repair. For AG metadata, one AG number must be specified. For file metadata, the repair is applied to the open file unless the inode number and generation number are specified.
On filesystems that support online label manipulation, get, set, or clear the filesystem label. With no options, print the current filesystem label. The -c option clears the filesystem label by setting it to the null string. The -s label option sets the filesystem label to label. If the label is longer than the filesystem will accept, xfs_io will print an error message. XFS filesystem labels can be at most 12 characters long.
Prints the mapping of disk blocks used by the filesystem hosting the current file. The map lists each extent used by files, allocation group metadata, journalling logs, and static filesystem metadata, as well as any regions that are unused. Each line of the listings takes the following form:

extent: major:minor [startblock..endblock]: owner startoffset..endoffset length

Static filesystem metadata, allocation group metadata, btrees, journalling logs, and free space are marked by replacing the startoffset..endoffset with the appropriate marker. All blocks, offsets, and lengths are specified in units of 512-byte blocks, no matter what the filesystem's block size is. The optional start and end arguments can be used to constrain the output to a particular range of disk blocks. If these two options are specified, exactly one of -d, -l, or -r must also be set.

Display only extents from the data device. This option only applies for XFS filesystems.
Display only extents from the external log device. This option only applies to XFS filesystems.
Display only extents from the realtime device. This option only applies to XFS filesystems.
Display results in a machine readable format (CSV). This option is not compatible with the -v flag. The columns of the output are: extent number, device major, device minor, physical start, physical end, owner, offset start, offset end, length. The start, end, and length numbers are provided in units of 512b. The owner field is a special string that takes the form:

for inode data.
for inode data extent maps.
for inode extended attribute data.
for inode extended attribute extent maps.
for other filesystem metadata.

If this option is given, fsmap obtains the extent list of the file in groups of num_extents extents. In the absence of -n, fsmap queries the system for extents in groups of 131,072 records.
Shows verbose information. When this flag is specified, additional AG specific information is appended to each line in the following form:
agno (startagblock..endagblock) nblocks flags
A second -v option will print out the flags legend. This option is not compatible with the -m flag.

OTHER COMMANDS

Display a brief description of one or all commands.
Display a list of all open files and memory mapped regions. The current file and current mapping are distinguishable from any others.
See the print command.
Exit xfs_io.
See the quit command.
Create a mark named mark in the dm-log-writes log specified by device. This is intended to be equivalent to the shell command:

dmsetup message device 0 mark mark


See the log_writes command.
Test the internal crc32c implementation to make sure that it computes results correctly.

SEE ALSO

mkfs.xfs(8), xfsctl(3), xfs_bmap(8), xfs_db(8), xfs(5), fdatasync(2), fstat(2), fstatfs(2), fsync(2), ftruncate(2), futimens(3), mmap(2), msync(2), open(2), pread(2), pwrite(2), readdir(3), dmsetup(8).