summaryrefslogtreecommitdiffstats
path: root/block/genhd.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2008-09-03 08:53:37 +0200
committerJens Axboe <jens.axboe@oracle.com>2008-10-09 08:56:04 +0200
commit2ac3cee5298a247b2774f3319b28a05f588c3f0e (patch)
treee297bbd502f1a8a52436358c5184f7de1cb43f56 /block/genhd.c
parentac65ece4eee10b03ac29ee925cadc179dc810bab (diff)
downloadop-kernel-dev-2ac3cee5298a247b2774f3319b28a05f588c3f0e.zip
op-kernel-dev-2ac3cee5298a247b2774f3319b28a05f588c3f0e.tar.gz
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>
Diffstat (limited to 'block/genhd.c')
-rw-r--r--block/genhd.c28
1 files changed, 9 insertions, 19 deletions
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 @@ static int printk_partition(struct device *dev, void *data)
*/
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 int find_start(struct device *dev, void *data)
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_next(struct seq_file *part, void *v, loff_t *pos)
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 struct device_type disk_type = {
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_next(struct seq_file *part, void *v, loff_t *pos)
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 blk_lookup_devt(const char *name, int part)
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 @@ dev_t blk_lookup_devt(const char *name, int part)
devt = MKDEV(MAJOR(dev->devt),
MINOR(dev->devt) + part);
}
- mutex_unlock(&block_class_lock);
return devt;
}
OpenPOWER on IntegriCloud