[PATCH v3 02/18] swap: Call aops->readahead if appropriate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux