All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nitesh Shetty" <nj.shetty@samsung.com>
Cc: dri-devel@lists.freedesktop.org, nvdimm@lists.linux.dev,
	linux-ext4@vger.kernel.org, tytso@mit.edu, media-ci@linuxtv.org
Subject: Re: [RFC PATCH v3 09/13] iomap: don't ask for a buffered fallback for dma-buf iterators
Date: Tue, 01 Dec 2026 17:16:50 +0000	[thread overview]
Message-ID: <sashiko-outbox-243800@kernel.org> (raw)
In-Reply-To: <20261201155938.3028275-10-nj.shetty@samsung.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] iomap: blocking -EAGAIN on -EBUSY in __iomap_dio_rw() breaks
  XFS and IOPOLL
--

commit e6c38297f83152550306506a0aa0d60de11399b1
Author: Mengmeng Zhao <zhaomengmeng@kylinos.cn>

iomap: don't ask for a buffered fallback for dma-buf iterators

This commit updates __iomap_dio_rw() so that dma-buf iterators do not
return -ENOTBLK to request a buffered I/O fallback, instead mapping page
invalidation -EBUSY failures to -EAGAIN and zero-progress -ENOTBLK
callbacks to -EOPNOTSUPP.

> diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
> index 1cd907204501f..be7f3ef57d8a4 100644
> --- a/fs/iomap/direct-io.c
> +++ b/fs/iomap/direct-io.c
[ ... ]
> @@ -832,6 +834,13 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
>  					 * the caller tries again.
>  					 */
>  					ret = -EAGAIN;
> +				} else if (iov_iter_is_dmabuf_map(iter)) {
> +					/*
> +					 * a busy folio is transient, let the
> +					 * caller retry the direct write
> +					 */
> +					if (ret == -EBUSY)
> +						ret = -EAGAIN;
>  				} else {
>  					/* fall back to buffered write */
>  					ret = -ENOTBLK;

[Severity: High]
Can mapping -EBUSY to -EAGAIN when IOCB_NOWAIT is clear trigger an
ASSERT failure and an infinite loop in xfs_file_dio_write_unaligned()?

When IOCB_NOWAIT is not set, kiocb_invalidate_pages() blocks on
writeback and returns -EBUSY from invalidate_inode_pages2_range() if a
folio in the target range remains pinned or dirty.  For a sector-aligned
but block-unaligned blocking direct write in XFS, the exclusive retry
pass clears IOMAP_DIO_OVERWRITE_ONLY and assumes -EAGAIN can only come
from the initial overwrite-only attempt:

fs/xfs/xfs_file.c:xfs_file_dio_write_unaligned() {
    ...
retry_exclusive:
		iolock = XFS_IOLOCK_EXCL;
		flags = IOMAP_DIO_FORCE_WAIT;
    ...
	ret = iomap_dio_rw(iocb, from, &xfs_direct_write_iomap_ops,
			   &xfs_dio_write_ops, flags, NULL, 0);

	/*
	 * Retry unaligned I/O with exclusive blocking semantics if the
	 *DIO layer rejected it for mapping or locking reasons. If we are
	 * doing nonblocking user I/O, propagate the error.
	 */
	if (ret == -EAGAIN && !(iocb->ki_flags & IOCB_NOWAIT)) {
		ASSERT(flags & IOMAP_DIO_OVERWRITE_ONLY);
		xfs_iunlock(ip, iolock);
		goto retry_exclusive;
	}
    ...
}

Returning -EAGAIN on the retry_exclusive pass trips this ASSERT and
loops back to retry_exclusive indefinitely while the folio stays busy.
On an io_uring ring configured with IORING_SETUP_IOPOLL, returning
-EAGAIN to a blocking io-wq worker similarly causes io_write() and
io_wq_submit_work() to spin retrying io_issue_sqe().  Leaving ret as
-EBUSY returns the invalidation failure directly to the caller.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201155938.3028275-1-nj.shetty@samsung.com?part=9

  reply	other threads:[~2026-12-01 17:16 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20261201160117epcas5p2ec8720e93d2041c09b70d41eed40efd1@epcas5p2.samsung.com>
2026-12-01 15:59 ` [RFC PATCH v3 00/13] fs: dma-buf direct I/O for XFS and ext4 Nitesh Shetty
2026-12-01 15:59   ` [RFC PATCH v3 01/13] block: factor out bdev_init_dma_buf_io_ctx() Nitesh Shetty
2026-12-01 15:59   ` [RFC PATCH v3 02/13] dma-buf-io: add tags to share a context between files Nitesh Shetty
2026-12-01 15:59   ` [RFC PATCH v3 03/13] block: set dma-buf-io tag for block files Nitesh Shetty
2026-12-01 15:59   ` [RFC PATCH v3 04/13] io_uring: add data to dma-buf conversion helpers Nitesh Shetty
2026-12-01 15:59   ` [RFC PATCH v3 05/13] io_uring/dma-buf: switch to tag file filtering Nitesh Shetty
2026-12-01 17:10     ` sashiko-bot
2026-12-01 15:59   ` [RFC PATCH v3 06/13] dma-buf-io: require O_DIRECT and a tag in dma_buf_io_ctx_create() Nitesh Shetty
2026-12-01 15:59   ` [RFC PATCH v3 07/13] io_uring/dma-buf: get rid of struct io_buf_dma Nitesh Shetty
2026-12-01 15:59   ` [RFC PATCH v3 08/13] iomap: add dma-buf direct I/O guards Nitesh Shetty
2026-12-01 15:59   ` [RFC PATCH v3 09/13] iomap: don't ask for a buffered fallback for dma-buf iterators Nitesh Shetty
2026-12-01 17:16     ` sashiko-bot [this message]
2026-12-01 15:59   ` [RFC PATCH v3 10/13] blk-crypto: refuse dma-buf bios in the fallback path Nitesh Shetty
2026-12-01 15:59   ` [RFC PATCH v3 11/13] dax: refuse dma-buf iterators in dax_iomap_rw() Nitesh Shetty
2026-12-01 15:59   ` [RFC PATCH v3 12/13] xfs: support dma-buf registered buffers for direct I/O Nitesh Shetty
2026-12-01 17:20     ` sashiko-bot
2026-12-01 15:59   ` [RFC PATCH v3 13/13] ext4: " Nitesh Shetty
2026-12-01 17:20   ` [RFC PATCH v3 00/13] fs: dma-buf direct I/O for XFS and ext4 sashiko-bot

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=sashiko-outbox-243800@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=media-ci@linuxtv.org \
    --cc=nj.shetty@samsung.com \
    --cc=nvdimm@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tytso@mit.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.