Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm/filemap: fix readahead return types

A readahead request will not allocate more memory than can be represented
by a size_t, even on systems that have HIGHMEM available. Change the
length functions from returning an loff_t to a size_t.

Link: https://lkml.kernel.org/r/20210510201201.1558972-1-willy@infradead.org
Fixes: 32c0a6bcaa1f57 ("btrfs: add and use readahead_batch_length")
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Matthew Wilcox (Oracle) and committed by
Linus Torvalds
076171a6 f649dc0e

+5 -5
+2 -2
fs/iomap/buffered-io.c
··· 394 394 { 395 395 struct inode *inode = rac->mapping->host; 396 396 loff_t pos = readahead_pos(rac); 397 - loff_t length = readahead_length(rac); 397 + size_t length = readahead_length(rac); 398 398 struct iomap_readpage_ctx ctx = { 399 399 .rac = rac, 400 400 }; ··· 402 402 trace_iomap_readahead(inode, readahead_count(rac)); 403 403 404 404 while (length > 0) { 405 - loff_t ret = iomap_apply(inode, pos, length, 0, ops, 405 + ssize_t ret = iomap_apply(inode, pos, length, 0, ops, 406 406 &ctx, iomap_readahead_actor); 407 407 if (ret <= 0) { 408 408 WARN_ON_ONCE(ret == 0);
+3 -3
include/linux/pagemap.h
··· 997 997 * readahead_length - The number of bytes in this readahead request. 998 998 * @rac: The readahead request. 999 999 */ 1000 - static inline loff_t readahead_length(struct readahead_control *rac) 1000 + static inline size_t readahead_length(struct readahead_control *rac) 1001 1001 { 1002 - return (loff_t)rac->_nr_pages * PAGE_SIZE; 1002 + return rac->_nr_pages * PAGE_SIZE; 1003 1003 } 1004 1004 1005 1005 /** ··· 1024 1024 * readahead_batch_length - The number of bytes in the current batch. 1025 1025 * @rac: The readahead request. 1026 1026 */ 1027 - static inline loff_t readahead_batch_length(struct readahead_control *rac) 1027 + static inline size_t readahead_batch_length(struct readahead_control *rac) 1028 1028 { 1029 1029 return rac->_batch_count * PAGE_SIZE; 1030 1030 }