Skip to content

Commit 076171a

Browse files
Matthew Wilcox (Oracle)torvalds
authored andcommitted
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: 32c0a6b ("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>
1 parent f649dc0 commit 076171a

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

fs/iomap/buffered-io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,15 +394,15 @@ void iomap_readahead(struct readahead_control *rac, const struct iomap_ops *ops)
394394
{
395395
struct inode *inode = rac->mapping->host;
396396
loff_t pos = readahead_pos(rac);
397-
loff_t length = readahead_length(rac);
397+
size_t length = readahead_length(rac);
398398
struct iomap_readpage_ctx ctx = {
399399
.rac = rac,
400400
};
401401

402402
trace_iomap_readahead(inode, readahead_count(rac));
403403

404404
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,
406406
&ctx, iomap_readahead_actor);
407407
if (ret <= 0) {
408408
WARN_ON_ONCE(ret == 0);

include/linux/pagemap.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -997,9 +997,9 @@ static inline loff_t readahead_pos(struct readahead_control *rac)
997997
* readahead_length - The number of bytes in this readahead request.
998998
* @rac: The readahead request.
999999
*/
1000-
static inline loff_t readahead_length(struct readahead_control *rac)
1000+
static inline size_t readahead_length(struct readahead_control *rac)
10011001
{
1002-
return (loff_t)rac->_nr_pages * PAGE_SIZE;
1002+
return rac->_nr_pages * PAGE_SIZE;
10031003
}
10041004

10051005
/**
@@ -1024,7 +1024,7 @@ static inline unsigned int readahead_count(struct readahead_control *rac)
10241024
* readahead_batch_length - The number of bytes in the current batch.
10251025
* @rac: The readahead request.
10261026
*/
1027-
static inline loff_t readahead_batch_length(struct readahead_control *rac)
1027+
static inline size_t readahead_batch_length(struct readahead_control *rac)
10281028
{
10291029
return rac->_batch_count * PAGE_SIZE;
10301030
}

0 commit comments

Comments
 (0)