Skip to content

Commit 7ed6cbe

Browse files
Christoph Hellwigbrauner
authored andcommitted
fs: add STATX_DIO_READ_ALIGN
Add a separate dio read align field, as many out of place write file systems can easily do reads aligned to the device sector size, but require bigger alignment for writes. This is usually papered over by falling back to buffered I/O for smaller writes and doing read-modify-write cycles, but performance for this sucks, so applications benefit from knowing the actual write alignment. Signed-off-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: John Garry <[email protected]> Reviewed-by: Jan Kara <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 8fc7e23 commit 7ed6cbe

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

fs/stat.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,7 @@ cp_statx(const struct kstat *stat, struct statx __user *buffer)
725725
tmp.stx_mnt_id = stat->mnt_id;
726726
tmp.stx_dio_mem_align = stat->dio_mem_align;
727727
tmp.stx_dio_offset_align = stat->dio_offset_align;
728+
tmp.stx_dio_read_offset_align = stat->dio_read_offset_align;
728729
tmp.stx_subvol = stat->subvol;
729730
tmp.stx_atomic_write_unit_min = stat->atomic_write_unit_min;
730731
tmp.stx_atomic_write_unit_max = stat->atomic_write_unit_max;

include/linux/stat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ struct kstat {
5252
u64 mnt_id;
5353
u32 dio_mem_align;
5454
u32 dio_offset_align;
55+
u32 dio_read_offset_align;
5556
u64 change_cookie;
5657
u64 subvol;
5758
u32 atomic_write_unit_min;

include/uapi/linux/stat.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ struct statx {
179179
/* Max atomic write segment count */
180180
__u32 stx_atomic_write_segments_max;
181181

182-
__u32 __spare1[1];
182+
/* File offset alignment for direct I/O reads */
183+
__u32 stx_dio_read_offset_align;
183184

184185
/* 0xb8 */
185186
__u64 __spare3[9]; /* Spare space for future expansion */
@@ -213,6 +214,7 @@ struct statx {
213214
#define STATX_MNT_ID_UNIQUE 0x00004000U /* Want/got extended stx_mount_id */
214215
#define STATX_SUBVOL 0x00008000U /* Want/got stx_subvol */
215216
#define STATX_WRITE_ATOMIC 0x00010000U /* Want/got atomic_write_* fields */
217+
#define STATX_DIO_READ_ALIGN 0x00020000U /* Want/got dio read alignment info */
216218

217219
#define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */
218220

0 commit comments

Comments
 (0)