diff options
-rw-r--r-- | fs/cachefiles/rdwr.c | 30 | ||||
-rw-r--r-- | fs/nfs/dir.c | 7 | ||||
-rw-r--r-- | include/linux/pagevec.h | 34 | ||||
-rw-r--r-- | mm/swap.c | 12 |
4 files changed, 14 insertions, 69 deletions
diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c index 317f9ee9c991..ebaff368120d 100644 --- a/fs/cachefiles/rdwr.c +++ b/fs/cachefiles/rdwr.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/mount.h> | 12 | #include <linux/mount.h> |
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/file.h> | 14 | #include <linux/file.h> |
15 | #include <linux/swap.h> | ||
15 | #include "internal.h" | 16 | #include "internal.h" |
16 | 17 | ||
17 | /* | 18 | /* |
@@ -227,8 +228,7 @@ static void cachefiles_read_copier(struct fscache_operation *_op) | |||
227 | */ | 228 | */ |
228 | static int cachefiles_read_backing_file_one(struct cachefiles_object *object, | 229 | static int cachefiles_read_backing_file_one(struct cachefiles_object *object, |
229 | struct fscache_retrieval *op, | 230 | struct fscache_retrieval *op, |
230 | struct page *netpage, | 231 | struct page *netpage) |
231 | struct pagevec *pagevec) | ||
232 | { | 232 | { |
233 | struct cachefiles_one_read *monitor; | 233 | struct cachefiles_one_read *monitor; |
234 | struct address_space *bmapping; | 234 | struct address_space *bmapping; |
@@ -237,8 +237,6 @@ static int cachefiles_read_backing_file_one(struct cachefiles_object *object, | |||
237 | 237 | ||
238 | _enter(""); | 238 | _enter(""); |
239 | 239 | ||
240 | pagevec_reinit(pagevec); | ||
241 | |||
242 | _debug("read back %p{%lu,%d}", | 240 | _debug("read back %p{%lu,%d}", |
243 | netpage, netpage->index, page_count(netpage)); | 241 | netpage, netpage->index, page_count(netpage)); |
244 | 242 | ||
@@ -283,9 +281,7 @@ installed_new_backing_page: | |||
283 | backpage = newpage; | 281 | backpage = newpage; |
284 | newpage = NULL; | 282 | newpage = NULL; |
285 | 283 | ||
286 | page_cache_get(backpage); | 284 | lru_cache_add_file(backpage); |
287 | pagevec_add(pagevec, backpage); | ||
288 | __pagevec_lru_add_file(pagevec); | ||
289 | 285 | ||
290 | read_backing_page: | 286 | read_backing_page: |
291 | ret = bmapping->a_ops->readpage(NULL, backpage); | 287 | ret = bmapping->a_ops->readpage(NULL, backpage); |
@@ -452,8 +448,7 @@ int cachefiles_read_or_alloc_page(struct fscache_retrieval *op, | |||
452 | if (block) { | 448 | if (block) { |
453 | /* submit the apparently valid page to the backing fs to be | 449 | /* submit the apparently valid page to the backing fs to be |
454 | * read from disk */ | 450 | * read from disk */ |
455 | ret = cachefiles_read_backing_file_one(object, op, page, | 451 | ret = cachefiles_read_backing_file_one(object, op, page); |
456 | &pagevec); | ||
457 | } else if (cachefiles_has_space(cache, 0, 1) == 0) { | 452 | } else if (cachefiles_has_space(cache, 0, 1) == 0) { |
458 | /* there's space in the cache we can use */ | 453 | /* there's space in the cache we can use */ |
459 | fscache_mark_page_cached(op, page); | 454 | fscache_mark_page_cached(op, page); |
@@ -482,14 +477,11 @@ static int cachefiles_read_backing_file(struct cachefiles_object *object, | |||
482 | { | 477 | { |
483 | struct cachefiles_one_read *monitor = NULL; | 478 | struct cachefiles_one_read *monitor = NULL; |
484 | struct address_space *bmapping = object->backer->d_inode->i_mapping; | 479 | struct address_space *bmapping = object->backer->d_inode->i_mapping; |
485 | struct pagevec lru_pvec; | ||
486 | struct page *newpage = NULL, *netpage, *_n, *backpage = NULL; | 480 | struct page *newpage = NULL, *netpage, *_n, *backpage = NULL; |
487 | int ret = 0; | 481 | int ret = 0; |
488 | 482 | ||
489 | _enter(""); | 483 | _enter(""); |
490 | 484 | ||
491 | pagevec_init(&lru_pvec, 0); | ||
492 | |||
493 | list_for_each_entry_safe(netpage, _n, list, lru) { | 485 | list_for_each_entry_safe(netpage, _n, list, lru) { |
494 | list_del(&netpage->lru); | 486 | list_del(&netpage->lru); |
495 | 487 | ||
@@ -534,9 +526,7 @@ static int cachefiles_read_backing_file(struct cachefiles_object *object, | |||
534 | backpage = newpage; | 526 | backpage = newpage; |
535 | newpage = NULL; | 527 | newpage = NULL; |
536 | 528 | ||
537 | page_cache_get(backpage); | 529 | lru_cache_add_file(backpage); |
538 | if (!pagevec_add(&lru_pvec, backpage)) | ||
539 | __pagevec_lru_add_file(&lru_pvec); | ||
540 | 530 | ||
541 | reread_backing_page: | 531 | reread_backing_page: |
542 | ret = bmapping->a_ops->readpage(NULL, backpage); | 532 | ret = bmapping->a_ops->readpage(NULL, backpage); |
@@ -559,9 +549,7 @@ static int cachefiles_read_backing_file(struct cachefiles_object *object, | |||
559 | goto nomem; | 549 | goto nomem; |
560 | } | 550 | } |
561 | 551 | ||
562 | page_cache_get(netpage); | 552 | lru_cache_add_file(netpage); |
563 | if (!pagevec_add(&lru_pvec, netpage)) | ||
564 | __pagevec_lru_add_file(&lru_pvec); | ||
565 | 553 | ||
566 | /* install a monitor */ | 554 | /* install a monitor */ |
567 | page_cache_get(netpage); | 555 | page_cache_get(netpage); |
@@ -643,9 +631,7 @@ static int cachefiles_read_backing_file(struct cachefiles_object *object, | |||
643 | 631 | ||
644 | fscache_mark_page_cached(op, netpage); | 632 | fscache_mark_page_cached(op, netpage); |
645 | 633 | ||
646 | page_cache_get(netpage); | 634 | lru_cache_add_file(netpage); |
647 | if (!pagevec_add(&lru_pvec, netpage)) | ||
648 | __pagevec_lru_add_file(&lru_pvec); | ||
649 | 635 | ||
650 | /* the netpage is unlocked and marked up to date here */ | 636 | /* the netpage is unlocked and marked up to date here */ |
651 | fscache_end_io(op, netpage, 0); | 637 | fscache_end_io(op, netpage, 0); |
@@ -661,8 +647,6 @@ static int cachefiles_read_backing_file(struct cachefiles_object *object, | |||
661 | 647 | ||
662 | out: | 648 | out: |
663 | /* tidy up */ | 649 | /* tidy up */ |
664 | pagevec_lru_add_file(&lru_pvec); | ||
665 | |||
666 | if (newpage) | 650 | if (newpage) |
667 | page_cache_release(newpage); | 651 | page_cache_release(newpage); |
668 | if (netpage) | 652 | if (netpage) |
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 5d051419527b..d7ed697133f0 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/pagevec.h> | 33 | #include <linux/pagevec.h> |
34 | #include <linux/namei.h> | 34 | #include <linux/namei.h> |
35 | #include <linux/mount.h> | 35 | #include <linux/mount.h> |
36 | #include <linux/swap.h> | ||
36 | #include <linux/sched.h> | 37 | #include <linux/sched.h> |
37 | #include <linux/kmemleak.h> | 38 | #include <linux/kmemleak.h> |
38 | #include <linux/xattr.h> | 39 | #include <linux/xattr.h> |
@@ -1758,7 +1759,6 @@ EXPORT_SYMBOL_GPL(nfs_unlink); | |||
1758 | */ | 1759 | */ |
1759 | int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) | 1760 | int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) |
1760 | { | 1761 | { |
1761 | struct pagevec lru_pvec; | ||
1762 | struct page *page; | 1762 | struct page *page; |
1763 | char *kaddr; | 1763 | char *kaddr; |
1764 | struct iattr attr; | 1764 | struct iattr attr; |
@@ -1798,11 +1798,8 @@ int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) | |||
1798 | * No big deal if we can't add this page to the page cache here. | 1798 | * No big deal if we can't add this page to the page cache here. |
1799 | * READLINK will get the missing page from the server if needed. | 1799 | * READLINK will get the missing page from the server if needed. |
1800 | */ | 1800 | */ |
1801 | pagevec_init(&lru_pvec, 0); | 1801 | if (!add_to_page_cache_lru(page, dentry->d_inode->i_mapping, 0, |
1802 | if (!add_to_page_cache(page, dentry->d_inode->i_mapping, 0, | ||
1803 | GFP_KERNEL)) { | 1802 | GFP_KERNEL)) { |
1804 | pagevec_add(&lru_pvec, page); | ||
1805 | pagevec_lru_add_file(&lru_pvec); | ||
1806 | SetPageUptodate(page); | 1803 | SetPageUptodate(page); |
1807 | unlock_page(page); | 1804 | unlock_page(page); |
1808 | } else | 1805 | } else |
diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index 2aa12b8499c0..e4dbfab37729 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h | |||
@@ -21,7 +21,7 @@ struct pagevec { | |||
21 | }; | 21 | }; |
22 | 22 | ||
23 | void __pagevec_release(struct pagevec *pvec); | 23 | void __pagevec_release(struct pagevec *pvec); |
24 | void __pagevec_lru_add(struct pagevec *pvec, enum lru_list lru); | 24 | void __pagevec_lru_add(struct pagevec *pvec); |
25 | unsigned pagevec_lookup(struct pagevec *pvec, struct address_space *mapping, | 25 | unsigned pagevec_lookup(struct pagevec *pvec, struct address_space *mapping, |
26 | pgoff_t start, unsigned nr_pages); | 26 | pgoff_t start, unsigned nr_pages); |
27 | unsigned pagevec_lookup_tag(struct pagevec *pvec, | 27 | unsigned pagevec_lookup_tag(struct pagevec *pvec, |
@@ -64,36 +64,4 @@ static inline void pagevec_release(struct pagevec *pvec) | |||
64 | __pagevec_release(pvec); | 64 | __pagevec_release(pvec); |
65 | } | 65 | } |
66 | 66 | ||
67 | static inline void __pagevec_lru_add_anon(struct pagevec *pvec) | ||
68 | { | ||
69 | __pagevec_lru_add(pvec, LRU_INACTIVE_ANON); | ||
70 | } | ||
71 | |||
72 | static inline void __pagevec_lru_add_active_anon(struct pagevec *pvec) | ||
73 | { | ||
74 | __pagevec_lru_add(pvec, LRU_ACTIVE_ANON); | ||
75 | } | ||
76 | |||
77 | static inline void __pagevec_lru_add_file(struct pagevec *pvec) | ||
78 | { | ||
79 | __pagevec_lru_add(pvec, LRU_INACTIVE_FILE); | ||
80 | } | ||
81 | |||
82 | static inline void __pagevec_lru_add_active_file(struct pagevec *pvec) | ||
83 | { | ||
84 | __pagevec_lru_add(pvec, LRU_ACTIVE_FILE); | ||
85 | } | ||
86 | |||
87 | static inline void pagevec_lru_add_file(struct pagevec *pvec) | ||
88 | { | ||
89 | if (pagevec_count(pvec)) | ||
90 | __pagevec_lru_add_file(pvec); | ||
91 | } | ||
92 | |||
93 | static inline void pagevec_lru_add_anon(struct pagevec *pvec) | ||
94 | { | ||
95 | if (pagevec_count(pvec)) | ||
96 | __pagevec_lru_add_anon(pvec); | ||
97 | } | ||
98 | |||
99 | #endif /* _LINUX_PAGEVEC_H */ | 67 | #endif /* _LINUX_PAGEVEC_H */ |
@@ -505,7 +505,7 @@ void __lru_cache_add(struct page *page, enum lru_list lru) | |||
505 | 505 | ||
506 | page_cache_get(page); | 506 | page_cache_get(page); |
507 | if (!pagevec_space(pvec)) | 507 | if (!pagevec_space(pvec)) |
508 | __pagevec_lru_add(pvec, lru); | 508 | __pagevec_lru_add(pvec); |
509 | pagevec_add(pvec, page); | 509 | pagevec_add(pvec, page); |
510 | put_cpu_var(lru_add_pvec); | 510 | put_cpu_var(lru_add_pvec); |
511 | } | 511 | } |
@@ -628,7 +628,7 @@ void lru_add_drain_cpu(int cpu) | |||
628 | struct pagevec *pvec = &per_cpu(lru_add_pvec, cpu); | 628 | struct pagevec *pvec = &per_cpu(lru_add_pvec, cpu); |
629 | 629 | ||
630 | if (pagevec_count(pvec)) | 630 | if (pagevec_count(pvec)) |
631 | __pagevec_lru_add(pvec, NR_LRU_LISTS); | 631 | __pagevec_lru_add(pvec); |
632 | 632 | ||
633 | pvec = &per_cpu(lru_rotate_pvecs, cpu); | 633 | pvec = &per_cpu(lru_rotate_pvecs, cpu); |
634 | if (pagevec_count(pvec)) { | 634 | if (pagevec_count(pvec)) { |
@@ -832,12 +832,10 @@ void lru_add_page_tail(struct page *page, struct page *page_tail, | |||
832 | static void __pagevec_lru_add_fn(struct page *page, struct lruvec *lruvec, | 832 | static void __pagevec_lru_add_fn(struct page *page, struct lruvec *lruvec, |
833 | void *arg) | 833 | void *arg) |
834 | { | 834 | { |
835 | enum lru_list requested_lru = (enum lru_list)arg; | ||
836 | int file = page_is_file_cache(page); | 835 | int file = page_is_file_cache(page); |
837 | int active = PageActive(page); | 836 | int active = PageActive(page); |
838 | enum lru_list lru = page_lru(page); | 837 | enum lru_list lru = page_lru(page); |
839 | 838 | ||
840 | WARN_ON_ONCE(requested_lru < NR_LRU_LISTS && requested_lru != lru); | ||
841 | VM_BUG_ON(PageUnevictable(page)); | 839 | VM_BUG_ON(PageUnevictable(page)); |
842 | VM_BUG_ON(PageLRU(page)); | 840 | VM_BUG_ON(PageLRU(page)); |
843 | 841 | ||
@@ -851,11 +849,9 @@ static void __pagevec_lru_add_fn(struct page *page, struct lruvec *lruvec, | |||
851 | * Add the passed pages to the LRU, then drop the caller's refcount | 849 | * Add the passed pages to the LRU, then drop the caller's refcount |
852 | * on them. Reinitialises the caller's pagevec. | 850 | * on them. Reinitialises the caller's pagevec. |
853 | */ | 851 | */ |
854 | void __pagevec_lru_add(struct pagevec *pvec, enum lru_list lru) | 852 | void __pagevec_lru_add(struct pagevec *pvec) |
855 | { | 853 | { |
856 | VM_BUG_ON(is_unevictable_lru(lru)); | 854 | pagevec_lru_move_fn(pvec, __pagevec_lru_add_fn, NULL); |
857 | |||
858 | pagevec_lru_move_fn(pvec, __pagevec_lru_add_fn, (void *)lru); | ||
859 | } | 855 | } |
860 | EXPORT_SYMBOL(__pagevec_lru_add); | 856 | EXPORT_SYMBOL(__pagevec_lru_add); |
861 | 857 | ||