Skip to contentSkip to conversation

actually exercise sub-block direct I/O reads

PATCH In review Christoph Hellwig 3 participants 24 messages Aug 31 – Sep 14

lore
Share & tools
lore
#0 lore raw

Hi all,

when looking into testing changes that might require a minimum read size larger than a page size, I realized that various tests hard code PAGE_SIZE as a direct I/O read size despite claiming that they exercise sub-block direct I/O.

This series adds support to query the minimum read size and actually uses that for testing.

#1 lore raw

PATCH 1/5 statx.h: update to latest kernel UAPI

Update the localy provided statx definition to the kernel UAPI as of 7.3-rc1.

---
 src/statx.h | 126 +++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 96 insertions(+), 30 deletions(-)
src/statx.h +96 -30
index bae1c86f6201..0a27bf030b1d 100644
@@ -95,44 +95,97 @@ struct statx_timestamp {
  */
 struct statx {
 	/* 0x00 */
-	__u32	stx_mask;	/* What results were written [uncond] */
-	__u32	stx_blksize;	/* Preferred general I/O size [uncond] */
-	__u64	stx_attributes;	/* Flags conveying information about the file [uncond] */
+	/* What results were written [uncond] */
+	__u32	stx_mask;
+
+	/* Preferred general I/O size [uncond] */
+	__u32	stx_blksize;
+
+	/* Flags conveying information about the file [uncond] */
+	__u64	stx_attributes;
+
 	/* 0x10 */
-	__u32	stx_nlink;	/* Number of hard links */
-	__u32	stx_uid;	/* User ID of owner */
-	__u32	stx_gid;	/* Group ID of owner */
-	__u16	stx_mode;	/* File mode */
+	/* Number of hard links */
+	__u32	stx_nlink;
+
+	/* User ID of owner */
+	__u32	stx_uid;
+
+	/* Group ID of owner */
+	__u32	stx_gid;
+
+	/* File mode */
+	__u16	stx_mode;
 	__u16	__spare0[1];
+
 	/* 0x20 */
-	__u64	stx_ino;	/* Inode number */
-	__u64	stx_size;	/* File size */
-	__u64	stx_blocks;	/* Number of 512-byte blocks allocated */
-	__u64	stx_attributes_mask; /* Mask to show what's supported in stx_attributes */
+	/* Inode number */
+	__u64	stx_ino;
+
+	/* File size */
+	__u64	stx_size;
+
+	/* Number of 512-byte blocks allocated */
+	__u64	stx_blocks;
+
+	/* Mask to show what's supported in stx_attributes */
+	__u64	stx_attributes_mask;
 
 	/* 0x40 */
-	struct statx_timestamp	stx_atime;	/* Last access time */
-	struct statx_timestamp	stx_btime;	/* File creation time */
-	struct statx_timestamp	stx_ctime;	/* Last attribute change time */
-	struct statx_timestamp	stx_mtime;	/* Last data modification time */
+	/* Last access time */
+	struct statx_timestamp	stx_atime;
+
+	/* File creation time */
+	struct statx_timestamp	stx_btime;
+
+	/* Last attribute change time */
+	struct statx_timestamp	stx_ctime;
+
+	/* Last data modification time */
+	struct statx_timestamp	stx_mtime;
+
 	/* 0x80 */
-	__u32	stx_rdev_major;	/* Device ID of special file [if bdev/cdev] */
+	/* Device ID of special file [if bdev/cdev] */
+	__u32	stx_rdev_major;
 	__u32	stx_rdev_minor;
-	__u32	stx_dev_major;	/* ID of device containing file [uncond] */
+
+	/* ID of device containing file [uncond] */
+	__u32	stx_dev_major;
 	__u32	stx_dev_minor;
+
 	/* 0x90 */
 	__u64	stx_mnt_id;
-	__u32	stx_dio_mem_align;	/* Memory buffer alignment for direct I/O */
-	__u32	stx_dio_offset_align;	/* File offset alignment for direct I/O */
+
+	/* Memory buffer alignment for direct I/O */
+	__u32	stx_dio_mem_align;
+
+	/* File offset alignment for direct I/O */
+	__u32	stx_dio_offset_align;
+
 	/* 0xa0 */
-	__u64	stx_subvol;	/* Subvolume identifier */
-	__u32	stx_atomic_write_unit_min;	/* Min atomic write unit in bytes */
-	__u32	stx_atomic_write_unit_max;	/* Max atomic write unit in bytes */
+	/* Subvolume identifier */
+	__u64	stx_subvol;
+
+	/* Min atomic write unit in bytes */
+	__u32	stx_atomic_write_unit_min;
+
+	/* Max atomic write unit in bytes */
+	__u32	stx_atomic_write_unit_max;
+
 	/* 0xb0 */
-	__u32   stx_atomic_write_segments_max;	/* Max atomic write segment count */
-	__u32   __spare1[1];
-	/* 0xb8 */
-	__u64	__spare3[9];	/* Spare space for future expansion */
+	/* Max atomic write segment count */
+	__u32   stx_atomic_write_segments_max;
+
+	/* File offset alignment for direct I/O reads */
+	__u32	stx_dio_read_offset_align;
+
+	/* Optimised max atomic write unit in bytes */
+	__u32	stx_atomic_write_unit_max_opt;
+	__u32	__spare2[1];
+
+	/* 0xc0 */
+	__u64	__spare3[8];	/* Spare space for future expansion */
+
 	/* 0x100 */
 };
 
@@ -162,19 +215,32 @@ struct statx {
 #define STATX_MNT_ID_UNIQUE	0x00004000U	/* Want/got extended stx_mount_id */
 #define STATX_SUBVOL		0x00008000U	/* Want/got stx_subvol */
 #define STATX_WRITE_ATOMIC	0x00010000U	/* Want/got atomic_write_* fields */
+#define STATX_DIO_READ_ALIGN	0x00020000U	/* Want/got dio read alignment info */
 
-#define STATX_ALL		0x00000fffU	/* All currently supported flags */
+#define STATX__RESERVED		0x80000000U	/* Reserved for future struct statx expansion */
 
+#ifndef __KERNEL__
 /*
- * Attributes to be found in stx_attributes
+ * This is deprecated, and shall remain the same value in the future.  To avoid
+ * confusion please use the equivalent (STATX_BASIC_STATS | STATX_BTIME)
+ * instead.
+ */
+#define STATX_ALL		0x00000fffU
+#endif
+
+/*
+ * Attributes to be found in stx_attributes and masked in stx_attributes_mask.
  *
  * These give information about the features or the state of a file that might
  * be of use to ordinary userspace programs such as GUIs or ls rather than
  * specialised tools.
  *
- * Note that the flags marked [I] correspond to generic FS_IOC_FLAGS
+ * Note that the flags marked [I] correspond to the FS_IOC_SETFLAGS flags
  * semantically.  Where possible, the numerical value is picked to correspond
- * also.
+ * also.  Note that the DAX attribute indicates that the file is in the CPU
+ * direct access state.  It does not correspond to the per-inode flag that
+ * some filesystems support.
+ *
  */
 #define STATX_ATTR_COMPRESSED		0x00000004 /* [I] File is compressed by the fs */
 #define STATX_ATTR_IMMUTABLE		0x00000010 /* [I] File is marked immutable */
Signature · 1 line
2.53.0
Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] statx.h: update to latest kernel UAPI

Quoted 4 lines · Christoph Hellwig

Update the localy provided statx definition to the kernel UAPI as of 7.3-rc1.

Seems fine to me;

--D

Quoted 173 lines
---
 src/statx.h | 126 +++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 96 insertions(+), 30 deletions(-)
src/statx.h +96 -30
index bae1c86f6201..0a27bf030b1d 100644
@@ -95,44 +95,97 @@ struct statx_timestamp {
  */
 struct statx {
 	/* 0x00 */
-	__u32	stx_mask;	/* What results were written [uncond] */
-	__u32	stx_blksize;	/* Preferred general I/O size [uncond] */
-	__u64	stx_attributes;	/* Flags conveying information about the file [uncond] */
+	/* What results were written [uncond] */
+	__u32	stx_mask;
+
+	/* Preferred general I/O size [uncond] */
+	__u32	stx_blksize;
+
+	/* Flags conveying information about the file [uncond] */
+	__u64	stx_attributes;
+
 	/* 0x10 */
-	__u32	stx_nlink;	/* Number of hard links */
-	__u32	stx_uid;	/* User ID of owner */
-	__u32	stx_gid;	/* Group ID of owner */
-	__u16	stx_mode;	/* File mode */
+	/* Number of hard links */
+	__u32	stx_nlink;
+
+	/* User ID of owner */
+	__u32	stx_uid;
+
+	/* Group ID of owner */
+	__u32	stx_gid;
+
+	/* File mode */
+	__u16	stx_mode;
 	__u16	__spare0[1];
+
 	/* 0x20 */
-	__u64	stx_ino;	/* Inode number */
-	__u64	stx_size;	/* File size */
-	__u64	stx_blocks;	/* Number of 512-byte blocks allocated */
-	__u64	stx_attributes_mask; /* Mask to show what's supported in stx_attributes */
+	/* Inode number */
+	__u64	stx_ino;
+
+	/* File size */
+	__u64	stx_size;
+
+	/* Number of 512-byte blocks allocated */
+	__u64	stx_blocks;
+
+	/* Mask to show what's supported in stx_attributes */
+	__u64	stx_attributes_mask;
 
 	/* 0x40 */
-	struct statx_timestamp	stx_atime;	/* Last access time */
-	struct statx_timestamp	stx_btime;	/* File creation time */
-	struct statx_timestamp	stx_ctime;	/* Last attribute change time */
-	struct statx_timestamp	stx_mtime;	/* Last data modification time */
+	/* Last access time */
+	struct statx_timestamp	stx_atime;
+
+	/* File creation time */
+	struct statx_timestamp	stx_btime;
+
+	/* Last attribute change time */
+	struct statx_timestamp	stx_ctime;
+
+	/* Last data modification time */
+	struct statx_timestamp	stx_mtime;
+
 	/* 0x80 */
-	__u32	stx_rdev_major;	/* Device ID of special file [if bdev/cdev] */
+	/* Device ID of special file [if bdev/cdev] */
+	__u32	stx_rdev_major;
 	__u32	stx_rdev_minor;
-	__u32	stx_dev_major;	/* ID of device containing file [uncond] */
+
+	/* ID of device containing file [uncond] */
+	__u32	stx_dev_major;
 	__u32	stx_dev_minor;
+
 	/* 0x90 */
 	__u64	stx_mnt_id;
-	__u32	stx_dio_mem_align;	/* Memory buffer alignment for direct I/O */
-	__u32	stx_dio_offset_align;	/* File offset alignment for direct I/O */
+
+	/* Memory buffer alignment for direct I/O */
+	__u32	stx_dio_mem_align;
+
+	/* File offset alignment for direct I/O */
+	__u32	stx_dio_offset_align;
+
 	/* 0xa0 */
-	__u64	stx_subvol;	/* Subvolume identifier */
-	__u32	stx_atomic_write_unit_min;	/* Min atomic write unit in bytes */
-	__u32	stx_atomic_write_unit_max;	/* Max atomic write unit in bytes */
+	/* Subvolume identifier */
+	__u64	stx_subvol;
+
+	/* Min atomic write unit in bytes */
+	__u32	stx_atomic_write_unit_min;
+
+	/* Max atomic write unit in bytes */
+	__u32	stx_atomic_write_unit_max;
+
 	/* 0xb0 */
-	__u32   stx_atomic_write_segments_max;	/* Max atomic write segment count */
-	__u32   __spare1[1];
-	/* 0xb8 */
-	__u64	__spare3[9];	/* Spare space for future expansion */
+	/* Max atomic write segment count */
+	__u32   stx_atomic_write_segments_max;
+
+	/* File offset alignment for direct I/O reads */
+	__u32	stx_dio_read_offset_align;
+
+	/* Optimised max atomic write unit in bytes */
+	__u32	stx_atomic_write_unit_max_opt;
+	__u32	__spare2[1];
+
+	/* 0xc0 */
+	__u64	__spare3[8];	/* Spare space for future expansion */
+
 	/* 0x100 */
 };
 
@@ -162,19 +215,32 @@ struct statx {
 #define STATX_MNT_ID_UNIQUE	0x00004000U	/* Want/got extended stx_mount_id */
 #define STATX_SUBVOL		0x00008000U	/* Want/got stx_subvol */
 #define STATX_WRITE_ATOMIC	0x00010000U	/* Want/got atomic_write_* fields */
+#define STATX_DIO_READ_ALIGN	0x00020000U	/* Want/got dio read alignment info */
 
-#define STATX_ALL		0x00000fffU	/* All currently supported flags */
+#define STATX__RESERVED		0x80000000U	/* Reserved for future struct statx expansion */
 
+#ifndef __KERNEL__
 /*
- * Attributes to be found in stx_attributes
+ * This is deprecated, and shall remain the same value in the future.  To avoid
+ * confusion please use the equivalent (STATX_BASIC_STATS | STATX_BTIME)
+ * instead.
+ */
+#define STATX_ALL		0x00000fffU
+#endif
+
+/*
+ * Attributes to be found in stx_attributes and masked in stx_attributes_mask.
  *
  * These give information about the features or the state of a file that might
  * be of use to ordinary userspace programs such as GUIs or ls rather than
  * specialised tools.
  *
- * Note that the flags marked [I] correspond to generic FS_IOC_FLAGS
+ * Note that the flags marked [I] correspond to the FS_IOC_SETFLAGS flags
  * semantically.  Where possible, the numerical value is picked to correspond
- * also.
+ * also.  Note that the DAX attribute indicates that the file is in the CPU
+ * direct access state.  It does not correspond to the per-inode flag that
+ * some filesystems support.
+ *
  */
 #define STATX_ATTR_COMPRESSED		0x00000004 /* [I] File is compressed by the fs */
 #define STATX_ATTR_IMMUTABLE		0x00000010 /* [I] File is marked immutable */
Signature · 1 line
2.53.0
Reviewed-by on v1 1/5
#3 lore raw

Re: [PATCH 1/5] statx.h: update to latest kernel UAPI

In reply to Christoph Hellwig
Quoted 1 line · Christoph Hellwig

Update the localy provided statx definition to the kernel UAPI as of

This patch looks good to me, I'll change "localy" to "locally" when I merge it. Thanks!

Quoted 175 lines

7.3-rc1.

---
 src/statx.h | 126 +++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 96 insertions(+), 30 deletions(-)
src/statx.h +96 -30
index bae1c86f6201..0a27bf030b1d 100644
@@ -95,44 +95,97 @@ struct statx_timestamp {
  */
 struct statx {
 	/* 0x00 */
-	__u32	stx_mask;	/* What results were written [uncond] */
-	__u32	stx_blksize;	/* Preferred general I/O size [uncond] */
-	__u64	stx_attributes;	/* Flags conveying information about the file [uncond] */
+	/* What results were written [uncond] */
+	__u32	stx_mask;
+
+	/* Preferred general I/O size [uncond] */
+	__u32	stx_blksize;
+
+	/* Flags conveying information about the file [uncond] */
+	__u64	stx_attributes;
+
 	/* 0x10 */
-	__u32	stx_nlink;	/* Number of hard links */
-	__u32	stx_uid;	/* User ID of owner */
-	__u32	stx_gid;	/* Group ID of owner */
-	__u16	stx_mode;	/* File mode */
+	/* Number of hard links */
+	__u32	stx_nlink;
+
+	/* User ID of owner */
+	__u32	stx_uid;
+
+	/* Group ID of owner */
+	__u32	stx_gid;
+
+	/* File mode */
+	__u16	stx_mode;
 	__u16	__spare0[1];
+
 	/* 0x20 */
-	__u64	stx_ino;	/* Inode number */
-	__u64	stx_size;	/* File size */
-	__u64	stx_blocks;	/* Number of 512-byte blocks allocated */
-	__u64	stx_attributes_mask; /* Mask to show what's supported in stx_attributes */
+	/* Inode number */
+	__u64	stx_ino;
+
+	/* File size */
+	__u64	stx_size;
+
+	/* Number of 512-byte blocks allocated */
+	__u64	stx_blocks;
+
+	/* Mask to show what's supported in stx_attributes */
+	__u64	stx_attributes_mask;
 
 	/* 0x40 */
-	struct statx_timestamp	stx_atime;	/* Last access time */
-	struct statx_timestamp	stx_btime;	/* File creation time */
-	struct statx_timestamp	stx_ctime;	/* Last attribute change time */
-	struct statx_timestamp	stx_mtime;	/* Last data modification time */
+	/* Last access time */
+	struct statx_timestamp	stx_atime;
+
+	/* File creation time */
+	struct statx_timestamp	stx_btime;
+
+	/* Last attribute change time */
+	struct statx_timestamp	stx_ctime;
+
+	/* Last data modification time */
+	struct statx_timestamp	stx_mtime;
+
 	/* 0x80 */
-	__u32	stx_rdev_major;	/* Device ID of special file [if bdev/cdev] */
+	/* Device ID of special file [if bdev/cdev] */
+	__u32	stx_rdev_major;
 	__u32	stx_rdev_minor;
-	__u32	stx_dev_major;	/* ID of device containing file [uncond] */
+
+	/* ID of device containing file [uncond] */
+	__u32	stx_dev_major;
 	__u32	stx_dev_minor;
+
 	/* 0x90 */
 	__u64	stx_mnt_id;
-	__u32	stx_dio_mem_align;	/* Memory buffer alignment for direct I/O */
-	__u32	stx_dio_offset_align;	/* File offset alignment for direct I/O */
+
+	/* Memory buffer alignment for direct I/O */
+	__u32	stx_dio_mem_align;
+
+	/* File offset alignment for direct I/O */
+	__u32	stx_dio_offset_align;
+
 	/* 0xa0 */
-	__u64	stx_subvol;	/* Subvolume identifier */
-	__u32	stx_atomic_write_unit_min;	/* Min atomic write unit in bytes */
-	__u32	stx_atomic_write_unit_max;	/* Max atomic write unit in bytes */
+	/* Subvolume identifier */
+	__u64	stx_subvol;
+
+	/* Min atomic write unit in bytes */
+	__u32	stx_atomic_write_unit_min;
+
+	/* Max atomic write unit in bytes */
+	__u32	stx_atomic_write_unit_max;
+
 	/* 0xb0 */
-	__u32   stx_atomic_write_segments_max;	/* Max atomic write segment count */
-	__u32   __spare1[1];
-	/* 0xb8 */
-	__u64	__spare3[9];	/* Spare space for future expansion */
+	/* Max atomic write segment count */
+	__u32   stx_atomic_write_segments_max;
+
+	/* File offset alignment for direct I/O reads */
+	__u32	stx_dio_read_offset_align;
+
+	/* Optimised max atomic write unit in bytes */
+	__u32	stx_atomic_write_unit_max_opt;
+	__u32	__spare2[1];
+
+	/* 0xc0 */
+	__u64	__spare3[8];	/* Spare space for future expansion */
+
 	/* 0x100 */
 };
 
@@ -162,19 +215,32 @@ struct statx {
 #define STATX_MNT_ID_UNIQUE	0x00004000U	/* Want/got extended stx_mount_id */
 #define STATX_SUBVOL		0x00008000U	/* Want/got stx_subvol */
 #define STATX_WRITE_ATOMIC	0x00010000U	/* Want/got atomic_write_* fields */
+#define STATX_DIO_READ_ALIGN	0x00020000U	/* Want/got dio read alignment info */
 
-#define STATX_ALL		0x00000fffU	/* All currently supported flags */
+#define STATX__RESERVED		0x80000000U	/* Reserved for future struct statx expansion */
 
+#ifndef __KERNEL__
 /*
- * Attributes to be found in stx_attributes
+ * This is deprecated, and shall remain the same value in the future.  To avoid
+ * confusion please use the equivalent (STATX_BASIC_STATS | STATX_BTIME)
+ * instead.
+ */
+#define STATX_ALL		0x00000fffU
+#endif
+
+/*
+ * Attributes to be found in stx_attributes and masked in stx_attributes_mask.
  *
  * These give information about the features or the state of a file that might
  * be of use to ordinary userspace programs such as GUIs or ls rather than
  * specialised tools.
  *
- * Note that the flags marked [I] correspond to generic FS_IOC_FLAGS
+ * Note that the flags marked [I] correspond to the FS_IOC_SETFLAGS flags
  * semantically.  Where possible, the numerical value is picked to correspond
- * also.
+ * also.  Note that the DAX attribute indicates that the file is in the CPU
+ * direct access state.  It does not correspond to the per-inode flag that
+ * some filesystems support.
+ *
  */
 #define STATX_ATTR_COMPRESSED		0x00000004 /* [I] File is compressed by the fs */
 #define STATX_ATTR_IMMUTABLE		0x00000010 /* [I] File is marked immutable */
Signature · 1 line
2.53.0
#4 lore raw

PATCH 2/5 min_dio_alignment: add a -r option to query read alignment

In reply to Christoph Hellwig

Add an option to query the STATX_DIO_READ_ALIGN if provided.

---
 src/min_dio_alignment.c | 44 ++++++++++++++++++++++++++++++-----------
 1 file changed, 33 insertions(+), 11 deletions(-)
src/min_dio_alignment.c +33 -11
index 866fba1546c4..143cee684ab4 100644
@@ -1,17 +1,19 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (c) 2024 Christoph Hellwig
+ * Copyright (c) 2024,2026 Christoph Hellwig
  */
 #include <fcntl.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <getopt.h>
 #include <sys/mount.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 #include "statx.h"
 
-static int min_dio_alignment(const char *mntpnt, const char *devname)
+static int min_dio_alignment(const char *mntpnt, const char *devname, bool read)
 {
 	struct statx stx = { };
 	struct stat st;
@@ -27,9 +29,16 @@ static int min_dio_alignment(const char *mntpnt, const char *devname)
 	 */
 	fd = open(mntpnt, O_TMPFILE | O_RDWR | O_EXCL, 0600);
 	if (fd >= 0 &&
-	    xfstests_statx(fd, "", AT_EMPTY_PATH, STATX_DIOALIGN, &stx) == 0 &&
-	    (stx.stx_mask & STATX_DIOALIGN) && stx.stx_dio_offset_align != 0)
-		return stx.stx_dio_offset_align;
+	    xfstests_statx(fd, "", AT_EMPTY_PATH, STATX_DIOALIGN, &stx) == 0) {
+		if (read &&
+		    (stx.stx_mask & STATX_DIO_READ_ALIGN) &&
+		    stx.stx_dio_read_offset_align != 0)
+			return stx.stx_dio_read_offset_align;
+
+		if ((stx.stx_mask & STATX_DIOALIGN) &&
+		    stx.stx_dio_offset_align != 0)
+			return stx.stx_dio_offset_align;
+	}
 
 	/*
 	 * If we are on a block device and no explicit aligned is reported, use
@@ -42,9 +51,8 @@ static int min_dio_alignment(const char *mntpnt, const char *devname)
 		if (dev_fd > 0 &&
 		    fstat(dev_fd, &st) == 0 &&
 		    S_ISBLK(st.st_mode) &&
-		    ioctl(dev_fd, BLKSSZGET, &logical_block_size) == 0) {
+		    ioctl(dev_fd, BLKSSZGET, &logical_block_size) == 0)
 			return logical_block_size;
-		}
 	}
 
 	/*
@@ -56,11 +64,25 @@ static int min_dio_alignment(const char *mntpnt, const char *devname)
 
 int main(int argc, char **argv)
 {
-	if (argc != 3) {
-		fprintf(stderr, "usage: %s mountpoint devicename\n", argv[0]);
-		exit(1);
+	bool read = false;
+	int c;
+
+	while ((c = getopt(argc, argv, "r")) != -1) {
+		switch(c) {
+		case 'r':
+			read = 1;
+			break;
+		default:
+			goto usage;
+		}
 	}
 
-	printf("%d\n", min_dio_alignment(argv[1], argv[2]));
+	if (argc - optind != 2)
+		goto usage;
+
+	printf("%d\n", min_dio_alignment(argv[optind], argv[optind + 1], read));
 	exit(0);
+usage:
+	fprintf(stderr, "usage: %s [-r] mountpoint devicename\n", argv[0]);
+	exit(1);
 }
Signature · 1 line
2.53.0
Reviewed-by on v1 2/5
#5 lore raw

Re: [PATCH 2/5] min_dio_alignment: add a -r option to query read alignment

Quoted 3 lines · Christoph Hellwig

Add an option to query the STATX_DIO_READ_ALIGN if provided.

This makes sense to me. It's sorta nice to have a canonical example of how you're supposed to access the directio geometry fields :)

--D

Quoted 95 lines
---
 src/min_dio_alignment.c | 44 ++++++++++++++++++++++++++++++-----------
 1 file changed, 33 insertions(+), 11 deletions(-)
src/min_dio_alignment.c +33 -11
index 866fba1546c4..143cee684ab4 100644
@@ -1,17 +1,19 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (c) 2024 Christoph Hellwig
+ * Copyright (c) 2024,2026 Christoph Hellwig
  */
 #include <fcntl.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <getopt.h>
 #include <sys/mount.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 #include "statx.h"
 
-static int min_dio_alignment(const char *mntpnt, const char *devname)
+static int min_dio_alignment(const char *mntpnt, const char *devname, bool read)
 {
 	struct statx stx = { };
 	struct stat st;
@@ -27,9 +29,16 @@ static int min_dio_alignment(const char *mntpnt, const char *devname)
 	 */
 	fd = open(mntpnt, O_TMPFILE | O_RDWR | O_EXCL, 0600);
 	if (fd >= 0 &&
-	    xfstests_statx(fd, "", AT_EMPTY_PATH, STATX_DIOALIGN, &stx) == 0 &&
-	    (stx.stx_mask & STATX_DIOALIGN) && stx.stx_dio_offset_align != 0)
-		return stx.stx_dio_offset_align;
+	    xfstests_statx(fd, "", AT_EMPTY_PATH, STATX_DIOALIGN, &stx) == 0) {
+		if (read &&
+		    (stx.stx_mask & STATX_DIO_READ_ALIGN) &&
+		    stx.stx_dio_read_offset_align != 0)
+			return stx.stx_dio_read_offset_align;
+
+		if ((stx.stx_mask & STATX_DIOALIGN) &&
+		    stx.stx_dio_offset_align != 0)
+			return stx.stx_dio_offset_align;
+	}
 
 	/*
 	 * If we are on a block device and no explicit aligned is reported, use
@@ -42,9 +51,8 @@ static int min_dio_alignment(const char *mntpnt, const char *devname)
 		if (dev_fd > 0 &&
 		    fstat(dev_fd, &st) == 0 &&
 		    S_ISBLK(st.st_mode) &&
-		    ioctl(dev_fd, BLKSSZGET, &logical_block_size) == 0) {
+		    ioctl(dev_fd, BLKSSZGET, &logical_block_size) == 0)
 			return logical_block_size;
-		}
 	}
 
 	/*
@@ -56,11 +64,25 @@ static int min_dio_alignment(const char *mntpnt, const char *devname)
 
 int main(int argc, char **argv)
 {
-	if (argc != 3) {
-		fprintf(stderr, "usage: %s mountpoint devicename\n", argv[0]);
-		exit(1);
+	bool read = false;
+	int c;
+
+	while ((c = getopt(argc, argv, "r")) != -1) {
+		switch(c) {
+		case 'r':
+			read = 1;
+			break;
+		default:
+			goto usage;
+		}
 	}
 
-	printf("%d\n", min_dio_alignment(argv[1], argv[2]));
+	if (argc - optind != 2)
+		goto usage;
+
+	printf("%d\n", min_dio_alignment(argv[optind], argv[optind + 1], read));
 	exit(0);
+usage:
+	fprintf(stderr, "usage: %s [-r] mountpoint devicename\n", argv[0]);
+	exit(1);
 }
Signature · 1 line
2.53.0
#6 lore raw

Re: [PATCH 2/5] min_dio_alignment: add a -r option to query read alignment

In reply to Christoph Hellwig
Quoted 34 lines · Christoph Hellwig

Add an option to query the STATX_DIO_READ_ALIGN if provided.

---
 src/min_dio_alignment.c | 44 ++++++++++++++++++++++++++++++-----------
 1 file changed, 33 insertions(+), 11 deletions(-)
src/min_dio_alignment.c +4 -2
index 866fba1546c4..143cee684ab4 100644
@@ -1,17 +1,19 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (c) 2024 Christoph Hellwig
+ * Copyright (c) 2024,2026 Christoph Hellwig
  */
 #include <fcntl.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <getopt.h>
 #include <sys/mount.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 #include "statx.h"
 
-static int min_dio_alignment(const char *mntpnt, const char *devname)
+static int min_dio_alignment(const char *mntpnt, const char *devname, bool read)
 {
 	struct statx stx = { };
 	struct stat st;

src/min_dio_alignment.c static int min_dio_alignment(const char *mntpnt, const char *devname) · line 32

Quoted 7 lines
src/min_dio_alignment.c +1 -3
@@ -27,9 +29,16 @@ static int min_dio_alignment(const char *mntpnt, const char *devname)
 	 */
 	fd = open(mntpnt, O_TMPFILE | O_RDWR | O_EXCL, 0600);
 	if (fd >= 0 &&
-	    xfstests_statx(fd, "", AT_EMPTY_PATH, STATX_DIOALIGN, &stx) == 0 &&
-	    (stx.stx_mask & STATX_DIOALIGN) && stx.stx_dio_offset_align != 0)
-		return stx.stx_dio_offset_align;
+	    xfstests_statx(fd, "", AT_EMPTY_PATH, STATX_DIOALIGN, &stx) == 0) {

Hmm... shouldn't STATX_DIO_READ_ALIGN be passed in the request mask as well?

xfstests_statx(fd, "", AT_EMPTY_PATH,
STATX_DIOALIGN|STATX_DIO_READ_ALIGN, &stx)

Quoted 56 lines
src/min_dio_alignment.c +28 -6
+		if (read &&
+		    (stx.stx_mask & STATX_DIO_READ_ALIGN) &&
+		    stx.stx_dio_read_offset_align != 0)
+			return stx.stx_dio_read_offset_align;
+
+		if ((stx.stx_mask & STATX_DIOALIGN) &&
+		    stx.stx_dio_offset_align != 0)
+			return stx.stx_dio_offset_align;
+	}
 
 	/*
 	 * If we are on a block device and no explicit aligned is reported, use
@@ -42,9 +51,8 @@ static int min_dio_alignment(const char *mntpnt, const char *devname)
 		if (dev_fd > 0 &&
 		    fstat(dev_fd, &st) == 0 &&
 		    S_ISBLK(st.st_mode) &&
-		    ioctl(dev_fd, BLKSSZGET, &logical_block_size) == 0) {
+		    ioctl(dev_fd, BLKSSZGET, &logical_block_size) == 0)
 			return logical_block_size;
-		}
 	}
 
 	/*
@@ -56,11 +64,25 @@ static int min_dio_alignment(const char *mntpnt, const char *devname)
 
 int main(int argc, char **argv)
 {
-	if (argc != 3) {
-		fprintf(stderr, "usage: %s mountpoint devicename\n", argv[0]);
-		exit(1);
+	bool read = false;
+	int c;
+
+	while ((c = getopt(argc, argv, "r")) != -1) {
+		switch(c) {
+		case 'r':
+			read = 1;
+			break;
+		default:
+			goto usage;
+		}
 	}
 
-	printf("%d\n", min_dio_alignment(argv[1], argv[2]));
+	if (argc - optind != 2)
+		goto usage;
+
+	printf("%d\n", min_dio_alignment(argv[optind], argv[optind + 1], read));
 	exit(0);
+usage:
+	fprintf(stderr, "usage: %s [-r] mountpoint devicename\n", argv[0]);
+	exit(1);
 }
Signature · 1 line
2.53.0
#7 lore raw

Re: [PATCH 2/5] min_dio_alignment: add a -r option to query read alignment

Quoted 46 lines · Zorro Lang
Quoted 34 lines · Christoph Hellwig

Add an option to query the STATX_DIO_READ_ALIGN if provided.

---
 src/min_dio_alignment.c | 44 ++++++++++++++++++++++++++++++-----------
 1 file changed, 33 insertions(+), 11 deletions(-)
src/min_dio_alignment.c +4 -2
index 866fba1546c4..143cee684ab4 100644
@@ -1,17 +1,19 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (c) 2024 Christoph Hellwig
+ * Copyright (c) 2024,2026 Christoph Hellwig
  */
 #include <fcntl.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <getopt.h>
 #include <sys/mount.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 #include "statx.h"
 
-static int min_dio_alignment(const char *mntpnt, const char *devname)
+static int min_dio_alignment(const char *mntpnt, const char *devname, bool read)
 {
 	struct statx stx = { };
 	struct stat st;

src/min_dio_alignment.c static int min_dio_alignment(const char *mntpnt, const char *devname) · line 32

Quoted 7 lines
src/min_dio_alignment.c +1 -3
@@ -27,9 +29,16 @@ static int min_dio_alignment(const char *mntpnt, const char *devname)
 	 */
 	fd = open(mntpnt, O_TMPFILE | O_RDWR | O_EXCL, 0600);
 	if (fd >= 0 &&
-	    xfstests_statx(fd, "", AT_EMPTY_PATH, STATX_DIOALIGN, &stx) == 0 &&
-	    (stx.stx_mask & STATX_DIOALIGN) && stx.stx_dio_offset_align != 0)
-		return stx.stx_dio_offset_align;
+	    xfstests_statx(fd, "", AT_EMPTY_PATH, STATX_DIOALIGN, &stx) == 0) {

Hmm... shouldn't STATX_DIO_READ_ALIGN be passed in the request mask as well?

Quoted 2 lines

xfstests_statx(fd, "", AT_EMPTY_PATH,
STATX_DIOALIGN|STATX_DIO_READ_ALIGN, &stx)

Yeah, strictly speaking we should. Currently this is only supported for XFS, and XFS automatically adds STATX_DIO_READ_ALIGN when STATX_DIOALIGN is requested, so it works. But more by chance than design.

#8 lore raw

Re: [PATCH 2/5] min_dio_alignment: add a -r option to query read alignment

Quoted 47 lines · Christoph Hellwig
Quoted 46 lines · Zorro Lang
Quoted 34 lines · Christoph Hellwig

Add an option to query the STATX_DIO_READ_ALIGN if provided.

---
 src/min_dio_alignment.c | 44 ++++++++++++++++++++++++++++++-----------
 1 file changed, 33 insertions(+), 11 deletions(-)
src/min_dio_alignment.c +4 -2
index 866fba1546c4..143cee684ab4 100644
@@ -1,17 +1,19 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (c) 2024 Christoph Hellwig
+ * Copyright (c) 2024,2026 Christoph Hellwig
  */
 #include <fcntl.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <getopt.h>
 #include <sys/mount.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 #include "statx.h"
 
-static int min_dio_alignment(const char *mntpnt, const char *devname)
+static int min_dio_alignment(const char *mntpnt, const char *devname, bool read)
 {
 	struct statx stx = { };
 	struct stat st;

src/min_dio_alignment.c static int min_dio_alignment(const char *mntpnt, const char *devname) · line 32

Quoted 7 lines
src/min_dio_alignment.c +1 -3
@@ -27,9 +29,16 @@ static int min_dio_alignment(const char *mntpnt, const char *devname)
 	 */
 	fd = open(mntpnt, O_TMPFILE | O_RDWR | O_EXCL, 0600);
 	if (fd >= 0 &&
-	    xfstests_statx(fd, "", AT_EMPTY_PATH, STATX_DIOALIGN, &stx) == 0 &&
-	    (stx.stx_mask & STATX_DIOALIGN) && stx.stx_dio_offset_align != 0)
-		return stx.stx_dio_offset_align;
+	    xfstests_statx(fd, "", AT_EMPTY_PATH, STATX_DIOALIGN, &stx) == 0) {

Hmm... shouldn't STATX_DIO_READ_ALIGN be passed in the request mask as well?

Quoted 7 lines
Quoted 2 lines

xfstests_statx(fd, "", AT_EMPTY_PATH,
STATX_DIOALIGN|STATX_DIO_READ_ALIGN, &stx)

Yeah, strictly speaking we should. Currently this is only supported for XFS, and XFS automatically adds STATX_DIO_READ_ALIGN when STATX_DIOALIGN is requested, so it works. But more by chance than design.

I couldn't find any mention in the statx doc that STATX_DIO_READ_ALIGN is added by default, explicitly specifying it seems more aligned with how the mask parameter is intended to work. Would you like me to fold this in when merging? or did you omit it due to other concerns?

This is the only open point left for the patchset, once we reach consensus, I'm good to merge it :)

Thanks,
Zorro

Quoted 2 lines
#9 lore raw

Re: [PATCH 2/5] min_dio_alignment: add a -r option to query read alignment

Quoted 56 lines · Zorro Lang
Quoted 47 lines · Christoph Hellwig
Quoted 46 lines · Zorro Lang
Quoted 34 lines · Christoph Hellwig

Add an option to query the STATX_DIO_READ_ALIGN if provided.

---
 src/min_dio_alignment.c | 44 ++++++++++++++++++++++++++++++-----------
 1 file changed, 33 insertions(+), 11 deletions(-)
src/min_dio_alignment.c +4 -2
index 866fba1546c4..143cee684ab4 100644
@@ -1,17 +1,19 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (c) 2024 Christoph Hellwig
+ * Copyright (c) 2024,2026 Christoph Hellwig
  */
 #include <fcntl.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <getopt.h>
 #include <sys/mount.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 #include "statx.h"
 
-static int min_dio_alignment(const char *mntpnt, const char *devname)
+static int min_dio_alignment(const char *mntpnt, const char *devname, bool read)
 {
 	struct statx stx = { };
 	struct stat st;

src/min_dio_alignment.c static int min_dio_alignment(const char *mntpnt, const char *devname) · line 32

Quoted 7 lines
src/min_dio_alignment.c +1 -3
@@ -27,9 +29,16 @@ static int min_dio_alignment(const char *mntpnt, const char *devname)
 	 */
 	fd = open(mntpnt, O_TMPFILE | O_RDWR | O_EXCL, 0600);
 	if (fd >= 0 &&
-	    xfstests_statx(fd, "", AT_EMPTY_PATH, STATX_DIOALIGN, &stx) == 0 &&
-	    (stx.stx_mask & STATX_DIOALIGN) && stx.stx_dio_offset_align != 0)
-		return stx.stx_dio_offset_align;
+	    xfstests_statx(fd, "", AT_EMPTY_PATH, STATX_DIOALIGN, &stx) == 0) {

Hmm... shouldn't STATX_DIO_READ_ALIGN be passed in the request mask as well?

Quoted 7 lines
Quoted 2 lines

xfstests_statx(fd, "", AT_EMPTY_PATH,
STATX_DIOALIGN|STATX_DIO_READ_ALIGN, &stx)

Yeah, strictly speaking we should. Currently this is only supported for XFS, and XFS automatically adds STATX_DIO_READ_ALIGN when STATX_DIOALIGN is requested, so it works. But more by chance than design.

Quoted 7 lines

I couldn't find any mention in the statx doc that STATX_DIO_READ_ALIGN is added by default, explicitly specifying it seems more aligned with how the mask parameter is intended to work. Would you like me to fold this in when merging? or did you omit it due to other concerns?

This is the only open point left for the patchset, once we reach consensus, I'm good to merge it :)

Hi Christoph, friendly ping, I'm still waiting on your confirmation before merging this patchset. Would you prefer I keep it as is, or should I add STATX_DIO_READ_ALIGN?

Thanks,
Zorro

Quoted 7 lines

Thanks,
Zorro

Quoted 2 lines
#10 lore raw

Re: [PATCH 2/5] min_dio_alignment: add a -r option to query read alignment

Quoted 11 lines · Zorro Lang
Quoted 7 lines

I couldn't find any mention in the statx doc that STATX_DIO_READ_ALIGN is added by default, explicitly specifying it seems more aligned with how the mask parameter is intended to work. Would you like me to fold this in when merging? or did you omit it due to other concerns?

This is the only open point left for the patchset, once we reach consensus, I'm good to merge it :)

Hi Christoph, friendly ping, I'm still waiting on your confirmation before merging this patchset. Would you prefer I keep it as is, or should I add STATX_DIO_READ_ALIGN?

Hi Zorro,

as I wrote in my last mail, passing STATX_DIO_READ_ALIGN is required by the interface, but on XFS, the only current implementation, it actually works without that. So yeah, please add it, or wait for me to resend the series as I've already added it locally.

#11 lore raw

Re: [PATCH 2/5] min_dio_alignment: add a -r option to query read alignment

In reply to Christoph Hellwig
Quoted 68 lines · Christoph Hellwig

Add an option to query the STATX_DIO_READ_ALIGN if provided.

---
 src/min_dio_alignment.c | 44 ++++++++++++++++++++++++++++++-----------
 1 file changed, 33 insertions(+), 11 deletions(-)
src/min_dio_alignment.c +15 -7
index 866fba1546c4..143cee684ab4 100644
@@ -1,17 +1,19 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (c) 2024 Christoph Hellwig
+ * Copyright (c) 2024,2026 Christoph Hellwig
  */
 #include <fcntl.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <getopt.h>
 #include <sys/mount.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 #include "statx.h"
 
-static int min_dio_alignment(const char *mntpnt, const char *devname)
+static int min_dio_alignment(const char *mntpnt, const char *devname, bool read)
 {
 	struct statx stx = { };
 	struct stat st;
@@ -27,9 +29,16 @@ static int min_dio_alignment(const char *mntpnt, const char *devname)
 	 */
 	fd = open(mntpnt, O_TMPFILE | O_RDWR | O_EXCL, 0600);
 	if (fd >= 0 &&
-	    xfstests_statx(fd, "", AT_EMPTY_PATH, STATX_DIOALIGN, &stx) == 0 &&
-	    (stx.stx_mask & STATX_DIOALIGN) && stx.stx_dio_offset_align != 0)
-		return stx.stx_dio_offset_align;
+	    xfstests_statx(fd, "", AT_EMPTY_PATH, STATX_DIOALIGN, &stx) == 0) {
+		if (read &&
+		    (stx.stx_mask & STATX_DIO_READ_ALIGN) &&
+		    stx.stx_dio_read_offset_align != 0)
+			return stx.stx_dio_read_offset_align;
+
+		if ((stx.stx_mask & STATX_DIOALIGN) &&
+		    stx.stx_dio_offset_align != 0)
+			return stx.stx_dio_offset_align;
+	}
 
 	/*
 	 * If we are on a block device and no explicit aligned is reported, use
@@ -42,9 +51,8 @@ static int min_dio_alignment(const char *mntpnt, const char *devname)
 		if (dev_fd > 0 &&
 		    fstat(dev_fd, &st) == 0 &&
 		    S_ISBLK(st.st_mode) &&
-		    ioctl(dev_fd, BLKSSZGET, &logical_block_size) == 0) {
+		    ioctl(dev_fd, BLKSSZGET, &logical_block_size) == 0)
 			return logical_block_size;
-		}
 	}
 
 	/*
@@ -56,11 +64,25 @@ static int min_dio_alignment(const char *mntpnt, const char *devname)
 
 int main(int argc, char **argv)
 {

src/min_dio_alignment.c static int min_dio_alignment(const char *mntpnt, const char *devname) · line 73

Quoted 10 lines
src/min_dio_alignment.c +7 -3
-	if (argc != 3) {
-		fprintf(stderr, "usage: %s mountpoint devicename\n", argv[0]);
-		exit(1);
+	bool read = false;
+	int c;
+
+	while ((c = getopt(argc, argv, "r")) != -1) {
+		switch(c) {
+		case 'r':
+			read = 1;

read = true;

Quoted 19 lines
src/min_dio_alignment.c +11 -1
+			break;
+		default:
+			goto usage;
+		}
 	}
 
-	printf("%d\n", min_dio_alignment(argv[1], argv[2]));
+	if (argc - optind != 2)
+		goto usage;
+
+	printf("%d\n", min_dio_alignment(argv[optind], argv[optind + 1], read));
 	exit(0);
+usage:
+	fprintf(stderr, "usage: %s [-r] mountpoint devicename\n", argv[0]);
+	exit(1);
 }
Signature · 1 line
2.53.0
#12 lore raw

PATCH 3/5 generic/091: enable sub-block reads

In reply to Christoph Hellwig

The description of generic/091 claims that it tries to exercise sub-block direct I/O, but the test currently limits reads to PAGE_SIZE alignment.

Use the new min_dio_alignment -r option to query the minimal read alignment and only limit the read alignment to that.

---
 tests/generic/091 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/generic/091 +1 -1
index 5cdf04890c0e..b2fba09d39ef 100755
@@ -15,8 +15,8 @@ _begin_fstest rw auto quick
 _require_test
 _require_odirect
 
-psize=`$here/src/feature -s`
 bsize=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
+psize=`$here/src/min_dio_alignment -r $TEST_DIR $TEST_DEV`
 
 # fsx usage:
 # 
Signature · 1 line
2.53.0
Reviewed-by on v1 3/5
#13 lore raw

Re: [PATCH 3/5] generic/091: enable sub-block reads

Quoted 7 lines · Christoph Hellwig

The description of generic/091 claims that it tries to exercise sub-block direct I/O, but the test currently limits reads to PAGE_SIZE alignment.

Use the new min_dio_alignment -r option to query the minimal read alignment and only limit the read alignment to that.

I've long wondered about why reads are the page size when xfs could easily do smaller...

--D

Quoted 22 lines
---
 tests/generic/091 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/generic/091 +1 -1
index 5cdf04890c0e..b2fba09d39ef 100755
@@ -15,8 +15,8 @@ _begin_fstest rw auto quick
 _require_test
 _require_odirect
 
-psize=`$here/src/feature -s`
 bsize=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
+psize=`$here/src/min_dio_alignment -r $TEST_DIR $TEST_DEV`
 
 # fsx usage:
 # 
Signature · 1 line
2.53.0
#14 lore raw

Re: [PATCH 3/5] generic/091: enable sub-block reads

Quoted 11 lines · Darrick J. Wong
Quoted 7 lines · Christoph Hellwig

The description of generic/091 claims that it tries to exercise sub-block direct I/O, but the test currently limits reads to PAGE_SIZE alignment.

Use the new min_dio_alignment -r option to query the minimal read alignment and only limit the read alignment to that.

I've long wondered about why reads are the page size when xfs could easily do smaller...

Maybe we should rename psize/PSIZE in _run_fsx_on_file helper (and cases call *run_fsx* function) as well? Keeping that name for DIO read alignment doesn't quite match the new semantics introduced by this series.

Thanks,
Zorro

Quoted 26 lines

--D

Quoted 22 lines
---
 tests/generic/091 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/generic/091 +1 -1
index 5cdf04890c0e..b2fba09d39ef 100755
@@ -15,8 +15,8 @@ _begin_fstest rw auto quick
 _require_test
 _require_odirect
 
-psize=`$here/src/feature -s`
 bsize=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
+psize=`$here/src/min_dio_alignment -r $TEST_DIR $TEST_DEV`
 
 # fsx usage:
 # 
Signature · 1 line
2.53.0
#15 lore raw

Re: [PATCH 3/5] generic/091: enable sub-block reads

Quoted 8 lines · Zorro Lang
Quoted 7 lines · Darrick J. Wong
Quoted 6 lines · Christoph Hellwig

The description of generic/091 claims that it tries to exercise sub-block direct I/O, but the test currently limits reads to PAGE_SIZE alignment.

Use the new min_dio_alignment -r option to query the minimal read alignment and only limit the read alignment to that.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

I've long wondered about why reads are the page size when xfs could easily do smaller...

Maybe we should rename psize/PSIZE in _run_fsx_on_file helper (and cases call *run_fsx* function) as well? Keeping that name for DIO read alignment doesn't quite match the new semantics introduced by this series.

Heh. I found these substituations weird, but also don't really undestand the purpose. Why don't we just pass these as explicit arguments anyway?

#16 lore raw

Re: [PATCH 3/5] generic/091: enable sub-block reads

Quoted 14 lines · Christoph Hellwig
Quoted 13 lines · Zorro Lang
Quoted 11 lines · Darrick J. Wong
Quoted 7 lines · Christoph Hellwig

The description of generic/091 claims that it tries to exercise sub-block direct I/O, but the test currently limits reads to PAGE_SIZE alignment.

Use the new min_dio_alignment -r option to query the minimal read alignment and only limit the read alignment to that.

I've long wondered about why reads are the page size when xfs could easily do smaller...

Quoted 6 lines
Quoted 3 lines

Maybe we should rename psize/PSIZE in _run_fsx_on_file helper (and cases call *run_fsx* function) as well? Keeping that name for DIO read alignment doesn't quite match the new semantics introduced by this series.

Heh. I found these substituations weird, but also don't really undestand the purpose. Why don't we just pass these as explicit arguments anyway?

This change traces back to commit 3597757462a7 ("fsx: Small improvements and fixes") from a decade ago. It moved run_fsx directly from a local test-case function into a common helper without any modifications.

This issue doesn't block your patch series. I'll send a follow-up series to clean up run_fsx once this is merged, so let's keep the focus on your changes for now :)

Quoted 2 lines
Reviewed-by on v1 3/5
#17 lore raw

Re: [PATCH 3/5] generic/091: enable sub-block reads

In reply to Christoph Hellwig
Quoted 16 lines · Christoph Hellwig

The description of generic/091 claims that it tries to exercise sub-block direct I/O, but the test currently limits reads to PAGE_SIZE alignment.

Use the new min_dio_alignment -r option to query the minimal read alignment and only limit the read alignment to that.

---
 tests/generic/091 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/generic/091 +0 -0
index 5cdf04890c0e..b2fba09d39ef 100755

tests/generic/091 _begin_fstest rw auto quick · line 19

Quoted 6 lines
tests/generic/091 +1 -1
@@ -15,8 +15,8 @@ _begin_fstest rw auto quick
 _require_test
 _require_odirect
 
-psize=`$here/src/feature -s`
 bsize=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
+psize=`$here/src/min_dio_alignment -r $TEST_DIR $TEST_DEV`

Good to me,

Quoted 6 lines
tests/generic/091 +0 -0
 # fsx usage:
 # 
Signature · 1 line
2.53.0
#18 lore raw

PATCH 4/5 generic/263: enable sub-block reads

In reply to Christoph Hellwig

The description of generic/263 claims that it tries to exercise sub-block direct I/O, but the test currently limits reads to PAGE_SIZE alignment.

Use the new min_dio_alignment -r option to query the minimal read alignment and only limit the read alignment to that.

---
 tests/generic/263 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/generic/263 +1 -1
index 91cfbe5253bd..c456d62ebd43 100755
@@ -15,7 +15,7 @@ _begin_fstest rw auto quick
 _require_test
 _require_odirect
 
-psize=`$here/src/feature -s`
+psize=`$here/src/min_dio_alignment -r $TEST_DIR $TEST_DEV`
 bsize=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
 
 run_fsx -N 10000  -o 8192   -l 500000 -r PSIZE -t BSIZE -w BSIZE -Z
Signature · 1 line
2.53.0
Reviewed-by on v1 4/5
#19 lore raw

Re: [PATCH 4/5] generic/263: enable sub-block reads

Quoted 7 lines · Christoph Hellwig

The description of generic/263 claims that it tries to exercise sub-block direct I/O, but the test currently limits reads to PAGE_SIZE alignment.

Use the new min_dio_alignment -r option to query the minimal read alignment and only limit the read alignment to that.

Looks ok,

--D

Quoted 21 lines
---
 tests/generic/263 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/generic/263 +1 -1
index 91cfbe5253bd..c456d62ebd43 100755
@@ -15,7 +15,7 @@ _begin_fstest rw auto quick
 _require_test
 _require_odirect
 
-psize=`$here/src/feature -s`
+psize=`$here/src/min_dio_alignment -r $TEST_DIR $TEST_DEV`
 bsize=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
 
 run_fsx -N 10000  -o 8192   -l 500000 -r PSIZE -t BSIZE -w BSIZE -Z
Signature · 1 line
2.53.0
Reviewed-by on v1 4/5
#20 lore raw

Re: [PATCH 4/5] generic/263: enable sub-block reads

In reply to Christoph Hellwig
Quoted 16 lines · Christoph Hellwig

The description of generic/263 claims that it tries to exercise sub-block direct I/O, but the test currently limits reads to PAGE_SIZE alignment.

Use the new min_dio_alignment -r option to query the minimal read alignment and only limit the read alignment to that.

---
 tests/generic/263 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/generic/263 +0 -0
index 91cfbe5253bd..c456d62ebd43 100755

tests/generic/263 _begin_fstest rw auto quick · line 18

Quoted 5 lines
tests/generic/263 +1 -1
@@ -15,7 +15,7 @@ _begin_fstest rw auto quick
 _require_test
 _require_odirect
 
-psize=`$here/src/feature -s`
+psize=`$here/src/min_dio_alignment -r $TEST_DIR $TEST_DEV`

Makes sense to me (except the "psize" name, I think we should update that later).

Quoted 6 lines
tests/generic/263 +0 -0
 bsize=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
 
 run_fsx -N 10000  -o 8192   -l 500000 -r PSIZE -t BSIZE -w BSIZE -Z
Signature · 1 line
2.53.0
#21 lore raw

PATCH 5/5 generic/760: enable sub-block reads

In reply to Christoph Hellwig

generic/760 currently limits reads to PAGE_SIZE alignments while allowing smaller writes. Use the new min_dio_alignment -r option to query the minimal read alignment and only limit the read alignment to that.

---
 tests/generic/760 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/generic/760 +1 -1
index f270636e56a3..facd83e4af0c 100755
@@ -16,7 +16,7 @@ _require_odirect
 _require_thp
 _require_hugepage_fsx
 
-psize=`$here/src/feature -s`
+psize=`$here/src/min_dio_alignment -r $TEST_DIR $TEST_DEV`
 bsize=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
 
 _run_hugepage_fsx -N 10000            -l 500000 -r PSIZE -t BSIZE -w BSIZE -Z -R -W
Signature · 1 line
2.53.0
Reviewed-by on v1 5/5
#22 lore raw

Re: [PATCH 5/5] generic/760: enable sub-block reads

Quoted 5 lines · Christoph Hellwig

generic/760 currently limits reads to PAGE_SIZE alignments while allowing smaller writes. Use the new min_dio_alignment -r option to query the minimal read alignment and only limit the read alignment to that.

Looks ok,

--D

Quoted 21 lines
---
 tests/generic/760 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/generic/760 +1 -1
index f270636e56a3..facd83e4af0c 100755
@@ -16,7 +16,7 @@ _require_odirect
 _require_thp
 _require_hugepage_fsx
 
-psize=`$here/src/feature -s`
+psize=`$here/src/min_dio_alignment -r $TEST_DIR $TEST_DEV`
 bsize=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
 
 _run_hugepage_fsx -N 10000            -l 500000 -r PSIZE -t BSIZE -w BSIZE -Z -R -W
Signature · 1 line
2.53.0
Reviewed-by on v1 5/5
#23 lore raw

Re: [PATCH 5/5] generic/760: enable sub-block reads

In reply to Christoph Hellwig
Quoted 14 lines · Christoph Hellwig

generic/760 currently limits reads to PAGE_SIZE alignments while allowing smaller writes. Use the new min_dio_alignment -r option to query the minimal read alignment and only limit the read alignment to that.

---
 tests/generic/760 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/generic/760 +0 -0
index f270636e56a3..facd83e4af0c 100755

tests/generic/760 _require_odirect · line 19

Quoted 5 lines
tests/generic/760 +1 -1
@@ -16,7 +16,7 @@ _require_odirect
 _require_thp
 _require_hugepage_fsx
 
-psize=`$here/src/feature -s`
+psize=`$here/src/min_dio_alignment -r $TEST_DIR $TEST_DEV`
Quoted 6 lines
tests/generic/760 +0 -0
 bsize=`$here/src/min_dio_alignment $TEST_DIR $TEST_DEV`
 
 _run_hugepage_fsx -N 10000            -l 500000 -r PSIZE -t BSIZE -w BSIZE -Z -R -W
Signature · 1 line
2.53.0