]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mm/filemap: fix readahead return types
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Sat, 15 May 2021 00:27:30 +0000 (17:27 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 15 May 2021 02:41:32 +0000 (19:41 -0700)
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: 2fc26381224f60 ("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>
fs/iomap/buffered-io.c
include/linux/pagemap.h

index f2cd2034a87bb21fb338f67e608e15f2f66952e1..9023717c5188b11ee78c811e2f7f2f7bc351fee3 100644 (file)
@@ -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);
index a4bd41128bf318eb4ae536c56ccda93e6e29b436..e89df447fae32cac5a49cbf89b2abc985012111c 100644 (file)
@@ -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;
 }