diff options
author | Ingo Molnar <mingo@elte.hu> | 2006-01-18 20:42:33 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-18 22:20:18 -0500 |
commit | fc0abb1451c64c79ac80665d5ba74450ce274e4d (patch) | |
tree | 30301b6134b122a638104645bd6bd4b45014dd2c /mm/swapfile.c | |
parent | 1743660b911bfb849b1fb33830522254561b9f9b (diff) |
[PATCH] sem2mutex: mm/slab.c
Convert mm/swapfile.c's swapon_sem to swapon_mutex.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Cc: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm/swapfile.c')
-rw-r--r-- | mm/swapfile.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c index 957fef43fa60..f1e69c30d203 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/rmap.h> | 25 | #include <linux/rmap.h> |
26 | #include <linux/security.h> | 26 | #include <linux/security.h> |
27 | #include <linux/backing-dev.h> | 27 | #include <linux/backing-dev.h> |
28 | #include <linux/mutex.h> | ||
28 | #include <linux/capability.h> | 29 | #include <linux/capability.h> |
29 | #include <linux/syscalls.h> | 30 | #include <linux/syscalls.h> |
30 | 31 | ||
@@ -46,12 +47,12 @@ struct swap_list_t swap_list = {-1, -1}; | |||
46 | 47 | ||
47 | struct swap_info_struct swap_info[MAX_SWAPFILES]; | 48 | struct swap_info_struct swap_info[MAX_SWAPFILES]; |
48 | 49 | ||
49 | static DECLARE_MUTEX(swapon_sem); | 50 | static DEFINE_MUTEX(swapon_mutex); |
50 | 51 | ||
51 | /* | 52 | /* |
52 | * We need this because the bdev->unplug_fn can sleep and we cannot | 53 | * We need this because the bdev->unplug_fn can sleep and we cannot |
53 | * hold swap_lock while calling the unplug_fn. And swap_lock | 54 | * hold swap_lock while calling the unplug_fn. And swap_lock |
54 | * cannot be turned into a semaphore. | 55 | * cannot be turned into a mutex. |
55 | */ | 56 | */ |
56 | static DECLARE_RWSEM(swap_unplug_sem); | 57 | static DECLARE_RWSEM(swap_unplug_sem); |
57 | 58 | ||
@@ -1161,7 +1162,7 @@ asmlinkage long sys_swapoff(const char __user * specialfile) | |||
1161 | up_write(&swap_unplug_sem); | 1162 | up_write(&swap_unplug_sem); |
1162 | 1163 | ||
1163 | destroy_swap_extents(p); | 1164 | destroy_swap_extents(p); |
1164 | down(&swapon_sem); | 1165 | mutex_lock(&swapon_mutex); |
1165 | spin_lock(&swap_lock); | 1166 | spin_lock(&swap_lock); |
1166 | drain_mmlist(); | 1167 | drain_mmlist(); |
1167 | 1168 | ||
@@ -1180,7 +1181,7 @@ asmlinkage long sys_swapoff(const char __user * specialfile) | |||
1180 | p->swap_map = NULL; | 1181 | p->swap_map = NULL; |
1181 | p->flags = 0; | 1182 | p->flags = 0; |
1182 | spin_unlock(&swap_lock); | 1183 | spin_unlock(&swap_lock); |
1183 | up(&swapon_sem); | 1184 | mutex_unlock(&swapon_mutex); |
1184 | vfree(swap_map); | 1185 | vfree(swap_map); |
1185 | inode = mapping->host; | 1186 | inode = mapping->host; |
1186 | if (S_ISBLK(inode->i_mode)) { | 1187 | if (S_ISBLK(inode->i_mode)) { |
@@ -1209,7 +1210,7 @@ static void *swap_start(struct seq_file *swap, loff_t *pos) | |||
1209 | int i; | 1210 | int i; |
1210 | loff_t l = *pos; | 1211 | loff_t l = *pos; |
1211 | 1212 | ||
1212 | down(&swapon_sem); | 1213 | mutex_lock(&swapon_mutex); |
1213 | 1214 | ||
1214 | for (i = 0; i < nr_swapfiles; i++, ptr++) { | 1215 | for (i = 0; i < nr_swapfiles; i++, ptr++) { |
1215 | if (!(ptr->flags & SWP_USED) || !ptr->swap_map) | 1216 | if (!(ptr->flags & SWP_USED) || !ptr->swap_map) |
@@ -1238,7 +1239,7 @@ static void *swap_next(struct seq_file *swap, void *v, loff_t *pos) | |||
1238 | 1239 | ||
1239 | static void swap_stop(struct seq_file *swap, void *v) | 1240 | static void swap_stop(struct seq_file *swap, void *v) |
1240 | { | 1241 | { |
1241 | up(&swapon_sem); | 1242 | mutex_unlock(&swapon_mutex); |
1242 | } | 1243 | } |
1243 | 1244 | ||
1244 | static int swap_show(struct seq_file *swap, void *v) | 1245 | static int swap_show(struct seq_file *swap, void *v) |
@@ -1540,7 +1541,7 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags) | |||
1540 | goto bad_swap; | 1541 | goto bad_swap; |
1541 | } | 1542 | } |
1542 | 1543 | ||
1543 | down(&swapon_sem); | 1544 | mutex_lock(&swapon_mutex); |
1544 | spin_lock(&swap_lock); | 1545 | spin_lock(&swap_lock); |
1545 | p->flags = SWP_ACTIVE; | 1546 | p->flags = SWP_ACTIVE; |
1546 | nr_swap_pages += nr_good_pages; | 1547 | nr_swap_pages += nr_good_pages; |
@@ -1566,7 +1567,7 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags) | |||
1566 | swap_info[prev].next = p - swap_info; | 1567 | swap_info[prev].next = p - swap_info; |
1567 | } | 1568 | } |
1568 | spin_unlock(&swap_lock); | 1569 | spin_unlock(&swap_lock); |
1569 | up(&swapon_sem); | 1570 | mutex_unlock(&swapon_mutex); |
1570 | error = 0; | 1571 | error = 0; |
1571 | goto out; | 1572 | goto out; |
1572 | bad_swap: | 1573 | bad_swap: |