aboutsummaryrefslogtreecommitdiffstats
path: root/block/genhd.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/genhd.c')
-rw-r--r--block/genhd.c54
1 files changed, 25 insertions, 29 deletions
diff --git a/block/genhd.c b/block/genhd.c
index 11038fbc75ed..dc9ad4c171e2 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -43,14 +43,14 @@ static inline int major_to_index(int major)
43} 43}
44 44
45#ifdef CONFIG_PROC_FS 45#ifdef CONFIG_PROC_FS
46void blkdev_show(struct seq_file *f, off_t offset) 46void blkdev_show(struct seq_file *seqf, off_t offset)
47{ 47{
48 struct blk_major_name *dp; 48 struct blk_major_name *dp;
49 49
50 if (offset < BLKDEV_MAJOR_HASH_SIZE) { 50 if (offset < BLKDEV_MAJOR_HASH_SIZE) {
51 mutex_lock(&block_class_lock); 51 mutex_lock(&block_class_lock);
52 for (dp = major_names[offset]; dp; dp = dp->next) 52 for (dp = major_names[offset]; dp; dp = dp->next)
53 seq_printf(f, "%3d %s\n", dp->major, dp->name); 53 seq_printf(seqf, "%3d %s\n", dp->major, dp->name);
54 mutex_unlock(&block_class_lock); 54 mutex_unlock(&block_class_lock);
55 } 55 }
56} 56}
@@ -157,7 +157,7 @@ void blk_unregister_region(dev_t devt, unsigned long range)
157 157
158EXPORT_SYMBOL(blk_unregister_region); 158EXPORT_SYMBOL(blk_unregister_region);
159 159
160static struct kobject *exact_match(dev_t devt, int *part, void *data) 160static struct kobject *exact_match(dev_t devt, int *partno, void *data)
161{ 161{
162 struct gendisk *p = data; 162 struct gendisk *p = data;
163 163
@@ -217,9 +217,9 @@ void unlink_gendisk(struct gendisk *disk)
217 * This function gets the structure containing partitioning 217 * This function gets the structure containing partitioning
218 * information for the given device @devt. 218 * information for the given device @devt.
219 */ 219 */
220struct gendisk *get_gendisk(dev_t devt, int *part) 220struct gendisk *get_gendisk(dev_t devt, int *partno)
221{ 221{
222 struct kobject *kobj = kobj_lookup(bdev_map, devt, part); 222 struct kobject *kobj = kobj_lookup(bdev_map, devt, partno);
223 struct device *dev = kobj_to_dev(kobj); 223 struct device *dev = kobj_to_dev(kobj);
224 224
225 return kobj ? dev_to_disk(dev) : NULL; 225 return kobj ? dev_to_disk(dev) : NULL;
@@ -336,23 +336,12 @@ static void *show_partition_start(struct seq_file *seqf, loff_t *pos)
336 return p; 336 return p;
337} 337}
338 338
339static int show_partition(struct seq_file *part, void *v) 339static int show_partition(struct seq_file *seqf, void *v)
340{ 340{
341 struct gendisk *sgp = v; 341 struct gendisk *sgp = v;
342 int n; 342 int n;
343 char buf[BDEVNAME_SIZE]; 343 char buf[BDEVNAME_SIZE];
344 344
345 /*
346 * Print header if start told us to do. This is to preserve
347 * the original behavior of not printing header if no
348 * partition exists. This hackery will be removed later with
349 * class iteration clean up.
350 */
351 if (part->private) {
352 seq_puts(part, "major minor #blocks name\n\n");
353 part->private = NULL;
354 }
355
356 /* Don't show non-partitionable removeable devices or empty devices */ 345 /* Don't show non-partitionable removeable devices or empty devices */
357 if (!get_capacity(sgp) || 346 if (!get_capacity(sgp) ||
358 (sgp->minors == 1 && (sgp->flags & GENHD_FL_REMOVABLE))) 347 (sgp->minors == 1 && (sgp->flags & GENHD_FL_REMOVABLE)))
@@ -361,7 +350,7 @@ static int show_partition(struct seq_file *part, void *v)
361 return 0; 350 return 0;
362 351
363 /* show the full disk and all non-0 size partitions of it */ 352 /* show the full disk and all non-0 size partitions of it */
364 seq_printf(part, "%4d %4d %10llu %s\n", 353 seq_printf(seqf, "%4d %4d %10llu %s\n",
365 sgp->major, sgp->first_minor, 354 sgp->major, sgp->first_minor,
366 (unsigned long long)get_capacity(sgp) >> 1, 355 (unsigned long long)get_capacity(sgp) >> 1,
367 disk_name(sgp, 0, buf)); 356 disk_name(sgp, 0, buf));
@@ -370,7 +359,7 @@ static int show_partition(struct seq_file *part, void *v)
370 continue; 359 continue;
371 if (sgp->part[n]->nr_sects == 0) 360 if (sgp->part[n]->nr_sects == 0)
372 continue; 361 continue;
373 seq_printf(part, "%4d %4d %10llu %s\n", 362 seq_printf(seqf, "%4d %4d %10llu %s\n",
374 sgp->major, n + 1 + sgp->first_minor, 363 sgp->major, n + 1 + sgp->first_minor,
375 (unsigned long long)sgp->part[n]->nr_sects >> 1 , 364 (unsigned long long)sgp->part[n]->nr_sects >> 1 ,
376 disk_name(sgp, n + 1, buf)); 365 disk_name(sgp, n + 1, buf));
@@ -388,7 +377,7 @@ const struct seq_operations partitions_op = {
388#endif 377#endif
389 378
390 379
391static struct kobject *base_probe(dev_t devt, int *part, void *data) 380static struct kobject *base_probe(dev_t devt, int *partno, void *data)
392{ 381{
393 if (request_module("block-major-%d-%d", MAJOR(devt), MINOR(devt)) > 0) 382 if (request_module("block-major-%d-%d", MAJOR(devt), MINOR(devt)) > 0)
394 /* Make old-style 2.4 aliases work */ 383 /* Make old-style 2.4 aliases work */
@@ -564,7 +553,14 @@ static struct device_type disk_type = {
564}; 553};
565 554
566#ifdef CONFIG_PROC_FS 555#ifdef CONFIG_PROC_FS
567static int diskstats_show(struct seq_file *s, void *v) 556/*
557 * aggregate disk stat collector. Uses the same stats that the sysfs
558 * entries do, above, but makes them available through one seq_file.
559 *
560 * The output looks suspiciously like /proc/partitions with a bunch of
561 * extra fields.
562 */
563static int diskstats_show(struct seq_file *seqf, void *v)
568{ 564{
569 struct gendisk *gp = v; 565 struct gendisk *gp = v;
570 char buf[BDEVNAME_SIZE]; 566 char buf[BDEVNAME_SIZE];
@@ -572,7 +568,7 @@ static int diskstats_show(struct seq_file *s, void *v)
572 568
573 /* 569 /*
574 if (&gp->dev.kobj.entry == block_class.devices.next) 570 if (&gp->dev.kobj.entry == block_class.devices.next)
575 seq_puts(s, "major minor name" 571 seq_puts(seqf, "major minor name"
576 " rio rmerge rsect ruse wio wmerge " 572 " rio rmerge rsect ruse wio wmerge "
577 "wsect wuse running use aveq" 573 "wsect wuse running use aveq"
578 "\n\n"); 574 "\n\n");
@@ -581,7 +577,7 @@ static int diskstats_show(struct seq_file *s, void *v)
581 preempt_disable(); 577 preempt_disable();
582 disk_round_stats(gp); 578 disk_round_stats(gp);
583 preempt_enable(); 579 preempt_enable();
584 seq_printf(s, "%4d %4d %s %lu %lu %llu %u %lu %lu %llu %u %u %u %u\n", 580 seq_printf(seqf, "%4d %4d %s %lu %lu %llu %u %lu %lu %llu %u %u %u %u\n",
585 gp->major, gp->first_minor, disk_name(gp, 0, buf), 581 gp->major, gp->first_minor, disk_name(gp, 0, buf),
586 disk_stat_read(gp, ios[0]), disk_stat_read(gp, merges[0]), 582 disk_stat_read(gp, ios[0]), disk_stat_read(gp, merges[0]),
587 (unsigned long long)disk_stat_read(gp, sectors[0]), 583 (unsigned long long)disk_stat_read(gp, sectors[0]),
@@ -603,7 +599,7 @@ static int diskstats_show(struct seq_file *s, void *v)
603 preempt_disable(); 599 preempt_disable();
604 part_round_stats(hd); 600 part_round_stats(hd);
605 preempt_enable(); 601 preempt_enable();
606 seq_printf(s, "%4d %4d %s %lu %lu %llu " 602 seq_printf(seqf, "%4d %4d %s %lu %lu %llu "
607 "%u %lu %lu %llu %u %u %u %u\n", 603 "%u %lu %lu %llu %u %u %u %u\n",
608 gp->major, n + gp->first_minor + 1, 604 gp->major, n + gp->first_minor + 1,
609 disk_name(gp, n + 1, buf), 605 disk_name(gp, n + 1, buf),
@@ -655,7 +651,7 @@ void genhd_media_change_notify(struct gendisk *disk)
655EXPORT_SYMBOL_GPL(genhd_media_change_notify); 651EXPORT_SYMBOL_GPL(genhd_media_change_notify);
656#endif /* 0 */ 652#endif /* 0 */
657 653
658dev_t blk_lookup_devt(const char *name, int part) 654dev_t blk_lookup_devt(const char *name, int partno)
659{ 655{
660 dev_t devt = MKDEV(0, 0); 656 dev_t devt = MKDEV(0, 0);
661 struct class_dev_iter iter; 657 struct class_dev_iter iter;
@@ -665,9 +661,9 @@ dev_t blk_lookup_devt(const char *name, int part)
665 while ((dev = class_dev_iter_next(&iter))) { 661 while ((dev = class_dev_iter_next(&iter))) {
666 struct gendisk *disk = dev_to_disk(dev); 662 struct gendisk *disk = dev_to_disk(dev);
667 663
668 if (!strcmp(dev->bus_id, name) && part < disk->minors) { 664 if (!strcmp(dev->bus_id, name) && partno < disk->minors) {
669 devt = MKDEV(MAJOR(dev->devt), 665 devt = MKDEV(MAJOR(dev->devt),
670 MINOR(dev->devt) + part); 666 MINOR(dev->devt) + partno);
671 break; 667 break;
672 } 668 }
673 } 669 }
@@ -777,10 +773,10 @@ int bdev_read_only(struct block_device *bdev)
777 773
778EXPORT_SYMBOL(bdev_read_only); 774EXPORT_SYMBOL(bdev_read_only);
779 775
780int invalidate_partition(struct gendisk *disk, int index) 776int invalidate_partition(struct gendisk *disk, int partno)
781{ 777{
782 int res = 0; 778 int res = 0;
783 struct block_device *bdev = bdget_disk(disk, index); 779 struct block_device *bdev = bdget_disk(disk, partno);
784 if (bdev) { 780 if (bdev) {
785 fsync_bdev(bdev); 781 fsync_bdev(bdev);
786 res = __invalidate_device(bdev); 782 res = __invalidate_device(bdev);