diff mbox series

[03/14] fs: directly use a_ops->freepage() instead of a local copy of it.

Message ID 20201007010603.3452458-4-jglisse@redhat.com (mailing list archive)
State New, archived
Headers show
Series Small step toward KSM for file back page. | expand

Commit Message

Jerome Glisse Oct. 7, 2020, 1:05 a.m. UTC
From: Jérôme Glisse <jglisse@redhat.com>

Coccinelle is confuse with function pointer, convert to directly
use a_ops->freepage() to be nice to coccinelle.

Signed-off-by: Jérôme Glisse <jglisse@redhat.com>
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-mm@kvack.org
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Tejun Heo <tj@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
 mm/filemap.c | 12 ++++--------
 mm/vmscan.c  |  7 ++-----
 2 files changed, 6 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/mm/filemap.c b/mm/filemap.c
index 2cdbbffc55522..ba892599a2717 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -242,11 +242,8 @@  void __delete_from_page_cache(struct page *page, void *shadow)
 static void page_cache_free_page(struct address_space *mapping,
 				struct page *page)
 {
-	void (*freepage)(struct page *);
-
-	freepage = mapping->a_ops->freepage;
-	if (freepage)
-		freepage(page);
+	if (mapping->a_ops->freepage)
+		mapping->a_ops->freepage(page);
 
 	if (PageTransHuge(page) && !PageHuge(page)) {
 		page_ref_sub(page, HPAGE_PMD_NR);
@@ -790,7 +787,6 @@  EXPORT_SYMBOL(file_write_and_wait_range);
 int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
 {
 	struct address_space *mapping = old->mapping;
-	void (*freepage)(struct page *) = mapping->a_ops->freepage;
 	pgoff_t offset = old->index;
 	XA_STATE(xas, &mapping->i_pages, offset);
 	unsigned long flags;
@@ -819,8 +815,8 @@  int replace_page_cache_page(struct page *old, struct page *new, gfp_t gfp_mask)
 	if (PageSwapBacked(new))
 		__inc_lruvec_page_state(new, NR_SHMEM);
 	xas_unlock_irqrestore(&xas, flags);
-	if (freepage)
-		freepage(old);
+	if (mapping->a_ops->freepage)
+		mapping->a_ops->freepage(old);
 	put_page(old);
 
 	return 0;
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 466fc3144fffc..6db869339073d 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -903,9 +903,6 @@  static int __remove_mapping(struct address_space *mapping, struct page *page,
 		xa_unlock_irqrestore(&mapping->i_pages, flags);
 		put_swap_page(page, swap);
 	} else {
-		void (*freepage)(struct page *);
-
-		freepage = mapping->a_ops->freepage;
 		/*
 		 * Remember a shadow entry for reclaimed file cache in
 		 * order to detect refaults, thus thrashing, later on.
@@ -928,8 +925,8 @@  static int __remove_mapping(struct address_space *mapping, struct page *page,
 		__delete_from_page_cache(page, shadow);
 		xa_unlock_irqrestore(&mapping->i_pages, flags);
 
-		if (freepage != NULL)
-			freepage(page);
+		if (mapping->a_ops->freepage != NULL)
+			mapping->a_ops->freepage(page);
 	}
 
 	return 1;