Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs: add FMODE_DIO_PARALLEL_WRITE flag

Some filesystems support multiple threads writing to the same file with
O_DIRECT without requiring exclusive access to it. io_uring can use this
hint to avoid serializing dio writes to this inode, instead allowing them
to run in parallel.

XFS and ext4 both fall into this category, so set the flag for both of
them.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

+7 -2
+2 -1
fs/ext4/file.c
··· 899 899 return ret; 900 900 } 901 901 902 - filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC; 902 + filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC | 903 + FMODE_DIO_PARALLEL_WRITE; 903 904 return dquot_file_open(inode, filp); 904 905 } 905 906
+2 -1
fs/xfs/xfs_file.c
··· 1171 1171 { 1172 1172 if (xfs_is_shutdown(XFS_M(inode->i_sb))) 1173 1173 return -EIO; 1174 - file->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC | FMODE_BUF_WASYNC; 1174 + file->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC | FMODE_BUF_WASYNC | 1175 + FMODE_DIO_PARALLEL_WRITE; 1175 1176 return generic_file_open(inode, file); 1176 1177 } 1177 1178
+3
include/linux/fs.h
··· 168 168 169 169 #define FMODE_NOREUSE ((__force fmode_t)0x800000) 170 170 171 + /* File supports non-exclusive O_DIRECT writes from multiple threads */ 172 + #define FMODE_DIO_PARALLEL_WRITE ((__force fmode_t)0x1000000) 173 + 171 174 /* File was opened by fanotify and shouldn't generate fanotify events */ 172 175 #define FMODE_NONOTIFY ((__force fmode_t)0x4000000) 173 176