Some filesystems have a synchronous readpage and an asynchronous readahead. Call the readahead operation if we're trying to do swap readahead. Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> --- mm/page_io.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/mm/page_io.c b/mm/page_io.c index e485a6e8a6cd..faf5ccb42946 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -367,6 +367,24 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc, return ret; } +static int mapping_readpage(struct file *file, struct address_space *mapping, + struct page *page, bool synchronous) +{ + struct readahead_control ractl = { + .file = file, + .mapping = mapping, + ._index = page->index, + ._nr_pages = 1, + }; + + if (!synchronous && mapping->a_ops->readahead) { + mapping->a_ops->readahead(&ractl); + return 0; + } + + return mapping->a_ops->readpage(file, page); +} + int swap_readpage(struct page *page, bool synchronous) { struct bio *bio; @@ -395,9 +413,9 @@ int swap_readpage(struct page *page, bool synchronous) if (data_race(sis->flags & SWP_FS)) { struct file *swap_file = sis->swap_file; - struct address_space *mapping = swap_file->f_mapping; - ret = mapping->a_ops->readpage(swap_file, page); + ret = mapping_readpage(swap_file, swap_file->f_mapping, + page, synchronous); if (!ret) count_vm_event(PSWPIN); goto out; -- 2.28.0