mm: remove generic_writepages
authorChristoph Hellwig <hch@lst.de>
Thu, 29 Dec 2022 16:10:31 +0000 (06:10 -1000)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 19 Jan 2023 01:12:51 +0000 (17:12 -0800)
Now that all external callers are gone, just fold it into do_writepages.

Link: https://lkml.kernel.org/r/20221229161031.391878-7-hch@lst.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/writeback.h
mm/page-writeback.c

index 06f9291..2554b71 100644 (file)
@@ -369,8 +369,6 @@ bool wb_over_bg_thresh(struct bdi_writeback *wb);
 typedef int (*writepage_t)(struct page *page, struct writeback_control *wbc,
                                void *data);
 
-int generic_writepages(struct address_space *mapping,
-                      struct writeback_control *wbc);
 void tag_pages_for_writeback(struct address_space *mapping,
                             pgoff_t start, pgoff_t end);
 int write_cache_pages(struct address_space *mapping,
index 41128ea..337cafe 100644 (file)
@@ -2526,12 +2526,8 @@ continue_unlock:
 }
 EXPORT_SYMBOL(write_cache_pages);
 
-/*
- * Function used by generic_writepages to call the real writepage
- * function and set the mapping flags on error
- */
-static int __writepage(struct page *page, struct writeback_control *wbc,
-                      void *data)
+static int writepage_cb(struct page *page, struct writeback_control *wbc,
+               void *data)
 {
        struct address_space *mapping = data;
        int ret = mapping->a_ops->writepage(page, wbc);
@@ -2539,34 +2535,6 @@ static int __writepage(struct page *page, struct writeback_control *wbc,
        return ret;
 }
 
-/**
- * generic_writepages - walk the list of dirty pages of the given address space and writepage() all of them.
- * @mapping: address space structure to write
- * @wbc: subtract the number of written pages from *@wbc->nr_to_write
- *
- * This is a library function, which implements the writepages()
- * address_space_operation.
- *
- * Return: %0 on success, negative error code otherwise
- */
-int generic_writepages(struct address_space *mapping,
-                      struct writeback_control *wbc)
-{
-       struct blk_plug plug;
-       int ret;
-
-       /* deal with chardevs and other special file */
-       if (!mapping->a_ops->writepage)
-               return 0;
-
-       blk_start_plug(&plug);
-       ret = write_cache_pages(mapping, wbc, __writepage, mapping);
-       blk_finish_plug(&plug);
-       return ret;
-}
-
-EXPORT_SYMBOL(generic_writepages);
-
 int do_writepages(struct address_space *mapping, struct writeback_control *wbc)
 {
        int ret;
@@ -2577,11 +2545,20 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc)
        wb = inode_to_wb_wbc(mapping->host, wbc);
        wb_bandwidth_estimate_start(wb);
        while (1) {
-               if (mapping->a_ops->writepages)
+               if (mapping->a_ops->writepages) {
                        ret = mapping->a_ops->writepages(mapping, wbc);
-               else
-                       ret = generic_writepages(mapping, wbc);
-               if ((ret != -ENOMEM) || (wbc->sync_mode != WB_SYNC_ALL))
+               } else if (mapping->a_ops->writepage) {
+                       struct blk_plug plug;
+
+                       blk_start_plug(&plug);
+                       ret = write_cache_pages(mapping, wbc, writepage_cb,
+                                               mapping);
+                       blk_finish_plug(&plug);
+               } else {
+                       /* deal with chardevs and other special files */
+                       ret = 0;
+               }
+               if (ret != -ENOMEM || wbc->sync_mode != WB_SYNC_ALL)
                        break;
 
                /*