aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
Diffstat (limited to 'mm')
-rw-r--r--mm/swapfile.c51
1 files changed, 24 insertions, 27 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 16de84b56644..fa5f10b9c28b 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -519,9 +519,9 @@ swp_entry_t get_swap_page_of_type(int type)
519 return (swp_entry_t) {0}; 519 return (swp_entry_t) {0};
520} 520}
521 521
522static struct swap_info_struct * swap_info_get(swp_entry_t entry) 522static struct swap_info_struct *swap_info_get(swp_entry_t entry)
523{ 523{
524 struct swap_info_struct * p; 524 struct swap_info_struct *p;
525 unsigned long offset, type; 525 unsigned long offset, type;
526 526
527 if (!entry.val) 527 if (!entry.val)
@@ -599,7 +599,7 @@ static int swap_entry_free(struct swap_info_struct *p,
599 */ 599 */
600void swap_free(swp_entry_t entry) 600void swap_free(swp_entry_t entry)
601{ 601{
602 struct swap_info_struct * p; 602 struct swap_info_struct *p;
603 603
604 p = swap_info_get(entry); 604 p = swap_info_get(entry);
605 if (p) { 605 if (p) {
@@ -629,7 +629,6 @@ void swapcache_free(swp_entry_t entry, struct page *page)
629 } 629 }
630 spin_unlock(&swap_lock); 630 spin_unlock(&swap_lock);
631 } 631 }
632 return;
633} 632}
634 633
635/* 634/*
@@ -783,6 +782,21 @@ int swap_type_of(dev_t device, sector_t offset, struct block_device **bdev_p)
783} 782}
784 783
785/* 784/*
785 * Get the (PAGE_SIZE) block corresponding to given offset on the swapdev
786 * corresponding to given index in swap_info (swap type).
787 */
788sector_t swapdev_block(int type, pgoff_t offset)
789{
790 struct block_device *bdev;
791
792 if ((unsigned int)type >= nr_swapfiles)
793 return 0;
794 if (!(swap_info[type]->flags & SWP_WRITEOK))
795 return 0;
796 return map_swap_page(swp_entry(type, offset), &bdev);
797}
798
799/*
786 * Return either the total number of swap pages of given type, or the number 800 * Return either the total number of swap pages of given type, or the number
787 * of free pages of that type (depending on @free) 801 * of free pages of that type (depending on @free)
788 * 802 *
@@ -805,7 +819,7 @@ unsigned int count_swap_pages(int type, int free)
805 spin_unlock(&swap_lock); 819 spin_unlock(&swap_lock);
806 return n; 820 return n;
807} 821}
808#endif 822#endif /* CONFIG_HIBERNATION */
809 823
810/* 824/*
811 * No need to decide whether this PTE shares the swap entry with others, 825 * No need to decide whether this PTE shares the swap entry with others,
@@ -1316,23 +1330,6 @@ sector_t map_swap_page(swp_entry_t entry, struct block_device **bdev)
1316 } 1330 }
1317} 1331}
1318 1332
1319#ifdef CONFIG_HIBERNATION
1320/*
1321 * Get the (PAGE_SIZE) block corresponding to given offset on the swapdev
1322 * corresponding to given index in swap_info (swap type).
1323 */
1324sector_t swapdev_block(int type, pgoff_t offset)
1325{
1326 struct block_device *bdev;
1327
1328 if ((unsigned int)type >= nr_swapfiles)
1329 return 0;
1330 if (!(swap_info[type]->flags & SWP_WRITEOK))
1331 return 0;
1332 return map_swap_page(swp_entry(type, offset), &bdev);
1333}
1334#endif /* CONFIG_HIBERNATION */
1335
1336/* 1333/*
1337 * Free all of a swapdev's extent information 1334 * Free all of a swapdev's extent information
1338 */ 1335 */
@@ -1523,12 +1520,12 @@ bad_bmap:
1523 1520
1524SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) 1521SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
1525{ 1522{
1526 struct swap_info_struct * p = NULL; 1523 struct swap_info_struct *p = NULL;
1527 unsigned short *swap_map; 1524 unsigned short *swap_map;
1528 struct file *swap_file, *victim; 1525 struct file *swap_file, *victim;
1529 struct address_space *mapping; 1526 struct address_space *mapping;
1530 struct inode *inode; 1527 struct inode *inode;
1531 char * pathname; 1528 char *pathname;
1532 int i, type, prev; 1529 int i, type, prev;
1533 int err; 1530 int err;
1534 1531
@@ -1780,7 +1777,7 @@ late_initcall(max_swapfiles_check);
1780 */ 1777 */
1781SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) 1778SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
1782{ 1779{
1783 struct swap_info_struct * p; 1780 struct swap_info_struct *p;
1784 char *name = NULL; 1781 char *name = NULL;
1785 struct block_device *bdev = NULL; 1782 struct block_device *bdev = NULL;
1786 struct file *swap_file = NULL; 1783 struct file *swap_file = NULL;
@@ -2116,7 +2113,7 @@ void si_swapinfo(struct sysinfo *val)
2116 */ 2113 */
2117static int __swap_duplicate(swp_entry_t entry, bool cache) 2114static int __swap_duplicate(swp_entry_t entry, bool cache)
2118{ 2115{
2119 struct swap_info_struct * p; 2116 struct swap_info_struct *p;
2120 unsigned long offset, type; 2117 unsigned long offset, type;
2121 int result = -EINVAL; 2118 int result = -EINVAL;
2122 int count; 2119 int count;
@@ -2185,7 +2182,7 @@ void swap_duplicate(swp_entry_t entry)
2185/* 2182/*
2186 * @entry: swap entry for which we allocate swap cache. 2183 * @entry: swap entry for which we allocate swap cache.
2187 * 2184 *
2188 * Called when allocating swap cache for exising swap entry, 2185 * Called when allocating swap cache for existing swap entry,
2189 * This can return error codes. Returns 0 at success. 2186 * This can return error codes. Returns 0 at success.
2190 * -EBUSY means there is a swap cache. 2187 * -EBUSY means there is a swap cache.
2191 * Note: return code is different from swap_duplicate(). 2188 * Note: return code is different from swap_duplicate().