From: sashiko-bot@kernel.org
To: "Christoph Hellwig" <hch@lst.de>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu
Subject: Re: [PATCH 2/2] iomap: don't use struct iomap_iter for simple dio reads
Date: Fri, 04 Dec 2026 09:35:04 +0000 [thread overview]
Message-ID: <sashiko-outbox-249520@kernel.org> (raw)
In-Reply-To: <20261204091101.2533591-3-hch@lst.de>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] ext4: making ext4_iomap_begin() static breaks
CONFIG_EXT4_KUNIT_TESTS builds
- [Medium] xfs: xfs_read_simple_begin() returns -ENOTBLK instead of
-EAGAIN on NOWAIT
- [Low] iomap: iomap_dio_read_simple() comment omits uninitialized iomap
contract
--
commit 5329ccff0d2b6f54203c2a7e79854425463b11e1
Author: Christoph Hellwig <hch@lst.de>
iomap: don't use struct iomap_iter for simple dio reads
This commit replaces struct iomap_iter in iomap_dio_read_simple() with a
plain struct iomap and a dedicated iomap_simple_begin_fn callback, adding
simple-read begin handlers in ext4 and XFS.
[ ... ]
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 07a62d8569d31..f987991b48c23 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -4012,8 +4012,7 @@ static int ext4_iomap_alloc(struct inode *inode, struct ext4_map_blocks *map,
> return ret;
> }
>
> -
> -int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
> +static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
> unsigned flags, struct iomap *iomap, struct iomap *srcmap)
> {
> int ret;
[Severity: Medium]
Does making ext4_iomap_begin() static break CONFIG_EXT4_KUNIT_TESTS builds?
fs/ext4/inode.c still has EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_iomap_begin),
which expands to an extern declaration and conflicts with the static
definition.
inode_test_iomap_and_atomic_writes() in fs/ext4/inode-test.c also calls
ext4_iomap_begin() directly, so removing the prototype from fs/ext4/ext4.h
and external linkage breaks compiling and linking ext4-test.o.
[ ... ]
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index ad1ce4f99ad88..ba46156128dfa 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -189,6 +189,53 @@ static const struct iomap_dio_ops xfs_dio_read_bounce_ops = {
> .bio_set = &iomap_ioend_bioset,
> };
>
> +static int
> +xfs_read_simple_begin(
> + struct inode *inode,
> + loff_t offset,
> + loff_t length,
> + unsigned flags,
> + struct iomap *iomap)
> +{
> + struct xfs_inode *ip = XFS_I(inode);
> + struct xfs_mount *mp = ip->i_mount;
> + xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset);
> + struct xfs_bmbt_irec imap;
> + struct xfs_iext_cursor icur;
> +
> + ASSERT(!(flags & ~(IOMAP_DIRECT | IOMAP_NOWAIT)));
> +
> + if (xfs_is_shutdown(mp))
> + return -EIO;
> + if (xfs_need_iread_extents(&ip->i_df))
> + return -ENOTBLK;
[Severity: Medium]
Should this return -EAGAIN instead of -ENOTBLK when IOMAP_NOWAIT is set?
When extents are not yet loaded on a nonblocking direct read, returning
-ENOTBLK falls back to iomap_dio_rw(), where __iomap_dio_rw() allocates
struct iomap_dio with GFP_KERNEL before xfs_ilock_for_iomap() fails with
-EAGAIN.
Returning (flags & IOMAP_NOWAIT) ? -EAGAIN : -ENOTBLK preserves the previous
behavior and avoids a potentially sleeping allocation on IOCB_NOWAIT.
[ ... ]
> diff --git a/include/linux/iomap.h b/include/linux/iomap.h
> index 78a1b7603a4f2..6db4f005fdfc4 100644
> --- a/include/linux/iomap.h
> +++ b/include/linux/iomap.h
> @@ -740,20 +740,20 @@ void iomap_dio_bio_end_io(struct bio *bio);
> * The caller can only provide an iomap begin handler, and the iterator
> * is never advanced.
> */
> +typedef int (*iomap_simple_begin_fn)(struct inode *inode, loff_t pos,
> + loff_t length, unsigned flags, struct iomap *iomap);
> ssize_t __iomap_dio_read_simple(struct kiocb *iocb, struct iov_iter *iter,
> - struct iomap_iter *iomi);
> + unsigned flags, struct iomap *iomap);
> static __always_inline ssize_t iomap_dio_read_simple(struct kiocb *iocb,
> - struct iov_iter *iter, iomap_iter_begin_fn begin)
> + struct iov_iter *iter, iomap_simple_begin_fn begin)
> {
> - struct iomap_iter iomi = {
> - .inode = file_inode(iocb->ki_filp),
> - .pos = iocb->ki_pos,
> - .len = iov_iter_count(iter),
> - .flags = IOMAP_DIRECT,
> - };
> + struct inode *inode = file_inode(iocb->ki_filp);
> + size_t count = iov_iter_count(iter);
> + unsigned flags = IOMAP_DIRECT;
> + struct iomap iomap;
[Severity: Low]
Could the comment above iomap_simple_begin_fn document that iomap is
uninitialized on entry?
The comment still mentions the removed iterator ("and the iterator is never
advanced") and does not state that iomap_dio_read_simple() passes an
uninitialized stack struct iomap, unlike iomap_iter.
A future caller assuming zero-initialization (e.g., omitting iomap->flags = 0)
would expose uninitialized stack memory to IOMAP_F_INTEGRITY and
IOMAP_F_ANON_WRITE checks in __iomap_dio_read_simple() and iomap_sector().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204091101.2533591-2-hch@lst.de?part=2
prev parent reply other threads:[~2026-12-04 9:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 9:10 optimize iomap simple dio reads v2 Christoph Hellwig
2026-12-04 9:10 ` [PATCH 1/2] iomap: don't call sb_init_dio_done_wq from the simple dio read path Christoph Hellwig
2026-12-04 9:35 ` sashiko-bot
2026-12-04 10:37 ` Carlos Maiolino
2026-12-04 9:10 ` [PATCH 2/2] iomap: don't use struct iomap_iter for simple dio reads Christoph Hellwig
2026-12-04 9:35 ` sashiko-bot [this message]
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-249520@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=hch@lst.de \
--cc=linux-ext4@vger.kernel.org \
--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.