From: Christoph Hellwig <hch@lst.de>
To: Anuj Gupta <anuj1072538@gmail.com>
Cc: asml.silence@gmail.com, hch@lst.de, djwong@kernel.org,
cem@kernel.org, brauner@kernel.org, axboe@kernel.dk,
linux-block@vger.kernel.org, linux-xfs@vger.kernel.org,
linux-fsdevel@vger.kernel.org, joshi.k@samsung.com,
anuj20.g@samsung.com, nj.shetty@samsung.com
Subject: Re: [RFC 3/4] iomap: add dma-buf direct I/O guards and registration helper
Date: Fri, 16 Oct 2026 11:26:48 +0200 [thread overview]
Message-ID: <20261016092648.GC23141@lst.de> (raw)
In-Reply-To: <20261016091919.971295-4-anuj1072538@gmail.com>
On Fri, Oct 16, 2026 at 02:49:13PM +0530, Anuj Gupta wrote:
> From: Nitesh Shetty <nj.shetty@samsung.com>
>
> Direct I/O copies data from the CPU in three places, zero-filling
> holes, inline data, and bounce pages. A dma-buf iterator has no
> CPU-visible pages, so refuse it.
>
> Reads that encounter a hole or unwritten extent therefore return
> -EOPNOTSUPP for the entire operation, even if I/O for an earlier mapped
> extent was already submitted.
>
> Also add iomap_file_init_dma_buf_io_ctx(), so filesystems can register
> without open-coding the DAX check. The filesystem picks the device,
> iomap does the rest.
>
> Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com>
> Signed-off-by: Anuj Gupta <anuj20.g@samsung.com>
> ---
> fs/iomap/direct-io.c | 31 ++++++++++++++++++++++++++++++-
> include/linux/iomap.h | 3 +++
> 2 files changed, 33 insertions(+), 1 deletion(-)
>
> diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
> index 8b4039d16ce8..fc40f4367ee7 100644
> --- a/fs/iomap/direct-io.c
> +++ b/fs/iomap/direct-io.c
> @@ -427,6 +427,10 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)
> unsigned int alignment;
> ssize_t ret = 0;
>
> + if (iov_iter_is_dmabuf_map(dio->submit.iter) &&
> + (iomap->flags & IOMAP_F_INTEGRITY))
> + return -EOPNOTSUPP;
> +
> /*
> * File systems that write out of place and always allocate new blocks
> * need each bio to be block aligned as that's the unit of allocation.
> @@ -595,7 +599,13 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)
>
> static int iomap_dio_hole_iter(struct iomap_iter *iter, struct iomap_dio *dio)
> {
> - loff_t length = iov_iter_zero(iomap_length(iter), dio->submit.iter);
> + loff_t length;
> +
> + /* a device mapping cannot be zeroed from the CPU */
> + if (iov_iter_is_dmabuf_map(dio->submit.iter))
> + return -EOPNOTSUPP;
> +
> + length = iov_iter_zero(iomap_length(iter), dio->submit.iter);
>
> dio->size += length;
> if (!length)
> @@ -612,6 +622,10 @@ static int iomap_dio_inline_iter(struct iomap_iter *iomi, struct iomap_dio *dio)
> loff_t pos = iomi->pos;
> u64 copied;
>
> + /* inline data is copied from the CPU, which a device mapping bypasses */
Overly lone line here.
> + /* bouncing copies the data from the CPU, which a device mapping bypasses */
.. and here. Note that could still copy to/from the device memory in
either case, but that's probably rather pointless at least for actual
device dmabufs. It might be useful for udmabuf or other kernel
allocations, though.
next prev parent reply other threads:[~2026-10-16 9:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 9:19 [RFC 0/4] fs: support dma-buf backed direct I/O Anuj Gupta
2026-10-16 9:19 ` [RFC 1/4] block: factor out bdev_init_dma_buf_io_ctx() Anuj Gupta
2026-10-16 9:23 ` Christoph Hellwig
2026-10-16 9:19 ` [RFC 2/4] block: refuse a dma-buf bio for a disk the buffer was not registered on Anuj Gupta
2026-10-16 9:24 ` Christoph Hellwig
2026-10-16 9:19 ` [RFC 3/4] iomap: add dma-buf direct I/O guards and registration helper Anuj Gupta
2026-10-16 9:26 ` Christoph Hellwig [this message]
2026-10-16 9:19 ` [RFC 4/4] xfs: support dma-buf registered buffers for direct I/O Anuj Gupta
2026-10-16 9:28 ` Christoph Hellwig
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 \
--in-reply-to=20261016092648.GC23141@lst.de \
--to=hch@lst.de \
--cc=anuj1072538@gmail.com \
--cc=anuj20.g@samsung.com \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=cem@kernel.org \
--cc=djwong@kernel.org \
--cc=joshi.k@samsung.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=nj.shetty@samsung.com \
/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