aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2023-06-14 13:17:50 +0200
committerHannes Reinecke <hare@suse.de>2023-06-14 13:26:35 +0200
commit3ccadc4c18a037ddba4e9d89b9dd434e1ad42189 (patch)
treeabd8665c84085433d5083f4167180854eb8d4530
parent2fe2ee019ba2f42d6b919c92ac125d1b7670a744 (diff)
downloadscsi-devel-brd.v2.tar.gz
mm/readahead: align readahead down to mapping blocksizebrd.v2
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@suse.de>
-rw-r--r--mm/readahead.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/mm/readahead.c b/mm/readahead.c
index 031935b78af778..91a7dbf4fa04d3 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;