diff options
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r-- | mm/swapfile.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c index ddc6d92be2cb..1e7a715a3866 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <asm/pgtable.h> | 33 | #include <asm/pgtable.h> |
34 | #include <asm/tlbflush.h> | 34 | #include <asm/tlbflush.h> |
35 | #include <linux/swapops.h> | 35 | #include <linux/swapops.h> |
36 | #include <linux/page_cgroup.h> | ||
36 | 37 | ||
37 | static DEFINE_SPINLOCK(swap_lock); | 38 | static DEFINE_SPINLOCK(swap_lock); |
38 | static unsigned int nr_swapfiles; | 39 | static unsigned int nr_swapfiles; |
@@ -1494,6 +1495,9 @@ asmlinkage long sys_swapoff(const char __user * specialfile) | |||
1494 | spin_unlock(&swap_lock); | 1495 | spin_unlock(&swap_lock); |
1495 | mutex_unlock(&swapon_mutex); | 1496 | mutex_unlock(&swapon_mutex); |
1496 | vfree(swap_map); | 1497 | vfree(swap_map); |
1498 | /* Destroy swap account informatin */ | ||
1499 | swap_cgroup_swapoff(type); | ||
1500 | |||
1497 | inode = mapping->host; | 1501 | inode = mapping->host; |
1498 | if (S_ISBLK(inode->i_mode)) { | 1502 | if (S_ISBLK(inode->i_mode)) { |
1499 | struct block_device *bdev = I_BDEV(inode); | 1503 | struct block_device *bdev = I_BDEV(inode); |
@@ -1811,6 +1815,11 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags) | |||
1811 | } | 1815 | } |
1812 | swap_map[page_nr] = SWAP_MAP_BAD; | 1816 | swap_map[page_nr] = SWAP_MAP_BAD; |
1813 | } | 1817 | } |
1818 | |||
1819 | error = swap_cgroup_swapon(type, maxpages); | ||
1820 | if (error) | ||
1821 | goto bad_swap; | ||
1822 | |||
1814 | nr_good_pages = swap_header->info.last_page - | 1823 | nr_good_pages = swap_header->info.last_page - |
1815 | swap_header->info.nr_badpages - | 1824 | swap_header->info.nr_badpages - |
1816 | 1 /* header page */; | 1825 | 1 /* header page */; |
@@ -1882,6 +1891,7 @@ bad_swap: | |||
1882 | bd_release(bdev); | 1891 | bd_release(bdev); |
1883 | } | 1892 | } |
1884 | destroy_swap_extents(p); | 1893 | destroy_swap_extents(p); |
1894 | swap_cgroup_swapoff(type); | ||
1885 | bad_swap_2: | 1895 | bad_swap_2: |
1886 | spin_lock(&swap_lock); | 1896 | spin_lock(&swap_lock); |
1887 | p->swap_file = NULL; | 1897 | p->swap_file = NULL; |