]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
mm/filemap: use page_cache_sync_ra() to kick off read-ahead
authorJens Axboe <axboe@kernel.dk>
Fri, 20 Dec 2024 15:47:40 +0000 (08:47 -0700)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 26 Jan 2025 04:22:42 +0000 (20:22 -0800)
Rather than use the page_cache_sync_readahead() helper, define our own
ractl and use page_cache_sync_ra() directly.  In preparation for needing
to modify ractl inside filemap_get_pages().

No functional changes in this patch.

Link: https://lkml.kernel.org/r/20241220154831.1086649-3-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Brian Foster <bfoster@redhat.com>
Cc: Chris Mason <clm@meta.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/filemap.c

index 904d8fa2bfc0c8e24daa1ba55a2ce375b2c8987c..a1fda00aa6bc21f82a39ded0b07109d88246179b 100644 (file)
@@ -2499,7 +2499,6 @@ static int filemap_get_pages(struct kiocb *iocb, size_t count,
 {
        struct file *filp = iocb->ki_filp;
        struct address_space *mapping = filp->f_mapping;
-       struct file_ra_state *ra = &filp->f_ra;
        pgoff_t index = iocb->ki_pos >> PAGE_SHIFT;
        pgoff_t last_index;
        struct folio *folio;
@@ -2514,12 +2513,13 @@ retry:
 
        filemap_get_read_batch(mapping, index, last_index - 1, fbatch);
        if (!folio_batch_count(fbatch)) {
+               DEFINE_READAHEAD(ractl, filp, &filp->f_ra, mapping, index);
+
                if (iocb->ki_flags & IOCB_NOIO)
                        return -EAGAIN;
                if (iocb->ki_flags & IOCB_NOWAIT)
                        flags = memalloc_noio_save();
-               page_cache_sync_readahead(mapping, ra, filp, index,
-                               last_index - index);
+               page_cache_sync_ra(&ractl, last_index - index);
                if (iocb->ki_flags & IOCB_NOWAIT)
                        memalloc_noio_restore(flags);
                filemap_get_read_batch(mapping, index, last_index - 1, fbatch);