From: Darrick J. Wong Date: Sun, 22 Feb 2026 22:41:05 +0000 (-0800) Subject: xfs: add media verification ioctl X-Git-Tag: v7.0.0~87 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b669642fe6fab7b2191e82c51aa02b9706fa61fb;p=xfsprogs-dev.git xfs: add media verification ioctl Source kernel commit: b8accfd65d31f25b9df15ec2419179b6fa0b21d5 Add a new privileged ioctl so that xfs_scrub can ask the kernel to verify the media of the devices backing an xfs filesystem, and have any resulting media errors reported to fsnotify and xfs_healer. To accomplish this, the kernel allocates a folio between the base page size and 1MB, and issues read IOs to a gradually incrementing range of one of the storage devices underlying an xfs filesystem. If any error occurs, that raw error is reported to the calling process. If the error happens to be one of the ones that the kernel considers indicative of data loss, then it will also be reported to xfs_healthmon and fsnotify. Driving the verification from the kernel enables xfs (and by extension xfs_scrub) to have precise control over the size and error handling of IOs that are issued to the underlying block device, and to emit notifications about problems to other relevant kernel subsystems immediately. Note that the caller is also allowed to reduce the size of the IO and to ask for a relaxation period after each IO. Signed-off-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig --- diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h index a01303c5..d165de60 100644 --- a/libxfs/xfs_fs.h +++ b/libxfs/xfs_fs.h @@ -1160,6 +1160,34 @@ struct xfs_health_file_on_monitored_fs { __u32 flags; /* zero for now */ }; +/* Verify the media of the underlying devices */ +struct xfs_verify_media { + __u32 me_dev; /* I: XFS_DEV_{DATA,LOG,RT} */ + __u32 me_flags; /* I: XFS_VERIFY_MEDIA_* */ + + /* + * IO: inclusive start of disk range to verify, in 512b blocks. + * Will be adjusted upwards as media verification succeeds. + */ + __u64 me_start_daddr; + + /* + * IO: exclusive end of the disk range to verify, in 512b blocks. + * Can be adjusted downwards to match device size. + */ + __u64 me_end_daddr; + + __u32 me_ioerror; /* O: I/O error (positive) */ + __u32 me_max_io_size; /* I: maximum IO size in bytes */ + + __u32 me_rest_us; /* I: rest time between IOs, usecs */ + __u32 me_pad; /* zero */ +}; + +#define XFS_VERIFY_MEDIA_REPORT (1 << 0) /* report to fsnotify */ + +#define XFS_VERIFY_MEDIA_FLAGS (XFS_VERIFY_MEDIA_REPORT) + /* * ioctl commands that are used by Linux filesystems */ @@ -1202,6 +1230,8 @@ struct xfs_health_file_on_monitored_fs { #define XFS_IOC_HEALTH_MONITOR _IOW ('X', 68, struct xfs_health_monitor) #define XFS_IOC_HEALTH_FD_ON_MONITORED_FS \ _IOW ('X', 69, struct xfs_health_file_on_monitored_fs) +#define XFS_IOC_VERIFY_MEDIA _IOWR('X', 70, struct xfs_verify_media) + /* * ioctl commands that replace IRIX syssgi()'s */