WSL2-Linux-Kernel/fs/iomap
Andreas Gruenbacher 55d2254fd9 iomap: Fix inline extent handling in iomap_readpage
commit d8af404ffc upstream.

Before commit 740499c784 ("iomap: fix the iomap_readpage_actor return
value for inline data"), when hitting an IOMAP_INLINE extent,
iomap_readpage_actor would report having read the entire page.  Since
then, it only reports having read the inline data (iomap->length).

This will force iomap_readpage into another iteration, and the
filesystem will report an unaligned hole after the IOMAP_INLINE extent.
But iomap_readpage_actor (now iomap_readpage_iter) isn't prepared to
deal with unaligned extents, it will get things wrong on filesystems
with a block size smaller than the page size, and we'll eventually run
into the following warning in iomap_iter_advance:

  WARN_ON_ONCE(iter->processed > iomap_length(iter));

Fix that by changing iomap_readpage_iter to return 0 when hitting an
inline extent; this will cause iomap_iter to stop immediately.

To fix readahead as well, change iomap_readahead_iter to pass on
iomap_readpage_iter return values less than or equal to zero.

Fixes: 740499c784 ("iomap: fix the iomap_readpage_actor return value for inline data")
Cc: stable@vger.kernel.org # v5.15+
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-12-01 09:04:44 +01:00
..
Makefile iomap: move loop control code to iter.c 2021-08-16 21:26:33 -07:00
buffered-io.c iomap: Fix inline extent handling in iomap_readpage 2021-12-01 09:04:44 +01:00
direct-io.c iomap: switch __iomap_dio_rw to use iomap_iter 2021-08-16 21:26:33 -07:00
fiemap.c iomap: switch iomap_bmap to use iomap_iter 2021-08-16 21:26:33 -07:00
iter.c iomap: move loop control code to iter.c 2021-08-16 21:26:33 -07:00
seek.c iomap: switch iomap_seek_data to use iomap_iter 2021-08-16 21:26:33 -07:00
swapfile.c mm/swap: consider max pages in iomap_swapfile_add_extent 2021-08-18 12:47:52 -07:00
trace.c iomap: lift common tracing code from xfs to iomap 2019-10-21 08:51:59 -07:00
trace.h iomap: standardize tracepoint formatting and storage 2021-08-26 09:18:53 -07:00