[PATCH] swsusp: use block device offsets to identify swap locations

Make swsusp use block device offsets instead of swap offsets to identify swap
locations and make it use the same code paths for writing as well as for
reading data.

This allows us to use the same code for handling swap files and swap
partitions and to simplify the code, eg.  by dropping rw_swap_page_sync().

Signed-off-by: Rafael J. Wysocki <[email protected]>
Cc: Pavel Machek <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
Rafael J. Wysocki 2006-12-06 20:34:10 -08:00 • committed by Linus Torvalds
commit 3aef83e0ef
7 changed files with 98 additions and 119 deletions

View file

@ -945,6 +945,23 @@ sector_t map_swap_page(struct swap_info_struct *sis, pgoff_t offset)
}
}
#ifdef CONFIG_SOFTWARE_SUSPEND
/*
* Get the (PAGE_SIZE) block corresponding to given offset on the swapdev
* corresponding to given index in swap_info (swap type).
*/
sector_t swapdev_block(int swap_type, pgoff_t offset)
{
struct swap_info_struct *sis;
if (swap_type >= nr_swapfiles)
return 0;
sis = swap_info + swap_type;
return (sis->flags & SWP_WRITEOK) ? map_swap_page(sis, offset) : 0;
}
#endif /* CONFIG_SOFTWARE_SUSPEND */
/*
* Free all of a swapdev's extent information
*/