diff options
Diffstat (limited to 'block/genhd.c')
-rw-r--r-- | block/genhd.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/block/genhd.c b/block/genhd.c index db57546a709d..64510fd88621 100644 --- a/block/genhd.c +++ b/block/genhd.c | |||
@@ -15,12 +15,13 @@ | |||
15 | #include <linux/kmod.h> | 15 | #include <linux/kmod.h> |
16 | #include <linux/kobj_map.h> | 16 | #include <linux/kobj_map.h> |
17 | #include <linux/buffer_head.h> | 17 | #include <linux/buffer_head.h> |
18 | #include <linux/mutex.h> | ||
18 | 19 | ||
19 | #define MAX_PROBE_HASH 255 /* random */ | 20 | #define MAX_PROBE_HASH 255 /* random */ |
20 | 21 | ||
21 | static struct subsystem block_subsys; | 22 | static struct subsystem block_subsys; |
22 | 23 | ||
23 | static DECLARE_MUTEX(block_subsys_sem); | 24 | static DEFINE_MUTEX(block_subsys_lock); |
24 | 25 | ||
25 | /* | 26 | /* |
26 | * Can be deleted altogether. Later. | 27 | * Can be deleted altogether. Later. |
@@ -46,7 +47,7 @@ struct blkdev_info { | |||
46 | /* | 47 | /* |
47 | * iterate over a list of blkdev_info structures. allows | 48 | * iterate over a list of blkdev_info structures. allows |
48 | * the major_names array to be iterated over from outside this file | 49 | * the major_names array to be iterated over from outside this file |
49 | * must be called with the block_subsys_sem held | 50 | * must be called with the block_subsys_lock held |
50 | */ | 51 | */ |
51 | void *get_next_blkdev(void *dev) | 52 | void *get_next_blkdev(void *dev) |
52 | { | 53 | { |
@@ -85,20 +86,20 @@ out: | |||
85 | 86 | ||
86 | void *acquire_blkdev_list(void) | 87 | void *acquire_blkdev_list(void) |
87 | { | 88 | { |
88 | down(&block_subsys_sem); | 89 | mutex_lock(&block_subsys_lock); |
89 | return get_next_blkdev(NULL); | 90 | return get_next_blkdev(NULL); |
90 | } | 91 | } |
91 | 92 | ||
92 | void release_blkdev_list(void *dev) | 93 | void release_blkdev_list(void *dev) |
93 | { | 94 | { |
94 | up(&block_subsys_sem); | 95 | mutex_unlock(&block_subsys_lock); |
95 | kfree(dev); | 96 | kfree(dev); |
96 | } | 97 | } |
97 | 98 | ||
98 | 99 | ||
99 | /* | 100 | /* |
100 | * Count the number of records in the blkdev_list. | 101 | * Count the number of records in the blkdev_list. |
101 | * must be called with the block_subsys_sem held | 102 | * must be called with the block_subsys_lock held |
102 | */ | 103 | */ |
103 | int count_blkdev_list(void) | 104 | int count_blkdev_list(void) |
104 | { | 105 | { |
@@ -118,7 +119,7 @@ int count_blkdev_list(void) | |||
118 | /* | 119 | /* |
119 | * extract the major and name values from a blkdev_info struct | 120 | * extract the major and name values from a blkdev_info struct |
120 | * passed in as a void to *dev. Must be called with | 121 | * passed in as a void to *dev. Must be called with |
121 | * block_subsys_sem held | 122 | * block_subsys_lock held |
122 | */ | 123 | */ |
123 | int get_blkdev_info(void *dev, int *major, char **name) | 124 | int get_blkdev_info(void *dev, int *major, char **name) |
124 | { | 125 | { |
@@ -138,7 +139,7 @@ int register_blkdev(unsigned int major, const char *name) | |||
138 | struct blk_major_name **n, *p; | 139 | struct blk_major_name **n, *p; |
139 | int index, ret = 0; | 140 | int index, ret = 0; |
140 | 141 | ||
141 | down(&block_subsys_sem); | 142 | mutex_lock(&block_subsys_lock); |
142 | 143 | ||
143 | /* temporary */ | 144 | /* temporary */ |
144 | if (major == 0) { | 145 | if (major == 0) { |
@@ -183,7 +184,7 @@ int register_blkdev(unsigned int major, const char *name) | |||
183 | kfree(p); | 184 | kfree(p); |
184 | } | 185 | } |
185 | out: | 186 | out: |
186 | up(&block_subsys_sem); | 187 | mutex_unlock(&block_subsys_lock); |
187 | return ret; | 188 | return ret; |
188 | } | 189 | } |
189 | 190 | ||
@@ -197,7 +198,7 @@ int unregister_blkdev(unsigned int major, const char *name) | |||
197 | int index = major_to_index(major); | 198 | int index = major_to_index(major); |
198 | int ret = 0; | 199 | int ret = 0; |
199 | 200 | ||
200 | down(&block_subsys_sem); | 201 | mutex_lock(&block_subsys_lock); |
201 | for (n = &major_names[index]; *n; n = &(*n)->next) | 202 | for (n = &major_names[index]; *n; n = &(*n)->next) |
202 | if ((*n)->major == major) | 203 | if ((*n)->major == major) |
203 | break; | 204 | break; |
@@ -207,7 +208,7 @@ int unregister_blkdev(unsigned int major, const char *name) | |||
207 | p = *n; | 208 | p = *n; |
208 | *n = p->next; | 209 | *n = p->next; |
209 | } | 210 | } |
210 | up(&block_subsys_sem); | 211 | mutex_unlock(&block_subsys_lock); |
211 | kfree(p); | 212 | kfree(p); |
212 | 213 | ||
213 | return ret; | 214 | return ret; |
@@ -301,7 +302,7 @@ static void *part_start(struct seq_file *part, loff_t *pos) | |||
301 | struct list_head *p; | 302 | struct list_head *p; |
302 | loff_t l = *pos; | 303 | loff_t l = *pos; |
303 | 304 | ||
304 | down(&block_subsys_sem); | 305 | mutex_lock(&block_subsys_lock); |
305 | list_for_each(p, &block_subsys.kset.list) | 306 | list_for_each(p, &block_subsys.kset.list) |
306 | if (!l--) | 307 | if (!l--) |
307 | return list_entry(p, struct gendisk, kobj.entry); | 308 | return list_entry(p, struct gendisk, kobj.entry); |
@@ -318,7 +319,7 @@ static void *part_next(struct seq_file *part, void *v, loff_t *pos) | |||
318 | 319 | ||
319 | static void part_stop(struct seq_file *part, void *v) | 320 | static void part_stop(struct seq_file *part, void *v) |
320 | { | 321 | { |
321 | up(&block_subsys_sem); | 322 | mutex_unlock(&block_subsys_lock); |
322 | } | 323 | } |
323 | 324 | ||
324 | static int show_partition(struct seq_file *part, void *v) | 325 | static int show_partition(struct seq_file *part, void *v) |
@@ -377,7 +378,7 @@ static struct kobject *base_probe(dev_t dev, int *part, void *data) | |||
377 | 378 | ||
378 | static int __init genhd_device_init(void) | 379 | static int __init genhd_device_init(void) |
379 | { | 380 | { |
380 | bdev_map = kobj_map_init(base_probe, &block_subsys_sem); | 381 | bdev_map = kobj_map_init(base_probe, &block_subsys_lock); |
381 | blk_dev_init(); | 382 | blk_dev_init(); |
382 | subsystem_register(&block_subsys); | 383 | subsystem_register(&block_subsys); |
383 | return 0; | 384 | return 0; |
@@ -611,7 +612,7 @@ static void *diskstats_start(struct seq_file *part, loff_t *pos) | |||
611 | loff_t k = *pos; | 612 | loff_t k = *pos; |
612 | struct list_head *p; | 613 | struct list_head *p; |
613 | 614 | ||
614 | down(&block_subsys_sem); | 615 | mutex_lock(&block_subsys_lock); |
615 | list_for_each(p, &block_subsys.kset.list) | 616 | list_for_each(p, &block_subsys.kset.list) |
616 | if (!k--) | 617 | if (!k--) |
617 | return list_entry(p, struct gendisk, kobj.entry); | 618 | return list_entry(p, struct gendisk, kobj.entry); |
@@ -628,7 +629,7 @@ static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos) | |||
628 | 629 | ||
629 | static void diskstats_stop(struct seq_file *part, void *v) | 630 | static void diskstats_stop(struct seq_file *part, void *v) |
630 | { | 631 | { |
631 | up(&block_subsys_sem); | 632 | mutex_unlock(&block_subsys_lock); |
632 | } | 633 | } |
633 | 634 | ||
634 | static int diskstats_show(struct seq_file *s, void *v) | 635 | static int diskstats_show(struct seq_file *s, void *v) |