]> www.infradead.org Git - users/willy/linux.git/commitdiff
fs: don't open code lru_to_page()
authorNikolay Borisov <nborisov@suse.com>
Wed, 5 Dec 2018 00:14:26 +0000 (11:14 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 10 Dec 2018 08:29:18 +0000 (19:29 +1100)
Multiple filesystems open code lru_to_page().  Rectify this by moving the
macro from mm_inline (which is specific to lru stuff) to the more generic
mm.h header and start using the macro where appropriate.

No functional changes.

Link: http://lkml.kernel.org/r/20181129104810.23361-1-nborisov@suse.com
Link: https://lkml.kernel.org/r/20181129075301.29087-1-nborisov@suse.com
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>
Acked-by: Pankaj gupta <pagupta@redhat.com>
Acked-by: "Yan, Zheng" <zyan@redhat.com> [ceph]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
fs/afs/file.c
fs/btrfs/extent_io.c
fs/ceph/addr.c
fs/cifs/file.c
fs/ext4/readpage.c
fs/ocfs2/aops.c
fs/orangefs/inode.c
include/linux/mm.h
include/linux/mm_inline.h
mm/swap.c

index d6bc3f5d784b5676185070ae208345dd2eef3325..323ae99122039944a3df2a36a126748fafcd2529 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/writeback.h>
 #include <linux/gfp.h>
 #include <linux/task_io_accounting_ops.h>
+#include <linux/mm.h>
 #include "internal.h"
 
 static int afs_file_mmap(struct file *file, struct vm_area_struct *vma);
@@ -441,7 +442,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,
        /* Count the number of contiguous pages at the front of the list.  Note
         * that the list goes prev-wards rather than next-wards.
         */
-       first = list_entry(pages->prev, struct page, lru);
+       first = lru_to_page(pages);
        index = first->index + 1;
        n = 1;
        for (p = first->lru.prev; p != pages; p = p->prev) {
@@ -473,7 +474,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,
         * page at the end of the file.
         */
        do {
-               page = list_entry(pages->prev, struct page, lru);
+               page = lru_to_page(pages);
                list_del(&page->lru);
                index = page->index;
                if (add_to_page_cache_lru(page, mapping, index,
index 44876d57e70f66aa2458b1a4b08249a03833ea7c..65d349ab0e5d968748d5d9a67d179ab23bc483b3 100644 (file)
@@ -4105,7 +4105,7 @@ int extent_readpages(struct address_space *mapping, struct list_head *pages,
 
        while (!list_empty(pages)) {
                for (nr = 0; nr < BTRFS_PAGES_BATCH && !list_empty(pages);) {
-                       struct page *page = list_entry(pages->prev, struct page, lru);
+                       struct page *page = lru_to_page(pages);
 
                        prefetchw(&page->flags);
                        list_del(&page->lru);
index 8eade7a993c1f5f120908849a38a0c80537cf505..5d0c05e288ccb3bcfc09db85b3ef949711292ad1 100644 (file)
@@ -306,7 +306,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,
        struct ceph_osd_client *osdc =
                &ceph_inode_to_client(inode)->client->osdc;
        struct ceph_inode_info *ci = ceph_inode(inode);
-       struct page *page = list_entry(page_list->prev, struct page, lru);
+       struct page *page = lru_to_page(page_list);
        struct ceph_vino vino;
        struct ceph_osd_request *req;
        u64 off;
@@ -333,8 +333,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,
                        if (got)
                                ceph_put_cap_refs(ci, got);
                        while (!list_empty(page_list)) {
-                               page = list_entry(page_list->prev,
-                                                 struct page, lru);
+                               page = lru_to_page(page_list);
                                list_del(&page->lru);
                                put_page(page);
                        }
index 6706328ce03f89fc3eabc82f6b01779011c533c5..930fa49bcc8b2f7910e94effa68805a04b66cf93 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/mount.h>
 #include <linux/slab.h>
 #include <linux/swap.h>
+#include <linux/mm.h>
 #include <asm/div64.h>
 #include "cifsfs.h"
 #include "cifspdu.h"
@@ -3956,7 +3957,7 @@ readpages_get_pages(struct address_space *mapping, struct list_head *page_list,
 
        INIT_LIST_HEAD(tmplist);
 
-       page = list_entry(page_list->prev, struct page, lru);
+       page = lru_to_page(page_list);
 
        /*
         * Lock the page and put it in the cache. Since no one else
index d3dd1ff745db832be8ac979f5b69e4a7ffa625ed..806104ee022493c7053e4ec3f84ff14c71efaee1 100644 (file)
@@ -252,7 +252,7 @@ int ext4_mpage_readpages(struct address_space *mapping,
 
                prefetchw(&page->flags);
                if (pages) {
-                       page = list_entry(pages->prev, struct page, lru);
+                       page = lru_to_page(pages);
                        list_del(&page->lru);
                        if (add_to_page_cache_lru(page, mapping, page->index,
                                  readahead_gfp_mask(mapping)))
index 7302c6ab2c5669fc33e0efc144eed80132067a41..e8ea6f783f19c7840a96e566edf0af4b929b269f 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/quotaops.h>
 #include <linux/blkdev.h>
 #include <linux/uio.h>
+#include <linux/mm.h>
 
 #include <cluster/masklog.h>
 
@@ -397,7 +398,7 @@ static int ocfs2_readpages(struct file *filp, struct address_space *mapping,
         * Check whether a remote node truncated this file - we just
         * drop out in that case as it's not worth handling here.
         */
-       last = list_entry(pages->prev, struct page, lru);
+       last = lru_to_page(pages);
        start = (loff_t)last->index << PAGE_SHIFT;
        if (start >= i_size_read(inode))
                goto out_unlock;
index fe53381b26b1841c3cae47dbe630d400e6021af8..f038235c64bdf6d840f0d37fde29818ffa5c6e65 100644 (file)
@@ -77,7 +77,7 @@ static int orangefs_readpages(struct file *file,
        for (page_idx = 0; page_idx < nr_pages; page_idx++) {
                struct page *page;
 
-               page = list_entry(pages->prev, struct page, lru);
+               page = lru_to_page(pages);
                list_del(&page->lru);
                if (!add_to_page_cache(page,
                                       mapping,
index 0b777bfd1a8c9573ffd3e283cc9f38fe8ad3f24c..7babe7bdddc76b8672b3569e1f9b0c7114f5c0c1 100644 (file)
@@ -206,6 +206,8 @@ extern int overcommit_kbytes_handler(struct ctl_table *, int, void __user *,
 /* test whether an address (unsigned long or pointer) is aligned to PAGE_SIZE */
 #define PAGE_ALIGNED(addr)     IS_ALIGNED((unsigned long)(addr), PAGE_SIZE)
 
+#define lru_to_page(head) (list_entry((head)->prev, struct page, lru))
+
 /*
  * Linux kernel virtual memory manager primitives.
  * The idea being to have a "virtual" mm in the same way
index 10191c28fc04ce22c605d54a87257ee5ff427651..04ec454d44cefd0dbd2ffb1b82842b220a14d2cf 100644 (file)
@@ -124,7 +124,4 @@ static __always_inline enum lru_list page_lru(struct page *page)
        }
        return lru;
 }
-
-#define lru_to_page(head) (list_entry((head)->prev, struct page, lru))
-
 #endif
index 4d8a1f1afaab44976ce3f4bb1e9efd690276e819..4929bc1be60efaac6276288540cd61c244244753 100644 (file)
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -126,7 +126,7 @@ void put_pages_list(struct list_head *pages)
        while (!list_empty(pages)) {
                struct page *victim;
 
-               victim = list_entry(pages->prev, struct page, lru);
+               victim = lru_to_page(pages);
                list_del(&victim->lru);
                put_page(victim);
        }