[PATCH 7/7] mm/readahead: align readahead down to mapping blocksize

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux