On Fri, Aug 22, 2025 at 04:26:06PM +0800, Fengnan Chang wrote: > 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@xxxxxxxxxxxxx> > --- > 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; Is there a reason /not/ to use the per-cpu bio cache unconditionally? --D > + > 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 > >