diff options
author | Cesar Eduardo Barros <cesarb@cesarb.net> | 2012-12-11 19:01:14 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-11 20:22:24 -0500 |
commit | 6555bc035731eab76c0901925034465d3ad2099c (patch) | |
tree | 69a3bd3525ad425204a91a6bbf07486789ae28bc /mm/swapfile.c | |
parent | cf0cac0a09341549dedabcfc2a66dcbc2eaaf2b9 (diff) |
mm: do not call frontswap_init() during swapoff
The call to frontswap_init() was added within enable_swap_info(), which
was called not only during sys_swapon, but also to reinsert the swap_info
into the swap_list in case of failure of try_to_unuse() within
sys_swapoff. This means that frontswap_init() might be called more than
once for the same swap area.
While as far as I could see no frontswap implementation has any problem
with it (and in fact, all the ones I found ignore the parameter passed to
frontswap_init), this could change in the future.
To prevent future problems, move the call to frontswap_init() to outside
the code shared between sys_swapon and sys_swapoff.
Signed-off-by: Cesar Eduardo Barros <cesarb@cesarb.net>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Dan Magenheimer <dan.magenheimer@oracle.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Rik van Riel <riel@redhat.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Hugh Dickins <hughd@google.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.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c index 27a52b731576..0fbb45283c66 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c | |||
@@ -1471,7 +1471,6 @@ static void _enable_swap_info(struct swap_info_struct *p, int prio, | |||
1471 | swap_list.head = swap_list.next = p->type; | 1471 | swap_list.head = swap_list.next = p->type; |
1472 | else | 1472 | else |
1473 | swap_info[prev]->next = p->type; | 1473 | swap_info[prev]->next = p->type; |
1474 | frontswap_init(p->type); | ||
1475 | } | 1474 | } |
1476 | 1475 | ||
1477 | static void enable_swap_info(struct swap_info_struct *p, int prio, | 1476 | static void enable_swap_info(struct swap_info_struct *p, int prio, |
@@ -1480,6 +1479,7 @@ static void enable_swap_info(struct swap_info_struct *p, int prio, | |||
1480 | { | 1479 | { |
1481 | spin_lock(&swap_lock); | 1480 | spin_lock(&swap_lock); |
1482 | _enable_swap_info(p, prio, swap_map, frontswap_map); | 1481 | _enable_swap_info(p, prio, swap_map, frontswap_map); |
1482 | frontswap_init(p->type); | ||
1483 | spin_unlock(&swap_lock); | 1483 | spin_unlock(&swap_lock); |
1484 | } | 1484 | } |
1485 | 1485 | ||