Skip to contentSkip to conversation

iomap: fix inline data on buffered read

PATCH Applied Gao Xiang 4 participants 5 messages Mar 19, 2025 – Mar 20, 2025

Subsystems (2)
lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH v2 1/1 iomap: fix inline data on buffered read

Previously, iomap_readpage_iter() returning 0 would break out of the loops of iomap_readahead_iter(), which is what iomap_read_inline_data() relies on.

However, commit d9dc477ff6a2 ("iomap: advance the iter directly on buffered read") changes this behavior without calling iomap_iter_advance(), which causes EROFS to get stuck in iomap_readpage_iter().

It seems iomap_iter_advance() cannot be called in iomap_read_inline_data() because of the iomap_write_begin() path, so handle this in iomap_readpage_iter() instead.

Reported-and-tested-by Bo Liu <[email protected]>
Fixes d9dc477ff6a2 ("iomap: advance the iter directly on buffered read")
Cc Brian Foster <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc "Darrick J. Wong" <[email protected]>
Cc Christian Brauner <[email protected]>

---
v1: https://lore.kernel.org/r/[email protected]
change since v1:
- iomap_iter_advance() directly instead of goto done
as suggested by Christoph.

 fs/iomap/buffered-io.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
fs/iomap/buffered-io.c +7 -2
index d52cfdc299c4..814b7f679486 100644
@@ -372,9 +372,14 @@ static int iomap_readpage_iter(struct iomap_iter *iter,
 	struct iomap_folio_state *ifs;
 	size_t poff, plen;
 	sector_t sector;
+	int ret;
 
-	if (iomap->type == IOMAP_INLINE)
-		return iomap_read_inline_data(iter, folio);
+	if (iomap->type == IOMAP_INLINE) {
+		ret = iomap_read_inline_data(iter, folio);
+		if (ret)
+			return ret;
+		return iomap_iter_advance(iter, &length);
+	}
 
 	/* zero post-eof blocks as the page may be mapped */
 	ifs = ifs_alloc(iter->inode, folio, iter->flags);
Signature · 1 line
2.43.5
Reviewed-by on v2 1/1
#1 lore raw
Quoted 13 lines · Gao Xiang

Previously, iomap_readpage_iter() returning 0 would break out of the loops of iomap_readahead_iter(), which is what iomap_read_inline_data() relies on.

However, commit d9dc477ff6a2 ("iomap: advance the iter directly on buffered read") changes this behavior without calling iomap_iter_advance(), which causes EROFS to get stuck in iomap_readpage_iter().

It seems iomap_iter_advance() cannot be called in iomap_read_inline_data() because of the iomap_write_begin() path, so handle this in iomap_readpage_iter() instead.

Quoted 8 lines
Reported-and-tested-by Bo Liu <[email protected]>
Fixes d9dc477ff6a2 ("iomap: advance the iter directly on buffered read")
Cc Brian Foster <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc "Darrick J. Wong" <[email protected]>
Cc Christian Brauner <[email protected]>

---

Ugh. I'd hoped ext4 testing would have uncovered such an issue, but now that I think of it, IIRC ext4 isn't fully on iomap yet so wouldn't have provided this coverage. So apologies for the testing oversight on my part and thanks for the fix.

For future reference, do you guys have any documentation or whatever to run quick/smoke fstests against EROFS? (I assume this could be reproduced via fstests..?).

Quoted 16 lines

v1: https://lore.kernel.org/r/[email protected]
change since v1:
- iomap_iter_advance() directly instead of goto done
as suggested by Christoph.

 fs/iomap/buffered-io.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
fs/iomap/buffered-io.c +0 -0
index d52cfdc299c4..814b7f679486 100644
@@ -372,9 +372,14 @@ static int iomap_readpage_iter(struct iomap_iter *iter,
 	struct iomap_folio_state *ifs;
 	size_t poff, plen;
 	sector_t sector;

fs/iomap/buffered-io.c static int iomap_readpage_iter(struct iomap_iter *iter, · line 382

Quoted 10 lines
fs/iomap/buffered-io.c +7 -2
+	int ret;
 
-	if (iomap->type == IOMAP_INLINE)
-		return iomap_read_inline_data(iter, folio);
+	if (iomap->type == IOMAP_INLINE) {
+		ret = iomap_read_inline_data(iter, folio);
+		if (ret)
+			return ret;
+		return iomap_iter_advance(iter, &length);
+	}

Technically you could use iomap_iter_advance_full() here, but since length is already defined for other purposes it doesn't really make much difference. LGTM:

Quoted 6 lines
fs/iomap/buffered-io.c +0 -0
 	/* zero post-eof blocks as the page may be mapped */
 	ifs = ifs_alloc(iter->inode, folio, iter->flags);
Signature · 1 line
2.43.5
author
#2 lore raw

Hi Brian,

Quoted 23 lines · Brian Foster
Quoted 13 lines · Gao Xiang

Previously, iomap_readpage_iter() returning 0 would break out of the loops of iomap_readahead_iter(), which is what iomap_read_inline_data() relies on.

However, commit d9dc477ff6a2 ("iomap: advance the iter directly on buffered read") changes this behavior without calling iomap_iter_advance(), which causes EROFS to get stuck in iomap_readpage_iter().

It seems iomap_iter_advance() cannot be called in iomap_read_inline_data() because of the iomap_write_begin() path, so handle this in iomap_readpage_iter() instead.

Quoted 8 lines
Reported-and-tested-by Bo Liu <[email protected]>
Fixes d9dc477ff6a2 ("iomap: advance the iter directly on buffered read")
Cc Brian Foster <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc "Darrick J. Wong" <[email protected]>
Cc Christian Brauner <[email protected]>

---

Quoted 8 lines

Ugh. I'd hoped ext4 testing would have uncovered such an issue, but now that I think of it, IIRC ext4 isn't fully on iomap yet so wouldn't have provided this coverage. So apologies for the testing oversight on my part and thanks for the fix.

For future reference, do you guys have any documentation or whatever to run quick/smoke fstests against EROFS? (I assume this could be reproduced via fstests..?).

I don't think any existing testcase of fstests is useful for readonly filesystems like EROFS since EROFS only has read interface so all test cases including regression tests will be integrated into erofs-utils directly.

EROFS can be easily tested with its own testcases in erofs-utils:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git
cd erofs-utils
git checkout origin/experimental-tests # for now, I will integrate to main later.
./autogen.sh
./configure
make check

Without this patch, test cases will just hang.

Quoted 1 line

...

Quoted 2 lines

Thanks.

Thanks,
Gao Xiang

Quoted 7 lines
Quoted 7 lines

/* zero post-eof blocks as the page may be mapped */ ifs = ifs_alloc(iter->inode, folio, iter->flags);

Signature · 1 line
2.43.5
maintainer Applied
#3 lore raw
In reply to Gao Xiang
Quoted 10 lines · Gao Xiang

Previously, iomap_readpage_iter() returning 0 would break out of the loops of iomap_readahead_iter(), which is what iomap_read_inline_data() relies on.

However, commit d9dc477ff6a2 ("iomap: advance the iter directly on buffered read") changes this behavior without calling iomap_iter_advance(), which causes EROFS to get stuck in iomap_readpage_iter().

[...]

Applied to the vfs-6.15.iomap branch of the vfs/vfs.git tree. Patches in the vfs-6.15.iomap branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-6.15.iomap

[1/1] iomap: fix inline data on buffered read

      https://git.kernel.org/vfs/vfs/c/b26816b4e320