IOCTL-XFS-VERIFY-MEDIA(2)

πŸ“¦ version 7.2.1, in alpine 3.24, arch rolling, fedora 44, nixpkgs unstable

✨ ioctl_xfs_verify_media β€” verify the media of the devices backing XFS ✨

okay bestie, so this one lives in the System Calls Manual section (section 2, for the uninitiated πŸ’…) and it's literally the vibe check for the physical storage underneath your XFS filesystem. sit down, grab a strawberry drink πŸ“, and let's get into it.


🌸 NAME 🌸

ioctl_xfs_verify_media β€” verify the media of the devices backing XFS


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <xfs/xfs_fs.h>

int ioctl(int fd, XFS_IOC_VERIFY_MEDIA, struct xfs_verify_media *arg);

✨ DESCRIPTION ✨

So what you're doing here is verifying the media of a storage device backing an XFS filesystem. And if errors pop up? You report them to the kernel, so it can generate health events for the health monitoring system and fsnotify. no cap, the kernel is the one keeping receipts πŸ“.

The verification request travels inside a structure that looks exactly like this:

struct xfs_verify_media {
     __u32     me_dev;
     __u32     me_flags;
     __u64     me_start_daddr;
     __u64     me_end_daddr;
     __u32     me_ioerror;
     __u32     me_max_io_size;
     __u32     me_rest_us;
     __u32     me_pad;
};

The field me_pad must be zero. not negotiable, don't be chaotic.

The field me_ioerror will be set if the ioctl returns success.

The fields me_start_daddr and me_end_daddr are the range of the storage device to verify. Both values must be in units of 512-byte blocks. The me_start_daddr field is inclusive, and the me_end_daddr field is exclusive. If me_end_daddr is larger than the size of the device, the kernel will set it to the size of the device. it's giving "the kernel corrects you, lovingly".

If the system call returns success and any part of the storage device range was successfully verified, the me_start_daddr field will be updated to reflect the successful verification. If after this update the me_start_daddr is equal to me_end_daddr, then the entire range was verified successfully. πŸŽ‰

If not, then a media error was encountered and the caller should generate a series of secondary calls to this ioctl with smaller ranges to discover the exact location and type of media error. The type of media error will be written to the me_ioerror field. think of it like zooming in on a blurry photo until you find the cursed pixel πŸ”.

The me_max_io_size field, if nonzero, is an upper bound on the I/O operations that the kernel will issue to the block device.

The me_rest_us is the time duration, in microseconds, for which the kernel will wait between issuing I/O operations. yes, the kernel takes little breaks. self-care king πŸ‘‘.

The field me_dev must be one of the following values:

  • XFS_DEV_DATA β€” Verify the data device.
  • XFS_DEV_LOG β€” Verify the external log device.
  • XFS_DEV_RT β€” Verify the realtime device.

The field me_flags is a bitmask of one of the following values:

  • XFS_VERIFY_MEDIA_REPORT β€” Report all media errors to fsnotify.

The me_max_io_size field, if nonzero, will be used as advice for the maximum size of the IO to send to the device.

The me_rest_us field will cause the kernel to pause for this many microseconds between IO requests.


πŸ’– RETURN VALUE πŸ’–

On runtime error, -1 is returned, and errno is set to indicate the error. If 0 is returned, then start_daddr or ioerror will be updated. periodt.


🌈 ERRORS 🌈

Error codes can be one of, but are not limited to, the following:

  • EPERM β€” The calling process does not have sufficient privilege.
  • EINVAL β€” One or more of the arguments specified is invalid.
  • EFAULT β€” The arg structure could not be copied into the kernel.
  • ENODEV β€” The device is not present.
  • ENOMEM β€” There was not enough memory to perform the verification.

πŸ’€ I/O ERRORS πŸ’€

The ioerror field could be set to one of the following:

  • 0 β€” The verification I/O succeeded.
  • EOPNOTSUPP
  • ETIMEDOUT β€” The kernel timed out the verification I/O command.
  • ENOLINK β€” The transportation link to the storage device was down temporarily.
  • EREMOTEIO β€” The storage target controller suffered a critical error.
  • ENODATA β€” The storage target media suffered a critical error.
  • EILSEQ β€” Storage protection metadata did not validate successfully.
  • ENOMEM β€” There was not enough memory to allocate an I/O request.
  • ENODEV β€” The storage device is offline.
  • ETIME β€” The storage device timed out the I/O command.
  • EINVAL β€” The I/O request was rejected by the device for being invalid.
  • EIO β€” An I/O error occurred but no specific details are available.

This list is not exhaustive and may grow in the future. so don't come for me if new ones show up πŸ™ˆ.


🧚 CONFORMING TO 🧚

This API is specific to XFS filesystem on the Linux kernel. it does not play well with others, it's loyal like that πŸ’œ.


🫢 SEE ALSO 🫢


and that's the whole page, bestie ✨ this was XFS, dated 2026-01-09, and yeah β€” that's the version, that's the source, that's the tea πŸŽ€ slay, go verify some media, i'm obsessed πŸ’…

πŸ“¦ where this page comes from