aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2006-01-06 03:16:37 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-06 11:33:43 -0500
commit3a291a20bd6fcfafb2109031f0760a0d3e92ecd7 (patch)
tree6c034471da9b2aac77b9810af640bb7a515cb299 /mm
parentca0aec0f7a94bf9f07fefa8bfd23282d4e8ceb8a (diff)
[PATCH] mm: add a new function (needed for swap suspend)
This adds the function get_swap_page_of_type() allowing us to specify an index in swap_info[] and select a swap_info_struct structure to be used for allocating a swap page. This function (or another one of similar functionality) will be necessary for implementing the image-writing part of swsusp in the user space.  It can also be used for simplifying the current in-kernel implementation of the image-writing part of swsusp. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/swapfile.c20
1 files changed, 20 insertions, 0 deletions
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
214swp_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
214static struct swap_info_struct * swap_info_get(swp_entry_t entry) 234static 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;