diff options
author | Tejun Heo <tj@kernel.org> | 2008-08-25 19:30:13 +0900 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2008-08-29 09:08:07 +0200 |
commit | 0ff68c7be1735fda997acc2784d1ecce8115a3be (patch) | |
tree | 642a638a0c08cd55848f02fb90d0a9d96b18316c /block | |
parent | 7ad701a67e2e9e412c31b21ef56816080f997413 (diff) |
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')
-rw-r--r-- | block/genhd.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/block/genhd.c b/block/genhd.c index 96b62b015fac..d6d991489898 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -285,9 +285,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 @@ -312,12 +310,10 @@ static void *part_start(struct seq_file *part, loff_t *pos) if (!k) seq_puts(part, "major minor #blocks name\n\n"); - 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; } @@ -343,7 +339,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) @@ -576,12 +571,10 @@ static void *diskstats_start(struct seq_file *part, loff_t *pos) struct device *dev; loff_t k = *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; } @@ -601,7 +594,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) @@ -720,7 +712,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); @@ -729,7 +720,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; } |