sys_swapon's call to destroy_swap_extents on failure is made after the final
swap_list_unlock, which is faintly unsafe: another sys_swapon might already be
setting up that swap_info_struct. Calling it earlier, before taking
swap_list_lock, is safe. sys_swapoff's call to destroy_swap_extents was safe,
but likewise move it earlier, before taking the locks (once try_to_unuse has
completed, nothing can be needing the swap extents).
Signed-off-by: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
swap_list_unlock();
goto out_dput;
}
+ destroy_swap_extents(p);
down(&swapon_sem);
swap_list_lock();
drain_mmlist();
swap_map = p->swap_map;
p->swap_map = NULL;
p->flags = 0;
- destroy_swap_extents(p);
swap_device_unlock(p);
swap_list_unlock();
up(&swapon_sem);
set_blocksize(bdev, p->old_block_size);
bd_release(bdev);
}
+ destroy_swap_extents(p);
bad_swap_2:
swap_list_lock();
swap_map = p->swap_map;
if (!(swap_flags & SWAP_FLAG_PREFER))
++least_priority;
swap_list_unlock();
- destroy_swap_extents(p);
vfree(swap_map);
if (swap_file)
filp_close(swap_file, NULL);