]> git.baikalelectronics.ru Git - kernel.git/commit
iomap: Fix inline extent handling in iomap_readpage
authorAndreas Gruenbacher <agruenba@redhat.com>
Thu, 18 Nov 2021 01:59:01 +0000 (17:59 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Dec 2021 08:04:44 +0000 (09:04 +0100)
commit2485fe81d3d507fb2d4a96ff26e8cf2b2e3b4496
tree3b6f1edc5d27d7a8ebbda1bda122188f13a4dd2e
parent50847fb13bb790b4d8d32af55514bc97b3016ea0
iomap: Fix inline extent handling in iomap_readpage

commit e62c41a9bb68f1f6395179f80eee4e4c73e0f109 upstream.

Before commit e63ee1efa78c ("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: e63ee1efa78c ("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>
fs/iomap/buffered-io.c