block: don't grab block_class_lock unnecessarily
block_class_lock protects major_names array and bdev_map and doesn't
have anything to do with block class devices. Don't grab them while
iterating over block class devices.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/block/genhd.c b/block/genhd.c
index 0be9513..9eb8b3e 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -283,9 +283,7 @@
*/
void __init printk_all_partitions(void)
{
- mutex_lock(&block_class_lock);
class_for_each_device(&block_class, NULL, NULL, printk_partition);
- mutex_unlock(&block_class_lock);
}
#ifdef CONFIG_PROC_FS
@@ -305,17 +303,15 @@
static void *part_start(struct seq_file *part, loff_t *pos)
{
struct device *dev;
- loff_t k = *pos;
+ loff_t n = *pos;
- if (!k)
+ if (!n)
part->private = (void *)1LU; /* tell show to print header */
- mutex_lock(&block_class_lock);
- dev = class_find_device(&block_class, NULL, &k, find_start);
- if (dev) {
- put_device(dev);
+ dev = class_find_device(&block_class, NULL, &n, find_start);
+ if (dev)
return dev_to_disk(dev);
- }
+
return NULL;
}
@@ -341,7 +337,6 @@
static void part_stop(struct seq_file *part, void *v)
{
- mutex_unlock(&block_class_lock);
}
static int show_partition(struct seq_file *part, void *v)
@@ -583,14 +578,12 @@
static void *diskstats_start(struct seq_file *part, loff_t *pos)
{
struct device *dev;
- loff_t k = *pos;
+ loff_t n = *pos;
- mutex_lock(&block_class_lock);
- dev = class_find_device(&block_class, NULL, &k, find_start);
- if (dev) {
- put_device(dev);
+ dev = class_find_device(&block_class, NULL, &n, find_start);
+ if (dev)
return dev_to_disk(dev);
- }
+
return NULL;
}
@@ -610,7 +603,6 @@
static void diskstats_stop(struct seq_file *part, void *v)
{
- mutex_unlock(&block_class_lock);
}
static int diskstats_show(struct seq_file *s, void *v)
@@ -729,7 +721,6 @@
dev_t devt = MKDEV(0, 0);
struct find_block find;
- mutex_lock(&block_class_lock);
find.name = name;
find.part = part;
dev = class_find_device(&block_class, NULL, &find, match_id);
@@ -738,7 +729,6 @@
devt = MKDEV(MAJOR(dev->devt),
MINOR(dev->devt) + part);
}
- mutex_unlock(&block_class_lock);
return devt;
}