aboutsummaryrefslogtreecommitdiffstats
path: root/block/genhd.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2008-09-03 02:53:37 -0400
committerJens Axboe <jens.axboe@oracle.com>2008-10-09 02:56:04 -0400
commit2ac3cee5298a247b2774f3319b28a05f588c3f0e (patch)
treee297bbd502f1a8a52436358c5184f7de1cb43f56 /block/genhd.c
parentac65ece4eee10b03ac29ee925cadc179dc810bab (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/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 0be95135c404..9eb8b3e212c1 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -283,9 +283,7 @@ static int printk_partition(struct device *dev, void *data)
283 */ 283 */
284void __init printk_all_partitions(void) 284void __init printk_all_partitions(void)
285{ 285{
286 mutex_lock(&block_class_lock);
287 class_for_each_device(&block_class, NULL, NULL, printk_partition); 286 class_for_each_device(&block_class, NULL, NULL, printk_partition);
288 mutex_unlock(&block_class_lock);
289} 287}
290 288
291#ifdef CONFIG_PROC_FS 289#ifdef CONFIG_PROC_FS
@@ -305,17 +303,15 @@ static int find_start(struct device *dev, void *data)
305static void *part_start(struct seq_file *part, loff_t *pos) 303static void *part_start(struct seq_file *part, loff_t *pos)
306{ 304{
307 struct device *dev; 305 struct device *dev;
308 loff_t k = *pos; 306 loff_t n = *pos;
309 307
310 if (!k) 308 if (!n)
311 part->private = (void *)1LU; /* tell show to print header */ 309 part->private = (void *)1LU; /* tell show to print header */
312 310
313 mutex_lock(&block_class_lock); 311 dev = class_find_device(&block_class, NULL, &n, find_start);
314 dev = class_find_device(&block_class, NULL, &k, find_start); 312 if (dev)
315 if (dev) {
316 put_device(dev);
317 return dev_to_disk(dev); 313 return dev_to_disk(dev);
318 } 314
319 return NULL; 315 return NULL;
320} 316}
321 317
@@ -341,7 +337,6 @@ static void *part_next(struct seq_file *part, void *v, loff_t *pos)
341 337
342static void part_stop(struct seq_file *part, void *v) 338static void part_stop(struct seq_file *part, void *v)
343{ 339{
344 mutex_unlock(&block_class_lock);
345} 340}
346 341
347static int show_partition(struct seq_file *part, void *v) 342static int show_partition(struct seq_file *part, void *v)
@@ -583,14 +578,12 @@ static struct device_type disk_type = {
583static void *diskstats_start(struct seq_file *part, loff_t *pos) 578static void *diskstats_start(struct seq_file *part, loff_t *pos)
584{ 579{
585 struct device *dev; 580 struct device *dev;
586 loff_t k = *pos; 581 loff_t n = *pos;
587 582
588 mutex_lock(&block_class_lock); 583 dev = class_find_device(&block_class, NULL, &n, find_start);
589 dev = class_find_device(&block_class, NULL, &k, find_start); 584 if (dev)
590 if (dev) {
591 put_device(dev);
592 return dev_to_disk(dev); 585 return dev_to_disk(dev);
593 } 586
594 return NULL; 587 return NULL;
595} 588}
596 589
@@ -610,7 +603,6 @@ static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos)
610 603
611static void diskstats_stop(struct seq_file *part, void *v) 604static void diskstats_stop(struct seq_file *part, void *v)
612{ 605{
613 mutex_unlock(&block_class_lock);
614} 606}
615 607
616static int diskstats_show(struct seq_file *s, void *v) 608static int diskstats_show(struct seq_file *s, void *v)
@@ -729,7 +721,6 @@ dev_t blk_lookup_devt(const char *name, int part)
729 dev_t devt = MKDEV(0, 0); 721 dev_t devt = MKDEV(0, 0);
730 struct find_block find; 722 struct find_block find;
731 723
732 mutex_lock(&block_class_lock);
733 find.name = name; 724 find.name = name;
734 find.part = part; 725 find.part = part;
735 dev = class_find_device(&block_class, NULL, &find, match_id); 726 dev = class_find_device(&block_class, NULL, &find, match_id);
@@ -738,7 +729,6 @@ dev_t blk_lookup_devt(const char *name, int part)
738 devt = MKDEV(MAJOR(dev->devt), 729 devt = MKDEV(MAJOR(dev->devt),
739 MINOR(dev->devt) + part); 730 MINOR(dev->devt) + part);
740 } 731 }
741 mutex_unlock(&block_class_lock);
742 732
743 return devt; 733 return devt;
744} 734}