diff mbox series

[02/22] fs: Move pagecache_write_begin() and pagecache_write_end()

Message ID 20220222194820.737755-3-willy@infradead.org (mailing list archive)
State New, archived
Headers show
Series Remove aop flags | expand

Commit Message

Matthew Wilcox Feb. 22, 2022, 7:48 p.m. UTC
These functions are now simple enough to be static inlines.  They
should also be in pagemap.h instead of fs.h because they're
pagecache functions.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/fs.h      | 12 ------------
 include/linux/pagemap.h | 20 ++++++++++++++++++++
 mm/filemap.c            | 21 ---------------------
 3 files changed, 20 insertions(+), 33 deletions(-)

Comments

Christoph Hellwig Feb. 23, 2022, 6:53 a.m. UTC | #1
On Tue, Feb 22, 2022 at 07:48:00PM +0000, Matthew Wilcox (Oracle) wrote:
> These functions are now simple enough to be static inlines.  They
> should also be in pagemap.h instead of fs.h because they're
> pagecache functions.

I wonder if we should keep them at all.  For the core fs code calling
the methods directly seems perfectly fine.  And the calles in the file
systems should just call the implementations and avoid the indirection.

And the callers in i915 look very suspicious.
Christian Brauner Feb. 23, 2022, 8:47 a.m. UTC | #2
On Tue, Feb 22, 2022 at 07:48:00PM +0000, Matthew Wilcox wrote:
> These functions are now simple enough to be static inlines.  They
> should also be in pagemap.h instead of fs.h because they're
> pagecache functions.
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> ---

Good to see the header shrink further!
Reviewed-by: Christian Brauner <brauner@kernel.org>
diff mbox series

Patch

diff --git a/include/linux/fs.h b/include/linux/fs.h
index 394570a970af..2843f789a6db 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -391,18 +391,6 @@  struct address_space_operations {
 
 extern const struct address_space_operations empty_aops;
 
-/*
- * pagecache_write_begin/pagecache_write_end must be used by general code
- * to write into the pagecache.
- */
-int pagecache_write_begin(struct file *, struct address_space *mapping,
-				loff_t pos, unsigned len, unsigned flags,
-				struct page **pagep, void **fsdata);
-
-int pagecache_write_end(struct file *, struct address_space *mapping,
-				loff_t pos, unsigned len, unsigned copied,
-				struct page *page, void *fsdata);
-
 /**
  * struct address_space - Contents of a cacheable, mappable object.
  * @host: Owner, either the inode or the block_device.
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 9cd504542c31..76b0ddfef5ba 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -529,6 +529,26 @@  static inline struct page *grab_cache_page_nowait(struct address_space *mapping,
 			mapping_gfp_mask(mapping));
 }
 
+/*
+ * pagecache_write_begin/pagecache_write_end must be used by general code
+ * to write into the pagecache.
+ */
+static inline int pagecache_write_begin(struct file *file,
+		struct address_space *mapping, loff_t pos, unsigned len,
+		unsigned flags, struct page **pagep, void **fsdata)
+{
+	return mapping->a_ops->write_begin(file, mapping, pos, len, flags,
+						pagep, fsdata);
+}
+
+static inline int pagecache_write_end(struct file *file,
+		struct address_space *mapping, loff_t pos, unsigned len,
+		unsigned copied, struct page *page, void *fsdata)
+{
+	return mapping->a_ops->write_end(file, mapping, pos, len, copied,
+						page, fsdata);
+}
+
 #define swapcache_index(folio)	__page_file_index(&(folio)->page)
 
 /**
diff --git a/mm/filemap.c b/mm/filemap.c
index c2bef068afab..9e3ccc2e54ee 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -3601,27 +3601,6 @@  struct page *read_cache_page_gfp(struct address_space *mapping,
 }
 EXPORT_SYMBOL(read_cache_page_gfp);
 
-int pagecache_write_begin(struct file *file, struct address_space *mapping,
-				loff_t pos, unsigned len, unsigned flags,
-				struct page **pagep, void **fsdata)
-{
-	const struct address_space_operations *aops = mapping->a_ops;
-
-	return aops->write_begin(file, mapping, pos, len, flags,
-							pagep, fsdata);
-}
-EXPORT_SYMBOL(pagecache_write_begin);
-
-int pagecache_write_end(struct file *file, struct address_space *mapping,
-				loff_t pos, unsigned len, unsigned copied,
-				struct page *page, void *fsdata)
-{
-	const struct address_space_operations *aops = mapping->a_ops;
-
-	return aops->write_end(file, mapping, pos, len, copied, page, fsdata);
-}
-EXPORT_SYMBOL(pagecache_write_end);
-
 /*
  * Warn about a page cache invalidation failure during a direct I/O write.
  */