diff options
author | Lee Schermerhorn <Lee.Schermerhorn@hp.com> | 2009-12-14 20:58:49 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-15 11:53:16 -0500 |
commit | d4906e1aa516cc965292b43b5a26122dd4344e7e (patch) | |
tree | 78c19149282e93200d90f380a40f1e1192354936 | |
parent | 7509765a29cfb1a4c506c09b304aaf3b4111c653 (diff) |
swap: rework map_swap_page() again
Seems that page_io.c doesn't really need to know that page_private(page)
is the swp_entry 'val'. Rework map_swap_page() to do what its name says
and map a page to a page offset in the swap space.
The only other caller of map_swap_page() is internal to mm/swapfile.c and
it does want to map a swap entry to the 'sector'. So rename
map_swap_page() to map_swap_entry(), make it 'static' and and implement
map_swap_page() as a wrapper around that.
Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com>
Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/swap.h | 2 | ||||
-rw-r--r-- | mm/page_io.c | 4 | ||||
-rw-r--r-- | mm/swapfile.c | 20 |
3 files changed, 18 insertions, 8 deletions
diff --git a/include/linux/swap.h b/include/linux/swap.h index 9f0ca325e30d..a2602a8207a6 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h | |||
@@ -325,7 +325,7 @@ extern void swapcache_free(swp_entry_t, struct page *page); | |||
325 | extern int free_swap_and_cache(swp_entry_t); | 325 | extern int free_swap_and_cache(swp_entry_t); |
326 | extern int swap_type_of(dev_t, sector_t, struct block_device **); | 326 | extern int swap_type_of(dev_t, sector_t, struct block_device **); |
327 | extern unsigned int count_swap_pages(int, int); | 327 | extern unsigned int count_swap_pages(int, int); |
328 | extern sector_t map_swap_page(swp_entry_t, struct block_device **); | 328 | extern sector_t map_swap_page(struct page *, struct block_device **); |
329 | extern sector_t swapdev_block(int, pgoff_t); | 329 | extern sector_t swapdev_block(int, pgoff_t); |
330 | extern int reuse_swap_page(struct page *); | 330 | extern int reuse_swap_page(struct page *); |
331 | extern int try_to_free_swap(struct page *); | 331 | extern int try_to_free_swap(struct page *); |
diff --git a/mm/page_io.c b/mm/page_io.c index afeed89a0a5d..a19af956ee1b 100644 --- a/mm/page_io.c +++ b/mm/page_io.c | |||
@@ -26,9 +26,7 @@ static struct bio *get_swap_bio(gfp_t gfp_flags, | |||
26 | 26 | ||
27 | bio = bio_alloc(gfp_flags, 1); | 27 | bio = bio_alloc(gfp_flags, 1); |
28 | if (bio) { | 28 | if (bio) { |
29 | swp_entry_t entry; | 29 | bio->bi_sector = map_swap_page(page, &bio->bi_bdev); |
30 | entry.val = page_private(page); | ||
31 | bio->bi_sector = map_swap_page(entry, &bio->bi_bdev); | ||
32 | bio->bi_sector <<= PAGE_SHIFT - 9; | 30 | bio->bi_sector <<= PAGE_SHIFT - 9; |
33 | bio->bi_io_vec[0].bv_page = page; | 31 | bio->bi_io_vec[0].bv_page = page; |
34 | bio->bi_io_vec[0].bv_len = PAGE_SIZE; | 32 | bio->bi_io_vec[0].bv_len = PAGE_SIZE; |
diff --git a/mm/swapfile.c b/mm/swapfile.c index 58bec6600167..d5eb2e85600b 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c | |||
@@ -38,6 +38,7 @@ | |||
38 | static bool swap_count_continued(struct swap_info_struct *, pgoff_t, | 38 | static bool swap_count_continued(struct swap_info_struct *, pgoff_t, |
39 | unsigned char); | 39 | unsigned char); |
40 | static void free_swap_count_continuations(struct swap_info_struct *); | 40 | static void free_swap_count_continuations(struct swap_info_struct *); |
41 | static sector_t map_swap_entry(swp_entry_t, struct block_device**); | ||
41 | 42 | ||
42 | static DEFINE_SPINLOCK(swap_lock); | 43 | static DEFINE_SPINLOCK(swap_lock); |
43 | static unsigned int nr_swapfiles; | 44 | static unsigned int nr_swapfiles; |
@@ -782,7 +783,7 @@ sector_t swapdev_block(int type, pgoff_t offset) | |||
782 | return 0; | 783 | return 0; |
783 | if (!(swap_info[type]->flags & SWP_WRITEOK)) | 784 | if (!(swap_info[type]->flags & SWP_WRITEOK)) |
784 | return 0; | 785 | return 0; |
785 | return map_swap_page(swp_entry(type, offset), &bdev); | 786 | return map_swap_entry(swp_entry(type, offset), &bdev); |
786 | } | 787 | } |
787 | 788 | ||
788 | /* | 789 | /* |
@@ -1249,10 +1250,11 @@ static void drain_mmlist(void) | |||
1249 | 1250 | ||
1250 | /* | 1251 | /* |
1251 | * Use this swapdev's extent info to locate the (PAGE_SIZE) block which | 1252 | * Use this swapdev's extent info to locate the (PAGE_SIZE) block which |
1252 | * corresponds to page offset `offset'. Note that the type of this function | 1253 | * corresponds to page offset for the specified swap entry. |
1253 | * is sector_t, but it returns page offset into the bdev, not sector offset. | 1254 | * Note that the type of this function is sector_t, but it returns page offset |
1255 | * into the bdev, not sector offset. | ||
1254 | */ | 1256 | */ |
1255 | sector_t map_swap_page(swp_entry_t entry, struct block_device **bdev) | 1257 | static sector_t map_swap_entry(swp_entry_t entry, struct block_device **bdev) |
1256 | { | 1258 | { |
1257 | struct swap_info_struct *sis; | 1259 | struct swap_info_struct *sis; |
1258 | struct swap_extent *start_se; | 1260 | struct swap_extent *start_se; |
@@ -1281,6 +1283,16 @@ sector_t map_swap_page(swp_entry_t entry, struct block_device **bdev) | |||
1281 | } | 1283 | } |
1282 | 1284 | ||
1283 | /* | 1285 | /* |
1286 | * Returns the page offset into bdev for the specified page's swap entry. | ||
1287 | */ | ||
1288 | sector_t map_swap_page(struct page *page, struct block_device **bdev) | ||
1289 | { | ||
1290 | swp_entry_t entry; | ||
1291 | entry.val = page_private(page); | ||
1292 | return map_swap_entry(entry, bdev); | ||
1293 | } | ||
1294 | |||
1295 | /* | ||
1284 | * Free all of a swapdev's extent information | 1296 | * Free all of a swapdev's extent information |
1285 | */ | 1297 | */ |
1286 | static void destroy_swap_extents(struct swap_info_struct *sis) | 1298 | static void destroy_swap_extents(struct swap_info_struct *sis) |