From: Jens Axboe axboe@kernel.dk
mainline inclusion from mainline-v6.6-rc1 commit 7b3c14d1a96bf63c078c3bbfe5573fb964e80b95 category: perf bugzilla: https://gitee.com/openeuler/kernel/issues/I90ZB5 CVE: NA
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
--------------------------------
Rather than gate whether or not we need to punt a dio completion to a workqueue on whether the IO is a write or not, 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.
Reviewed-by: Darrick J. Wong djwong@kernel.org Reviewed-by: Christoph Hellwig hch@lst.de Reviewed-by: Dave Chinner dchinner@redhat.com Signed-off-by: Jens Axboe axboe@kernel.dk Conflicts: fs/iomap/direct-io.c [ 3a0be38cc84d("iomap: treat a write through cache the same as FUA") is not applied. a6d3d49587d1("iomap: switch __iomap_dio_rw to use iomap_iter") is not applied. ] Signed-off-by: Zhihao Cheng chengzhihao1@huawei.com --- fs/iomap/direct-io.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index 7b0458d4d794..bb9a08235fa4 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -18,6 +18,7 @@ * Private flags for iomap_dio, must not overlap with the public ones in * iomap.h: */ +#define IOMAP_DIO_INLINE_COMP (1U << 27) #define IOMAP_DIO_WRITE_FUA (1U << 28) #define IOMAP_DIO_NEED_SYNC (1U << 29) #define IOMAP_DIO_WRITE (1U << 30) @@ -173,8 +174,10 @@ static void iomap_dio_bio_end_io(struct bio *bio) goto release_bio; }
- /* Read completion can always complete inline. */ - if (!(dio->flags & IOMAP_DIO_WRITE)) { + /* + * Flagged with IOMAP_DIO_INLINE_COMP, we can complete it inline + */ + if (dio->flags & IOMAP_DIO_INLINE_COMP) { iomap_dio_complete_work(&dio->aio.work); goto release_bio; } @@ -471,6 +474,9 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, dio->submit.last_queue = NULL;
if (iov_iter_rw(iter) == READ) { + /* reads can always complete inline */ + dio->flags |= IOMAP_DIO_INLINE_COMP; + if (pos >= dio->i_size) goto out_free_dio;