iomap: fix the iomap_readpage_actor return value for inline data
authorChristoph Hellwig <hch@lst.de>
Wed, 11 Aug 2021 01:33:07 +0000 (18:33 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 17 Aug 2021 04:26:33 +0000 (21:26 -0700)
The actor should never return a larger value than the length that was
passed in.  The current code handles this gracefully, but the opcoming
iter model will be more picky.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
fs/iomap/buffered-io.c

index 0273aed..8418dff 100644 (file)
@@ -205,7 +205,7 @@ struct iomap_readpage_ctx {
        struct readahead_control *rac;
 };
 
-static int iomap_read_inline_data(struct inode *inode, struct page *page,
+static loff_t iomap_read_inline_data(struct inode *inode, struct page *page,
                const struct iomap *iomap)
 {
        size_t size = i_size_read(inode) - iomap->offset;
@@ -253,7 +253,7 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
        sector_t sector;
 
        if (iomap->type == IOMAP_INLINE)
-               return iomap_read_inline_data(inode, page, iomap);
+               return min(iomap_read_inline_data(inode, page, iomap), length);
 
        /* zero post-eof blocks as the page may be mapped */
        iop = iomap_page_create(inode, page);