mm/filemap: Fix readahead return types
Subsystems (5)
Matthew Wilcox (Oracle)
maintainerPATCH 1/1 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.
--- fs/iomap/buffered-io.c | 4 ++-- include/linux/pagemap.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
fs/iomap/buffered-io.c +2 -2
@@ -394,7 +394,7 @@ void iomap_readahead(struct readahead_control *rac, const struct iomap_ops *ops) {struct inode *inode = rac->mapping->host;loff_t pos =readahead_pos (rac); -loff_t length =readahead_length (rac); +size_t length =readahead_length (rac);struct iomap_readpage_ctx ctx = { .rac = rac, };
@@ -402,7 +402,7 @@ void iomap_readahead(struct readahead_control *rac, const struct iomap_ops *ops)trace_iomap_readahead (inode,readahead_count (rac));while (length >0 ) { -loff_t ret =iomap_apply (inode, pos, length,0 , ops, +ssize_t ret =iomap_apply (inode, pos, length,0 , ops, &ctx, iomap_readahead_actor);if (ret <=0 ) {WARN_ON_ONCE (ret ==0 );
include/linux/pagemap.h +3 -3
@@ -997,9 +997,9 @@ static inline loff_t readahead_pos(struct readahead_control *rac)* readahead_length - The number of bytes in this readahead request. * @rac: The readahead request. */ -static inline loff_t readahead_length (struct readahead_control *rac) +static inline size_t readahead_length (struct readahead_control *rac) { -return (loff_t )rac->_nr_pages *PAGE_SIZE ; +return rac->_nr_pages *PAGE_SIZE ; }/**
@@ -1024,7 +1024,7 @@ static inline unsigned int readahead_count(struct readahead_control *rac)* readahead_batch_length - The number of bytes in the current batch. * @rac: The readahead request. */ -static inline loff_t readahead_batch_length (struct readahead_control *rac) +static inline size_t readahead_batch_length (struct readahead_control *rac) {return rac->_batch_count *PAGE_SIZE ; }
Signature · 1 line
2.30.2
Quoted 5 lines · Matthew Wilcox (Oracle)
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 anloff_tto asize_t.Signed-off-by Matthew Wilcox (Oracle) <[email protected]>
Looks reasonable to me; is this a 5.13 bugfix or just something that doesn't look right (i.e. save it for 5.14)?
--D
Quoted 55 lines
--- fs/iomap/buffered-io.c | 4 ++-- include/linux/pagemap.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)fs/iomap/buffered-io.c +2
-2@@ -394,7 +394,7 @@ void iomap_readahead(struct readahead_control *rac, const struct iomap_ops *ops) {struct inode *inode = rac->mapping->host;loff_t pos =readahead_pos (rac); -loff_t length =readahead_length (rac); +size_t length =readahead_length (rac);struct iomap_readpage_ctx ctx = { .rac = rac, };@@ -402,7 +402,7 @@ void iomap_readahead(struct readahead_control *rac, const struct iomap_ops *ops)trace_iomap_readahead (inode,readahead_count (rac));while (length >0 ) { -loff_t ret =iomap_apply (inode, pos, length,0 , ops, +ssize_t ret =iomap_apply (inode, pos, length,0 , ops, &ctx, iomap_readahead_actor);if (ret <=0 ) {WARN_ON_ONCE (ret ==0 );include/linux/pagemap.h +3
-3@@ -997,9 +997,9 @@ static inline loff_t readahead_pos(struct readahead_control *rac)* readahead_length - The number of bytes in this readahead request. * @rac: The readahead request. */ -static inline loff_t readahead_length (struct readahead_control *rac) +static inline size_t readahead_length (struct readahead_control *rac) { -return (loff_t )rac->_nr_pages *PAGE_SIZE ; +return rac->_nr_pages *PAGE_SIZE ; }/** @@ -1024,7 +1024,7 @@ static inline unsigned int readahead_count(struct readahead_control *rac)* readahead_batch_length - The number of bytes in the current batch. * @rac: The readahead request. */ -static inline loff_t readahead_batch_length (struct readahead_control *rac) +static inline size_t readahead_batch_length (struct readahead_control *rac) {return rac->_batch_count *PAGE_SIZE ; }Signature · 1 line
2.30.2
Matthew Wilcox
maintainerQuoted 11 lines · Darrick J. Wong
Quoted 5 lines · Matthew Wilcox (Oracle)
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 anloff_tto asize_t.Signed-off-by Matthew Wilcox (Oracle) <[email protected]>Looks reasonable to me; is this a 5.13 bugfix or just something that doesn't look right (i.e. save it for 5.14)?
Reviewed-by Darrick J. Wong <[email protected]>
Thanks! Linus was unhappy about it, and I promised to fix it. I leave it up to Andrew whether he wants to see this in 5.13 or 5.14.
(I went a little beyond what he was directly unhappy with and reviewed all the readahead.*length users for unnecessary loff_t usage)