@@ -25,7 +25,6 @@
#include "blk.h"
-static DEFINE_MUTEX(block_class_lock);
static struct kobject *block_depr;
struct bdev_map {
@@ -37,6 +36,7 @@ struct bdev_map {
int (*lock)(dev_t, void *);
void *data;
} *bdev_map[255];
+static DEFINE_MUTEX(bdev_map_lock);
/* for extended dynamic devt allocation, currently only one major is used */
#define NR_EXT_DEVT (1 << MINORBITS)
@@ -403,6 +403,7 @@ static struct blk_major_name {
int major;
char name[16];
} *major_names[BLKDEV_MAJOR_HASH_SIZE];
+static DEFINE_MUTEX(major_names_lock);
/* index in the above - for now: assume no multimajor ranges */
static inline int major_to_index(unsigned major)
@@ -415,11 +416,11 @@ void blkdev_show(struct seq_file *seqf, off_t offset)
{
struct blk_major_name *dp;
- mutex_lock(&block_class_lock);
+ mutex_lock(&major_names_lock);
for (dp = major_names[major_to_index(offset)]; dp; dp = dp->next)
if (dp->major == offset)
seq_printf(seqf, "%3d %s\n", dp->major, dp->name);
- mutex_unlock(&block_class_lock);
+ mutex_unlock(&major_names_lock);
}
#endif /* CONFIG_PROC_FS */
@@ -448,7 +449,7 @@ int register_blkdev(unsigned int major, const char *name)
struct blk_major_name **n, *p;
int index, ret = 0;
- mutex_lock(&block_class_lock);
+ mutex_lock(&major_names_lock);
/* temporary */
if (major == 0) {
@@ -501,7 +502,7 @@ int register_blkdev(unsigned int major, const char *name)
kfree(p);
}
out:
- mutex_unlock(&block_class_lock);
+ mutex_unlock(&major_names_lock);
return ret;
}
@@ -513,7 +514,7 @@ void unregister_blkdev(unsigned int major, const char *name)
struct blk_major_name *p = NULL;
int index = major_to_index(major);
- mutex_lock(&block_class_lock);
+ mutex_lock(&major_names_lock);
for (n = &major_names[index]; *n; n = &(*n)->next)
if ((*n)->major == major)
break;
@@ -523,7 +524,7 @@ void unregister_blkdev(unsigned int major, const char *name)
p = *n;
*n = p->next;
}
- mutex_unlock(&block_class_lock);
+ mutex_unlock(&major_names_lock);
kfree(p);
}
@@ -674,7 +675,7 @@ void blk_register_region(dev_t devt, unsigned long range, struct module *module,
p->data = data;
}
- mutex_lock(&block_class_lock);
+ mutex_lock(&bdev_map_lock);
for (i = 0, p -= n; i < n; i++, p++, index++) {
struct bdev_map **s = &bdev_map[index % 255];
while (*s && (*s)->range < range)
@@ -682,7 +683,7 @@ void blk_register_region(dev_t devt, unsigned long range, struct module *module,
p->next = *s;
*s = p;
}
- mutex_unlock(&block_class_lock);
+ mutex_unlock(&bdev_map_lock);
}
EXPORT_SYMBOL(blk_register_region);
@@ -693,7 +694,7 @@ void blk_unregister_region(dev_t devt, unsigned long range)
unsigned i;
struct bdev_map *found = NULL;
- mutex_lock(&block_class_lock);
+ mutex_lock(&bdev_map_lock);
for (i = 0; i < min(n, 255u); i++, index++) {
struct bdev_map **s;
for (s = &bdev_map[index % 255]; *s; s = &(*s)->next) {
@@ -706,7 +707,7 @@ void blk_unregister_region(dev_t devt, unsigned long range)
}
}
}
- mutex_unlock(&block_class_lock);
+ mutex_unlock(&bdev_map_lock);
kfree(found);
}
EXPORT_SYMBOL(blk_unregister_region);
@@ -1041,7 +1042,7 @@ static struct gendisk *lookup_gendisk(dev_t dev, int *partno)
unsigned long best = ~0UL;
retry:
- mutex_lock(&block_class_lock);
+ mutex_lock(&bdev_map_lock);
for (p = bdev_map[MAJOR(dev) % 255]; p; p = p->next) {
struct kobject *(*probe)(dev_t, int *, void *);
struct module *owner;
@@ -1062,7 +1063,7 @@ static struct gendisk *lookup_gendisk(dev_t dev, int *partno)
module_put(owner);
continue;
}
- mutex_unlock(&block_class_lock);
+ mutex_unlock(&bdev_map_lock);
kobj = probe(dev, partno, data);
/* Currently ->owner protects _only_ ->probe() itself. */
module_put(owner);
@@ -1070,7 +1071,7 @@ static struct gendisk *lookup_gendisk(dev_t dev, int *partno)
return dev_to_disk(kobj_to_dev(kobj));
goto retry;
}
- mutex_unlock(&block_class_lock);
+ mutex_unlock(&bdev_map_lock);
return NULL;
}
Split the block_class_lock mutex into one each to protect bdev_map and major_names. Signed-off-by: Christoph Hellwig <hch@lst.de> --- block/genhd.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)