aboutsummaryrefslogtreecommitdiffstats
path: root/mm/swapfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r--mm/swapfile.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index f89af5ba2eb2..6ffc87602f4a 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1329,6 +1329,14 @@ static void destroy_swap_extents(struct swap_info_struct *sis)
1329 list_del(&se->list); 1329 list_del(&se->list);
1330 kfree(se); 1330 kfree(se);
1331 } 1331 }
1332
1333 if (sis->flags & SWP_FILE) {
1334 struct file *swap_file = sis->swap_file;
1335 struct address_space *mapping = swap_file->f_mapping;
1336
1337 sis->flags &= ~SWP_FILE;
1338 mapping->a_ops->swap_deactivate(swap_file);
1339 }
1332} 1340}
1333 1341
1334/* 1342/*
@@ -1410,7 +1418,9 @@ add_swap_extent(struct swap_info_struct *sis, unsigned long start_page,
1410 */ 1418 */
1411static int setup_swap_extents(struct swap_info_struct *sis, sector_t *span) 1419static int setup_swap_extents(struct swap_info_struct *sis, sector_t *span)
1412{ 1420{
1413 struct inode *inode; 1421 struct file *swap_file = sis->swap_file;
1422 struct address_space *mapping = swap_file->f_mapping;
1423 struct inode *inode = mapping->host;
1414 unsigned blocks_per_page; 1424 unsigned blocks_per_page;
1415 unsigned long page_no; 1425 unsigned long page_no;
1416 unsigned blkbits; 1426 unsigned blkbits;
@@ -1421,13 +1431,22 @@ static int setup_swap_extents(struct swap_info_struct *sis, sector_t *span)
1421 int nr_extents = 0; 1431 int nr_extents = 0;
1422 int ret; 1432 int ret;
1423 1433
1424 inode = sis->swap_file->f_mapping->host;
1425 if (S_ISBLK(inode->i_mode)) { 1434 if (S_ISBLK(inode->i_mode)) {
1426 ret = add_swap_extent(sis, 0, sis->max, 0); 1435 ret = add_swap_extent(sis, 0, sis->max, 0);
1427 *span = sis->pages; 1436 *span = sis->pages;
1428 goto out; 1437 goto out;
1429 } 1438 }
1430 1439
1440 if (mapping->a_ops->swap_activate) {
1441 ret = mapping->a_ops->swap_activate(swap_file);
1442 if (!ret) {
1443 sis->flags |= SWP_FILE;
1444 ret = add_swap_extent(sis, 0, sis->max, 0);
1445 *span = sis->pages;
1446 }
1447 goto out;
1448 }
1449
1431 blkbits = inode->i_blkbits; 1450 blkbits = inode->i_blkbits;
1432 blocks_per_page = PAGE_SIZE >> blkbits; 1451 blocks_per_page = PAGE_SIZE >> blkbits;
1433 1452