mm: do not call frontswap_init() during swapoff
authorCesar Eduardo Barros <>
Wed, 12 Dec 2012 00:01:14 +0000 (16:01 -0800)
committerLinus Torvalds <>
Wed, 12 Dec 2012 01:22:24 +0000 (17:22 -0800)
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 <>
Cc: Konrad Rzeszutek Wilk <>
Acked-by: Dan Magenheimer <>
Cc: Mel Gorman <>
Cc: Rik van Riel <>
Cc: KAMEZAWA Hiroyuki <>
Cc: Johannes Weiner <>
Cc: Hugh Dickins <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>

index 27a52b731576366ff61d00b1c81a3449cd0612e1..0fbb45283c6641cf1bdb8b5a39b4c9eb414f61f7 100644 (file)
@@ -1471,7 +1471,6 @@ static void _enable_swap_info(struct swap_info_struct *p, int prio,
                swap_list.head = = p->type;
                swap_info[prev]->next = p->type;
-       frontswap_init(p->type);
 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,
        _enable_swap_info(p, prio, swap_map, frontswap_map);
+       frontswap_init(p->type);