diff options
-rw-r--r-- | include/linux/swap.h | 1 | ||||
-rw-r--r-- | mm/swapfile.c | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/swap.h b/include/linux/swap.h index bd6641784107..556617bcf7ac 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h | |||
@@ -209,6 +209,7 @@ extern unsigned int nr_swapfiles; | |||
209 | extern struct swap_info_struct swap_info[]; | 209 | extern struct swap_info_struct swap_info[]; |
210 | extern void si_swapinfo(struct sysinfo *); | 210 | extern void si_swapinfo(struct sysinfo *); |
211 | extern swp_entry_t get_swap_page(void); | 211 | extern swp_entry_t get_swap_page(void); |
212 | extern swp_entry_t get_swap_page_of_type(int type); | ||
212 | extern int swap_duplicate(swp_entry_t); | 213 | extern int swap_duplicate(swp_entry_t); |
213 | extern int valid_swaphandles(swp_entry_t, unsigned long *); | 214 | extern int valid_swaphandles(swp_entry_t, unsigned long *); |
214 | extern void swap_free(swp_entry_t); | 215 | extern void swap_free(swp_entry_t); |
diff --git a/mm/swapfile.c b/mm/swapfile.c index edafeace301f..6da4b28b896b 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c | |||
@@ -211,6 +211,26 @@ noswap: | |||
211 | return (swp_entry_t) {0}; | 211 | return (swp_entry_t) {0}; |
212 | } | 212 | } |
213 | 213 | ||
214 | swp_entry_t get_swap_page_of_type(int type) | ||
215 | { | ||
216 | struct swap_info_struct *si; | ||
217 | pgoff_t offset; | ||
218 | |||
219 | spin_lock(&swap_lock); | ||
220 | si = swap_info + type; | ||
221 | if (si->flags & SWP_WRITEOK) { | ||
222 | nr_swap_pages--; | ||
223 | offset = scan_swap_map(si); | ||
224 | if (offset) { | ||
225 | spin_unlock(&swap_lock); | ||
226 | return swp_entry(type, offset); | ||
227 | } | ||
228 | nr_swap_pages++; | ||
229 | } | ||
230 | spin_unlock(&swap_lock); | ||
231 | return (swp_entry_t) {0}; | ||
232 | } | ||
233 | |||
214 | static struct swap_info_struct * swap_info_get(swp_entry_t entry) | 234 | static struct swap_info_struct * swap_info_get(swp_entry_t entry) |
215 | { | 235 | { |
216 | struct swap_info_struct * p; | 236 | struct swap_info_struct * p; |