]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
mm/writeback: Add pageset_write_one pageset-5.15
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 9 Mar 2021 18:48:03 +0000 (13:48 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Sat, 28 Aug 2021 02:52:26 +0000 (22:52 -0400)
Transform write_one_page() into pageset_write_one() and add a compatibility
wrapper.  Also move the declaration to pagemap.h as this is page cache
functionality that doesn't need to be used by the rest of the kernel.

Saves 58 bytes of kernel text.  While pageset_write_one() is 101 bytes
smaller than write_one_page(), the inlined call to page_pageset() expands
each caller.  There are fewer than ten callers so it doesn't seem worth
putting a wrapper in the core.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: David Howells <dhowells@redhat.com>
include/linux/mm.h
include/linux/pagemap.h
mm/page-writeback.c

index aae92c8c0668ddfe297b8230e31f291b7f1623ba..db66b45d855f2cb2e9a5ee25133dd82c1772f0a4 100644 (file)
@@ -2787,10 +2787,6 @@ extern vm_fault_t filemap_map_pages(struct vm_fault *vmf,
                pgoff_t start_pgoff, pgoff_t end_pgoff);
 extern vm_fault_t filemap_page_mkwrite(struct vm_fault *vmf);
 
-/* mm/page-writeback.c */
-int __must_check write_one_page(struct page *page);
-void task_dirty_inc(struct task_struct *tsk);
-
 extern unsigned long stack_guard_gap;
 /* Generic expand stack which grows the stack according to GROWS{UP,DOWN} */
 extern int expand_stack(struct vm_area_struct *vma, unsigned long address);
index 1cac000bdbf88002c27c29bc4fa843504a1fbcc6..a7caa305e8d82f11f5e5897d5e19fee796bea9dd 100644 (file)
@@ -804,6 +804,11 @@ static inline void cancel_dirty_page(struct page *page)
 }
 bool pageset_clear_dirty_for_io(struct pageset *pageset);
 bool clear_page_dirty_for_io(struct page *page);
+int __must_check pageset_write_one(struct pageset *pageset);
+static inline int __must_check write_one_page(struct page *page)
+{
+       return pageset_write_one(page_pageset(page));
+}
 
 int __set_page_dirty_nobuffers(struct page *page);
 int __set_page_dirty_no_writeback(struct page *page);
index 0b82f2c4da46ee6aecca2793736b276c3dc6d139..071f9cca683716a050344625fdcfb7690ea6757f 100644 (file)
@@ -2364,44 +2364,44 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc)
 }
 
 /**
- * write_one_page - write out a single page and wait on I/O
- * @page: the page to write
+ * pageset_write_one - write out a single pageset and wait on I/O.
+ * @pageset: The pageset to write.
  *
- * The page must be locked by the caller and will be unlocked upon return.
+ * The pageset must be locked by the caller and will be unlocked upon return.
  *
  * Note that the mapping's AS_EIO/AS_ENOSPC flags will be cleared when this
  * function returns.
  *
  * Return: %0 on success, negative error code otherwise
  */
-int write_one_page(struct page *page)
+int pageset_write_one(struct pageset *pageset)
 {
-       struct address_space *mapping = page->mapping;
+       struct address_space *mapping = pageset->mapping;
        int ret = 0;
        struct writeback_control wbc = {
                .sync_mode = WB_SYNC_ALL,
-               .nr_to_write = 1,
+               .nr_to_write = pageset_nr_pages(pageset),
        };
 
-       BUG_ON(!PageLocked(page));
+       BUG_ON(!pageset_test_locked(pageset));
 
-       wait_on_page_writeback(page);
+       pageset_wait_writeback(pageset);
 
-       if (clear_page_dirty_for_io(page)) {
-               get_page(page);
-               ret = mapping->a_ops->writepage(page, &wbc);
+       if (pageset_clear_dirty_for_io(pageset)) {
+               pageset_get(pageset);
+               ret = mapping->a_ops->writepage(&pageset->page, &wbc);
                if (ret == 0)
-                       wait_on_page_writeback(page);
-               put_page(page);
+                       pageset_wait_writeback(pageset);
+               pageset_put(pageset);
        } else {
-               unlock_page(page);
+               pageset_unlock(pageset);
        }
 
        if (!ret)
                ret = filemap_check_errors(mapping);
        return ret;
 }
-EXPORT_SYMBOL(write_one_page);
+EXPORT_SYMBOL(pageset_write_one);
 
 /*
  * For address_spaces which do not use buffers nor write back.