If the blocksize of the mapping is larger than the page size we need to align down readahead to avoid reading past the end of the device. Signed-off-by: Hannes Reinecke <hare@xxxxxxx> --- mm/readahead.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/readahead.c b/mm/readahead.c index 031935b78af7..91a7dbf4fa04 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -285,6 +285,7 @@ static void do_page_cache_ra(struct readahead_control *ractl, struct inode *inode = ractl->mapping->host; unsigned long index = readahead_index(ractl); loff_t isize = i_size_read(inode); + unsigned int iblksize = i_blocksize(inode); pgoff_t end_index; /* The last page we want to read */ if (isize == 0) @@ -293,6 +294,9 @@ static void do_page_cache_ra(struct readahead_control *ractl, end_index = (isize - 1) >> PAGE_SHIFT; if (index > end_index) return; + if (iblksize > PAGE_SIZE) + end_index = ALIGN_DOWN(end_index, iblksize); + /* Don't read past the page containing the last byte of the file */ if (nr_to_read > end_index - index) nr_to_read = end_index - index + 1; -- 2.35.3