diff mbox series

[06/19] mm/filemap: Change calling convention for gfbr_ functions

Message ID 20201029193405.29125-7-willy@infradead.org
State New
Headers show
Series Transparent Hugepages for non-tmpfs filesystems | expand

Commit Message

Matthew Wilcox (Oracle) Oct. 29, 2020, 7:33 p.m. UTC
gfbr_update_page() would prefer to have mapping passed to it than filp,
as would gfbr_create_page().  That makes gfbr_read_page() retrieve
the file pointer from the iocb.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/filemap.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

Comments

Kent Overstreet Oct. 30, 2020, 12:05 a.m. UTC | #1
On Thu, Oct 29, 2020 at 07:33:52PM +0000, Matthew Wilcox (Oracle) wrote:
> gfbr_update_page() would prefer to have mapping passed to it than filp,
> as would gfbr_create_page().  That makes gfbr_read_page() retrieve
> the file pointer from the iocb.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Reviewed-by: Kent Overstreet <kent.overstreet@gmail.com>
diff mbox series

Patch

diff --git a/mm/filemap.c b/mm/filemap.c
index 7bc791b47a68..1bfd87d85bfd 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2176,9 +2176,10 @@  static int lock_page_for_iocb(struct kiocb *iocb, struct page *page)
 		return lock_page_killable(page);
 }
 
-static struct page *gfbr_read_page(struct kiocb *iocb, struct file *filp,
+static struct page *gfbr_read_page(struct kiocb *iocb,
 		struct address_space *mapping, struct page *page)
 {
+	struct file *filp = iocb->ki_filp;
 	struct file_ra_state *ra = &filp->f_ra;
 	int error;
 
@@ -2228,11 +2229,10 @@  static struct page *gfbr_read_page(struct kiocb *iocb, struct file *filp,
 	return page;
 }
 
-static struct page *gfbr_update_page(struct kiocb *iocb, struct file *filp,
-		struct iov_iter *iter, struct page *page, loff_t pos,
-		loff_t count)
+static struct page *gfbr_update_page(struct kiocb *iocb,
+		struct address_space *mapping, struct iov_iter *iter,
+		struct page *page, loff_t pos, loff_t count)
 {
-	struct address_space *mapping = filp->f_mapping;
 	struct inode *inode = mapping->host;
 	int error;
 
@@ -2293,13 +2293,12 @@  static struct page *gfbr_update_page(struct kiocb *iocb, struct file *filp,
 		return page;
 	}
 
-	return gfbr_read_page(iocb, filp, mapping, page);
+	return gfbr_read_page(iocb, mapping, page);
 }
 
-static struct page *gfbr_create_page(struct kiocb *iocb, struct iov_iter *iter)
+static struct page *gfbr_create_page(struct kiocb *iocb,
+		struct address_space *mapping, struct iov_iter *iter)
 {
-	struct file *filp = iocb->ki_filp;
-	struct address_space *mapping = filp->f_mapping;
 	pgoff_t index = iocb->ki_pos >> PAGE_SHIFT;
 	struct page *page;
 	int error;
@@ -2318,7 +2317,7 @@  static struct page *gfbr_create_page(struct kiocb *iocb, struct iov_iter *iter)
 		return error != -EEXIST ? ERR_PTR(error) : NULL;
 	}
 
-	return gfbr_read_page(iocb, filp, mapping, page);
+	return gfbr_read_page(iocb, mapping, page);
 }
 
 static int gfbr_get_pages(struct kiocb *iocb, struct iov_iter *iter,
@@ -2349,7 +2348,7 @@  static int gfbr_get_pages(struct kiocb *iocb, struct iov_iter *iter,
 	if (nr_got)
 		goto got_pages;
 
-	pages[0] = gfbr_create_page(iocb, iter);
+	pages[0] = gfbr_create_page(iocb, mapping, iter);
 	err = PTR_ERR_OR_ZERO(pages[0]);
 	if (!IS_ERR_OR_NULL(pages[0]))
 		nr_got = 1;
@@ -2383,7 +2382,7 @@  static int gfbr_get_pages(struct kiocb *iocb, struct iov_iter *iter,
 				break;
 			}
 
-			page = gfbr_update_page(iocb, filp, iter, page,
+			page = gfbr_update_page(iocb, mapping, iter, page,
 					pg_pos, pg_count);
 			if (IS_ERR_OR_NULL(page)) {
 				for (j = i + 1; j < nr_got; j++)