From: Jens Axboe <[email protected]>
To: [email protected], [email protected]
Cc: [email protected], [email protected], [email protected],
Jens Axboe <[email protected]>
Subject: [PATCH 2/6] iomap: add IOMAP_DIO_INLINE_COMP
Date: Wed, 19 Jul 2023 13:54:13 -0600 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
Rather than gate whether or not we need to punt a dio completion to a
workqueue, add an explicit flag for it. For now we treat them the same,
reads always set the flags and async writes do not.
No functional changes in this patch.
Signed-off-by: Jens Axboe <[email protected]>
---
fs/iomap/direct-io.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index 1c32f734c767..6b302bf8790b 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -20,6 +20,7 @@
* Private flags for iomap_dio, must not overlap with the public ones in
* iomap.h:
*/
+#define IOMAP_DIO_INLINE_COMP (1 << 27)
#define IOMAP_DIO_WRITE_FUA (1 << 28)
#define IOMAP_DIO_NEED_SYNC (1 << 29)
#define IOMAP_DIO_WRITE (1 << 30)
@@ -171,20 +172,25 @@ void iomap_dio_bio_end_io(struct bio *bio)
}
/*
- * If this dio is an async write, queue completion work for async
- * handling. Reads can always complete inline.
+ * Flagged with IOMAP_DIO_INLINE_COMP, we can complete it inline
*/
- if (dio->flags & IOMAP_DIO_WRITE) {
- struct inode *inode = file_inode(iocb->ki_filp);
-
- WRITE_ONCE(iocb->private, NULL);
- INIT_WORK(&dio->aio.work, iomap_dio_complete_work);
- queue_work(inode->i_sb->s_dio_done_wq, &dio->aio.work);
- } else {
+ if (dio->flags & IOMAP_DIO_INLINE_COMP) {
WRITE_ONCE(iocb->private, NULL);
iomap_dio_complete_work(&dio->aio.work);
+ goto release_bio;
}
+ /*
+ * Async DIO completion that requires filesystem level completion work
+ * gets punted to a work queue to complete as the operation may require
+ * more IO to be issued to finalise filesystem metadata changes or
+ * guarantee data integrity.
+ */
+ WRITE_ONCE(iocb->private, NULL);
+ INIT_WORK(&dio->aio.work, iomap_dio_complete_work);
+ queue_work(file_inode(iocb->ki_filp)->i_sb->s_dio_done_wq,
+ &dio->aio.work);
+
release_bio:
if (should_dirty) {
bio_check_pages_dirty(bio);
@@ -524,6 +530,9 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
iomi.flags |= IOMAP_NOWAIT;
if (iov_iter_rw(iter) == READ) {
+ /* reads can always complete inline */
+ dio->flags |= IOMAP_DIO_INLINE_COMP;
+
if (iomi.pos >= dio->i_size)
goto out_free_dio;
--
2.40.1
next prev parent reply other threads:[~2023-07-19 19:54 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-19 19:54 [PATCHSET v3 0/6] Improve async iomap DIO performance Jens Axboe
2023-07-19 19:54 ` [PATCH 1/6] iomap: cleanup up iomap_dio_bio_end_io() Jens Axboe
2023-07-20 4:50 ` Christoph Hellwig
2023-07-20 16:13 ` Jens Axboe
2023-07-19 19:54 ` Jens Axboe [this message]
2023-07-20 4:51 ` [PATCH 2/6] iomap: add IOMAP_DIO_INLINE_COMP Christoph Hellwig
2023-07-20 16:19 ` Jens Axboe
2023-07-19 19:54 ` [PATCH 3/6] iomap: treat a write through cache the same as FUA Jens Axboe
2023-07-20 4:54 ` Christoph Hellwig
2023-07-20 16:23 ` Jens Axboe
2023-07-19 19:54 ` [PATCH 4/6] fs: add IOCB flags related to passing back dio completions Jens Axboe
2023-07-20 5:01 ` Christoph Hellwig
2023-07-20 16:25 ` Jens Axboe
2023-07-19 19:54 ` [PATCH 5/6] io_uring/rw: add write support for IOCB_DIO_DEFER Jens Axboe
2023-07-19 19:54 ` [PATCH 6/6] iomap: support IOCB_DIO_DEFER Jens Axboe
2023-07-20 4:59 ` Christoph Hellwig
2023-07-20 16:27 ` Jens Axboe
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] \
[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