diff options
Diffstat (limited to 'mm/swap.c')
-rw-r--r-- | mm/swap.c | 51 |
1 files changed, 51 insertions, 0 deletions
@@ -948,6 +948,57 @@ void __pagevec_lru_add(struct pagevec *pvec) | |||
948 | EXPORT_SYMBOL(__pagevec_lru_add); | 948 | EXPORT_SYMBOL(__pagevec_lru_add); |
949 | 949 | ||
950 | /** | 950 | /** |
951 | * pagevec_lookup_entries - gang pagecache lookup | ||
952 | * @pvec: Where the resulting entries are placed | ||
953 | * @mapping: The address_space to search | ||
954 | * @start: The starting entry index | ||
955 | * @nr_entries: The maximum number of entries | ||
956 | * @indices: The cache indices corresponding to the entries in @pvec | ||
957 | * | ||
958 | * pagevec_lookup_entries() will search for and return a group of up | ||
959 | * to @nr_entries pages and shadow entries in the mapping. All | ||
960 | * entries are placed in @pvec. pagevec_lookup_entries() takes a | ||
961 | * reference against actual pages in @pvec. | ||
962 | * | ||
963 | * The search returns a group of mapping-contiguous entries with | ||
964 | * ascending indexes. There may be holes in the indices due to | ||
965 | * not-present entries. | ||
966 | * | ||
967 | * pagevec_lookup_entries() returns the number of entries which were | ||
968 | * found. | ||
969 | */ | ||
970 | unsigned pagevec_lookup_entries(struct pagevec *pvec, | ||
971 | struct address_space *mapping, | ||
972 | pgoff_t start, unsigned nr_pages, | ||
973 | pgoff_t *indices) | ||
974 | { | ||
975 | pvec->nr = find_get_entries(mapping, start, nr_pages, | ||
976 | pvec->pages, indices); | ||
977 | return pagevec_count(pvec); | ||
978 | } | ||
979 | |||
980 | /** | ||
981 | * pagevec_remove_exceptionals - pagevec exceptionals pruning | ||
982 | * @pvec: The pagevec to prune | ||
983 | * | ||
984 | * pagevec_lookup_entries() fills both pages and exceptional radix | ||
985 | * tree entries into the pagevec. This function prunes all | ||
986 | * exceptionals from @pvec without leaving holes, so that it can be | ||
987 | * passed on to page-only pagevec operations. | ||
988 | */ | ||
989 | void pagevec_remove_exceptionals(struct pagevec *pvec) | ||
990 | { | ||
991 | int i, j; | ||
992 | |||
993 | for (i = 0, j = 0; i < pagevec_count(pvec); i++) { | ||
994 | struct page *page = pvec->pages[i]; | ||
995 | if (!radix_tree_exceptional_entry(page)) | ||
996 | pvec->pages[j++] = page; | ||
997 | } | ||
998 | pvec->nr = j; | ||
999 | } | ||
1000 | |||
1001 | /** | ||
951 | * pagevec_lookup - gang pagecache lookup | 1002 | * pagevec_lookup - gang pagecache lookup |
952 | * @pvec: Where the resulting pages are placed | 1003 | * @pvec: Where the resulting pages are placed |
953 | * @mapping: The address_space to search | 1004 | * @mapping: The address_space to search |