linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iomap: allow iomap using the per-cpu bio cache
@ 2025-08-22  8:26 Fengnan Chang
  2025-08-22 15:05 ` Darrick J. Wong
  0 siblings, 1 reply; 16+ messages in thread
From: Fengnan Chang @ 2025-08-22  8:26 UTC (permalink / raw)
  To: brauner, djwong; +Cc: linux-xfs, linux-fsdevel, Fengnan Chang

When use io_uring with direct IO, we could use per-cpu bio cache
from bio_alloc_bioset, So pass IOCB_ALLOC_CACHE flag to alloc
bio helper.

Signed-off-by: Fengnan Chang <changfengnan@bytedance.com>
---
 fs/iomap/direct-io.c  | 6 ++++++
 include/linux/iomap.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index 6f25d4cfea9f..85cc092a4004 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -341,6 +341,9 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)
 	    !bdev_iter_is_aligned(iomap->bdev, dio->submit.iter))
 		return -EINVAL;
 
+	if (iter->flags & IOMAP_ALLOC_CACHE)
+		bio_opf |= REQ_ALLOC_CACHE;
+
 	if (dio->flags & IOMAP_DIO_WRITE) {
 		bio_opf |= REQ_OP_WRITE;
 
@@ -636,6 +639,9 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
 	if (iocb->ki_flags & IOCB_NOWAIT)
 		iomi.flags |= IOMAP_NOWAIT;
 
+	if (iocb->ki_flags & IOCB_ALLOC_CACHE)
+		iomi.flags |= IOMAP_ALLOC_CACHE;
+
 	if (iov_iter_rw(iter) == READ) {
 		/* reads can always complete inline */
 		dio->flags |= IOMAP_DIO_INLINE_COMP;
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index 73dceabc21c8..6cba9b1753ca 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -196,6 +196,7 @@ struct iomap_write_ops {
 #endif /* CONFIG_FS_DAX */
 #define IOMAP_ATOMIC		(1 << 9) /* torn-write protection */
 #define IOMAP_DONTCACHE		(1 << 10)
+#define IOMAP_ALLOC_CACHE	(1 << 11)
 
 struct iomap_ops {
 	/*
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2025-09-03  9:52 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-22  8:26 [PATCH] iomap: allow iomap using the per-cpu bio cache Fengnan Chang
2025-08-22 15:05 ` Darrick J. Wong
2025-08-22 15:42   ` Matthew Wilcox
2025-08-22 16:07     ` Ritesh Harjani
2025-08-22 16:51       ` Matthew Wilcox
2025-08-23  4:15         ` Ritesh Harjani
2025-08-25  8:51           ` Fengnan Chang
2025-08-25  9:21             ` Christoph Hellwig
2025-08-25  9:41               ` Fengnan Chang
2025-08-25 10:47                 ` Christoph Hellwig
2025-08-26  9:46                   ` Fengnan Chang
2025-08-26 13:15                     ` Christoph Hellwig
2025-08-26 16:53                 ` Ritesh Harjani
2025-08-29  4:26                   ` [External] " Fengnan Chang
2025-09-03  8:28                   ` Fengnan Chang
2025-09-03  9:53           ` Pavel Begunkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).