aboutsummaryrefslogtreecommitdiffstats
path: root/mm/swapfile.c
diff options
context:
space:
mode:
authorHugh Dickins <hugh.dickins@tiscali.co.uk>2009-12-14 20:58:40 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-15 11:53:13 -0500
commitf29ad6a99b596b8169744d107bf088e8be9e8d0d (patch)
treee138bf9eeb751defd358eb5aca8113e2645ded3d /mm/swapfile.c
parent976d6dfbb0175d136fc098854bbce0c028a3924b (diff)
swap_info: private to swapfile.c
The swap_info_struct is mostly private to mm/swapfile.c, with only one other in-tree user: get_swap_bio(). Adjust its interface to map_swap_page(), so that we can then remove get_swap_info_struct(). But there is a popular user out-of-tree, TuxOnIce: so leave the declaration of swap_info_struct in linux/swap.h. Signed-off-by: Hugh Dickins <hugh.dickins@tiscali.co.uk> Cc: Nigel Cunningham <ncunningham@crca.org.au> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Reviewed-by: Rik van Riel <riel@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r--mm/swapfile.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 9c590eef7912..f83f1c6f6196 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1283,12 +1283,22 @@ static void drain_mmlist(void)
1283 1283
1284/* 1284/*
1285 * Use this swapdev's extent info to locate the (PAGE_SIZE) block which 1285 * Use this swapdev's extent info to locate the (PAGE_SIZE) block which
1286 * corresponds to page offset `offset'. 1286 * corresponds to page offset `offset'. Note that the type of this function
1287 * is sector_t, but it returns page offset into the bdev, not sector offset.
1287 */ 1288 */
1288sector_t map_swap_page(struct swap_info_struct *sis, pgoff_t offset) 1289sector_t map_swap_page(swp_entry_t entry, struct block_device **bdev)
1289{ 1290{
1290 struct swap_extent *se = sis->curr_swap_extent; 1291 struct swap_info_struct *sis;
1291 struct swap_extent *start_se = se; 1292 struct swap_extent *start_se;
1293 struct swap_extent *se;
1294 pgoff_t offset;
1295
1296 sis = swap_info + swp_type(entry);
1297 *bdev = sis->bdev;
1298
1299 offset = swp_offset(entry);
1300 start_se = sis->curr_swap_extent;
1301 se = start_se;
1292 1302
1293 for ( ; ; ) { 1303 for ( ; ; ) {
1294 struct list_head *lh; 1304 struct list_head *lh;
@@ -1314,12 +1324,14 @@ sector_t map_swap_page(struct swap_info_struct *sis, pgoff_t offset)
1314sector_t swapdev_block(int swap_type, pgoff_t offset) 1324sector_t swapdev_block(int swap_type, pgoff_t offset)
1315{ 1325{
1316 struct swap_info_struct *sis; 1326 struct swap_info_struct *sis;
1327 struct block_device *bdev;
1317 1328
1318 if (swap_type >= nr_swapfiles) 1329 if (swap_type >= nr_swapfiles)
1319 return 0; 1330 return 0;
1320 1331
1321 sis = swap_info + swap_type; 1332 sis = swap_info + swap_type;
1322 return (sis->flags & SWP_WRITEOK) ? map_swap_page(sis, offset) : 0; 1333 return (sis->flags & SWP_WRITEOK) ?
1334 map_swap_page(swp_entry(swap_type, offset), &bdev) : 0;
1323} 1335}
1324#endif /* CONFIG_HIBERNATION */ 1336#endif /* CONFIG_HIBERNATION */
1325 1337
@@ -2159,13 +2171,6 @@ int swapcache_prepare(swp_entry_t entry)
2159 return __swap_duplicate(entry, SWAP_CACHE); 2171 return __swap_duplicate(entry, SWAP_CACHE);
2160} 2172}
2161 2173
2162
2163struct swap_info_struct *
2164get_swap_info_struct(unsigned type)
2165{
2166 return &swap_info[type];
2167}
2168
2169/* 2174/*
2170 * swap_lock prevents swap_map being freed. Don't grab an extra 2175 * swap_lock prevents swap_map being freed. Don't grab an extra
2171 * reference on the swaphandle, it doesn't matter if it becomes unused. 2176 * reference on the swaphandle, it doesn't matter if it becomes unused.