Blob Blame History Raw
From 4047e5d6ee42f45b206864a99360fae0f013c902 Mon Sep 17 00:00:00 2001
From: Peter Georg <peter.georg@physik.uni-regensburg.de>
Date: Wed, 22 Sep 2021 22:32:09 +0200
Subject: [PATCH 9004/9005] Compat: Replace readahead by readpages

---
 src/inode.c | 29 +++++++++--------------------
 1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/src/inode.c b/src/inode.c
index 69eef0f..20b9aea 100644
--- a/src/inode.c
+++ b/src/inode.c
@@ -704,34 +704,23 @@ static int ntfs_readpage(struct file *file, struct page *page)
 	return mpage_readpage(page, ntfs_get_block);
 }
 
-static void ntfs_readahead(struct readahead_control *rac)
+static int ntfs_readpages(struct file *file, struct address_space *mapping,
+                      struct list_head *pages, unsigned int nr_pages)
 {
-	struct address_space *mapping = rac->mapping;
 	struct inode *inode = mapping->host;
 	struct ntfs_inode *ni = ntfs_i(inode);
-	u64 valid;
-	loff_t pos;
 
 	if (is_resident(ni)) {
-		/* No readahead for resident. */
-		return;
+		/* No readpages for resident. */
+		return 0;
 	}
 
 	if (is_compressed(ni)) {
-		/* No readahead for compressed. */
-		return;
-	}
-
-	valid = ni->i_valid;
-	pos = readahead_pos(rac);
-
-	if (valid < i_size_read(inode) && pos <= valid &&
-	    valid < pos + readahead_length(rac)) {
-		/* Range cross 'valid'. Read it page by page. */
-		return;
+		/* No readpages for compressed. */
+		return 0;
 	}
 
-	mpage_readahead(rac, ntfs_get_block);
+	return mpage_readpages(mapping, pages, nr_pages, ntfs_get_block);
 }
 
 static int ntfs_get_block_direct_IO_R(struct inode *inode, sector_t iblock,
@@ -1943,7 +1932,7 @@ const struct inode_operations ntfs_link_inode_operations = {
 
 const struct address_space_operations ntfs_aops = {
 	.readpage	= ntfs_readpage,
-	.readahead	= ntfs_readahead,
+	.readpages	= ntfs_readpages,
 	.writepage	= ntfs_writepage,
 	.writepages	= ntfs_writepages,
 	.write_begin	= ntfs_write_begin,
@@ -1955,6 +1944,6 @@ const struct address_space_operations ntfs_aops = {
 
 const struct address_space_operations ntfs_aops_cmpr = {
 	.readpage	= ntfs_readpage,
-	.readahead	= ntfs_readahead,
+	.readpages	= ntfs_readpages,
 };
 // clang-format on
-- 
2.31.1