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.
Unified · Split
| @@ -17,6 +17,7 @@ · 16 unmodified lines | |||
| 17 | #include <linux/writeback.h> | 17 | #include <linux/writeback.h> |
| 18 | #include <linux/gfp.h> | 18 | #include <linux/gfp.h> |
| 19 | #include <linux/task_io_accounting_ops.h> | 19 | #include <linux/task_io_accounting_ops.h> |
| 20 | #include <linux/mm.h> | ||
| 20 | #include "internal.h" | 21 | #include "internal.h" |
| 21 | 22 | ||
| 22 | static int afs_file_mmap(struct file *file, struct vm_area_struct *vma); | 23 | 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, · 418 unmodified lines | |||
| 441 | /* Count the number of contiguous pages at the front of the list. Note | 442 | /* Count the number of contiguous pages at the front of the list. Note |
| 442 | * that the list goes prev-wards rather than next-wards. | 443 | * that the list goes prev-wards rather than next-wards. |
| 443 | */ | 444 | */ |
| 444 | first = list_entry(pages->prev, struct page, lru); | 445 | first = lru_to_page(pages); |
| 445 | index = first->index + 1; | 446 | index = first->index + 1; |
| 446 | n = 1; | 447 | n = 1; |
| 447 | for (p = first->lru.prev; p != pages; p = p->prev) { | 448 | 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, · 25 unmodified lines | |||
| 473 | * page at the end of the file. | 474 | * page at the end of the file. |
| 474 | */ | 475 | */ |
| 475 | do { | 476 | do { |
| 476 | page = list_entry(pages->prev, struct page, lru); | 477 | page = lru_to_page(pages); |
| 477 | list_del(&page->lru); | 478 | list_del(&page->lru); |
| 478 | index = page->index; | 479 | index = page->index; |
| 479 | if (add_to_page_cache_lru(page, mapping, index, | 480 | if (add_to_page_cache_lru(page, mapping, index, |
| @@ -4103,8 +4103,7 @@ int extent_readpages(struct address_space *mapping, struct list_head *pages, · 4102 unmodified lines | |||
| 4103 | 4103 | ||
| 4104 | while (!list_empty(pages)) { | 4104 | while (!list_empty(pages)) { |
| 4105 | for (nr = 0; nr < ARRAY_SIZE(pagepool) && !list_empty(pages);) { | 4105 | for (nr = 0; nr < ARRAY_SIZE(pagepool) && !list_empty(pages);) { |
| 4106 | struct page *page = list_entry(pages->prev, | 4106 | struct page *page = lru_to_page(pages); |
| 4107 | struct page, lru); | ||
| 4108 | 4107 | ||
| 4109 | prefetchw(&page->flags); | 4108 | prefetchw(&page->flags); |
| 4110 | list_del(&page->lru); | 4109 | list_del(&page->lru); |
| @@ -306,7 +306,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx, · 305 unmodified lines | |||
| 306 | struct ceph_osd_client *osdc = | 306 | struct ceph_osd_client *osdc = |
| 307 | &ceph_inode_to_client(inode)->client->osdc; | 307 | &ceph_inode_to_client(inode)->client->osdc; |
| 308 | struct ceph_inode_info *ci = ceph_inode(inode); | 308 | struct ceph_inode_info *ci = ceph_inode(inode); |
| 309 | struct page *page = list_entry(page_list->prev, struct page, lru); | 309 | struct page *page = lru_to_page(page_list); |
| 310 | struct ceph_vino vino; | 310 | struct ceph_vino vino; |
| 311 | struct ceph_osd_request *req; | 311 | struct ceph_osd_request *req; |
| 312 | u64 off; | 312 | u64 off; |
| @@ -333,8 +333,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx, · 20 unmodified lines | |||
| 333 | if (got) | 333 | if (got) |
| 334 | ceph_put_cap_refs(ci, got); | 334 | ceph_put_cap_refs(ci, got); |
| 335 | while (!list_empty(page_list)) { | 335 | while (!list_empty(page_list)) { |
| 336 | page = list_entry(page_list->prev, | 336 | page = lru_to_page(page_list); |
| 337 | struct page, lru); | ||
| 338 | list_del(&page->lru); | 337 | list_del(&page->lru); |
| 339 | put_page(page); | 338 | put_page(page); |
| 340 | } | 339 | } |
| @@ -33,6 +33,7 @@ · 32 unmodified lines | |||
| 33 | #include <linux/mount.h> | 33 | #include <linux/mount.h> |
| 34 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
| 35 | #include <linux/swap.h> | 35 | #include <linux/swap.h> |
| 36 | #include <linux/mm.h> | ||
| 36 | #include <asm/div64.h> | 37 | #include <asm/div64.h> |
| 37 | #include "cifsfs.h" | 38 | #include "cifsfs.h" |
| 38 | #include "cifspdu.h" | 39 | #include "cifspdu.h" |
| @@ -3964,7 +3965,7 @@ readpages_get_pages(struct address_space *mapping, struct list_head *page_list, · 3925 unmodified lines | |||
| 3964 | 3965 | ||
| 3965 | INIT_LIST_HEAD(tmplist); | 3966 | INIT_LIST_HEAD(tmplist); |
| 3966 | 3967 | ||
| 3967 | page = list_entry(page_list->prev, struct page, lru); | 3968 | page = lru_to_page(page_list); |
| 3968 | 3969 | ||
| 3969 | /* | 3970 | /* |
| 3970 | * Lock the page and put it in the cache. Since no one else | 3971 | * Lock the page and put it in the cache. Since no one else |
| @@ -128,7 +128,7 @@ int ext4_mpage_readpages(struct address_space *mapping, · 127 unmodified lines | |||
| 128 | 128 | ||
| 129 | prefetchw(&page->flags); | 129 | prefetchw(&page->flags); |
| 130 | if (pages) { | 130 | if (pages) { |
| 131 | page = list_entry(pages->prev, struct page, lru); | 131 | page = lru_to_page(pages); |
| 132 | list_del(&page->lru); | 132 | list_del(&page->lru); |
| 133 | if (add_to_page_cache_lru(page, mapping, page->index, | 133 | if (add_to_page_cache_lru(page, mapping, page->index, |
| 134 | readahead_gfp_mask(mapping))) | 134 | readahead_gfp_mask(mapping))) |
| @@ -30,6 +30,7 @@ · 29 unmodified lines | |||
| 30 | #include <linux/quotaops.h> | 30 | #include <linux/quotaops.h> |
| 31 | #include <linux/blkdev.h> | 31 | #include <linux/blkdev.h> |
| 32 | #include <linux/uio.h> | 32 | #include <linux/uio.h> |
| 33 | #include <linux/mm.h> | ||
| 33 | 34 | ||
| 34 | #include <cluster/masklog.h> | 35 | #include <cluster/masklog.h> |
| 35 | 36 | ||
| @@ -397,7 +398,7 @@ static int ocfs2_readpages(struct file *filp, struct address_space *mapping, · 361 unmodified lines | |||
| 397 | * Check whether a remote node truncated this file - we just | 398 | * Check whether a remote node truncated this file - we just |
| 398 | * drop out in that case as it's not worth handling here. | 399 | * drop out in that case as it's not worth handling here. |
| 399 | */ | 400 | */ |
| 400 | last = list_entry(pages->prev, struct page, lru); | 401 | last = lru_to_page(pages); |
| 401 | start = (loff_t)last->index << PAGE_SHIFT; | 402 | start = (loff_t)last->index << PAGE_SHIFT; |
| 402 | if (start >= i_size_read(inode)) | 403 | if (start >= i_size_read(inode)) |
| 403 | goto out_unlock; | 404 | goto out_unlock; |
| @@ -77,7 +77,7 @@ static int orangefs_readpages(struct file *file, · 76 unmodified lines | |||
| 77 | for (page_idx = 0; page_idx < nr_pages; page_idx++) { | 77 | for (page_idx = 0; page_idx < nr_pages; page_idx++) { |
| 78 | struct page *page; | 78 | struct page *page; |
| 79 | 79 | ||
| 80 | page = list_entry(pages->prev, struct page, lru); | 80 | page = lru_to_page(pages); |
| 81 | list_del(&page->lru); | 81 | list_del(&page->lru); |
| 82 | if (!add_to_page_cache(page, | 82 | if (!add_to_page_cache(page, |
| 83 | mapping, | 83 | mapping, |
| @@ -171,6 +171,8 @@ extern int overcommit_kbytes_handler(struct ctl_table *, int, void __user *, · 170 unmodified lines | |||
| 171 | /* test whether an address (unsigned long or pointer) is aligned to PAGE_SIZE */ | 171 | /* test whether an address (unsigned long or pointer) is aligned to PAGE_SIZE */ |
| 172 | #define PAGE_ALIGNED(addr) IS_ALIGNED((unsigned long)(addr), PAGE_SIZE) | 172 | #define PAGE_ALIGNED(addr) IS_ALIGNED((unsigned long)(addr), PAGE_SIZE) |
| 173 | 173 | ||
| 174 | #define lru_to_page(head) (list_entry((head)->prev, struct page, lru)) | ||
| 175 | |||
| 174 | /* | 176 | /* |
| 175 | * Linux kernel virtual memory manager primitives. | 177 | * Linux kernel virtual memory manager primitives. |
| 176 | * The idea being to have a "virtual" mm in the same way | 178 | * The idea being to have a "virtual" mm in the same way |
| @@ -124,7 +124,4 @@ static __always_inline enum lru_list page_lru(struct page *page) · 123 unmodified lines | |||
| 124 | } | 124 | } |
| 125 | return lru; | 125 | return lru; |
| 126 | } | 126 | } |
| 127 | |||
| 128 | #define lru_to_page(head) (list_entry((head)->prev, struct page, lru)) | ||
| 129 | |||
| 130 | #endif | 127 | #endif |
| @@ -126,7 +126,7 @@ void put_pages_list(struct list_head *pages) · 125 unmodified lines | |||
| 126 | while (!list_empty(pages)) { | 126 | while (!list_empty(pages)) { |
| 127 | struct page *victim; | 127 | struct page *victim; |
| 128 | 128 | ||
| 129 | victim = list_entry(pages->prev, struct page, lru); | 129 | victim = lru_to_page(pages); |
| 130 | list_del(&victim->lru); | 130 | list_del(&victim->lru); |
| 131 | put_page(victim); | 131 | put_page(victim); |
| 132 | } | 132 | } |