From: Jens Axboe <[email protected]>
To: [email protected], [email protected],
[email protected], [email protected]
Cc: Jens Axboe <[email protected]>
Subject: [PATCH 1/2] fs: add FMODE_DIO_PARALLEL_WRITE flag
Date: Tue, 7 Mar 2023 10:20:14 -0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
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.
Signed-off-by: Jens Axboe <[email protected]>
---
fs/ext4/file.c | 3 ++-
fs/xfs/xfs_file.c | 3 ++-
include/linux/fs.h | 3 +++
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 0b8b4499e5ca..d101b3b0c7da 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -899,7 +899,8 @@ static int ext4_file_open(struct inode *inode, struct file *filp)
return ret;
}
- filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC;
+ filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC |
+ FMODE_DIO_PARALLEL_WRITE;
return dquot_file_open(inode, filp);
}
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 705250f9f90a..863289aaa441 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -1171,7 +1171,8 @@ xfs_file_open(
{
if (xfs_is_shutdown(XFS_M(inode->i_sb)))
return -EIO;
- file->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC | FMODE_BUF_WASYNC;
+ file->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC | FMODE_BUF_WASYNC |
+ FMODE_DIO_PARALLEL_WRITE;
return generic_file_open(inode, file);
}
diff --git a/include/linux/fs.h b/include/linux/fs.h
index c85916e9f7db..475d88640d3d 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -168,6 +168,9 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
#define FMODE_NOREUSE ((__force fmode_t)0x800000)
+/* File supports non-exclusive O_DIRECT writes from multiple threads */
+#define FMODE_DIO_PARALLEL_WRITE ((__force fmode_t)0x1000000)
+
/* File was opened by fanotify and shouldn't generate fanotify events */
#define FMODE_NONOTIFY ((__force fmode_t)0x4000000)
--
2.39.2
next prev parent reply other threads:[~2023-03-07 17:25 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-07 17:20 [PATCHSET for-next 0/2] Flag file systems as supporting parallel dio writes Jens Axboe
2023-03-07 17:20 ` Jens Axboe [this message]
2023-04-12 13:40 ` [PATCH 1/2] fs: add FMODE_DIO_PARALLEL_WRITE flag Bernd Schubert
2023-04-12 13:43 ` Bernd Schubert
2023-04-13 7:40 ` Miklos Szeredi
2023-04-13 9:25 ` Bernd Schubert
2023-04-14 5:11 ` Christoph Hellwig
2023-04-14 15:36 ` Darrick J. Wong
2023-04-15 13:15 ` Jens Axboe
2023-04-18 12:42 ` Miklos Szeredi
2023-04-18 12:55 ` Bernd Schubert
2023-04-18 22:13 ` Dave Chinner
2023-04-19 1:28 ` Jens Axboe
2023-04-16 5:54 ` Christoph Hellwig
2023-04-19 1:29 ` Jens Axboe
2023-03-07 17:20 ` [PATCH 2/2] io_uring: avoid hashing O_DIRECT writes if the filesystem doesn't need it Jens Axboe
2023-03-15 17:40 ` [PATCHSET for-next 0/2] Flag file systems as supporting parallel dio writes Jens Axboe
2023-03-16 4:29 ` Darrick J. Wong
2023-03-17 2:53 ` Jens Axboe
2023-04-03 12:24 ` Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox