diff options
author | Tejun Heo <tj@kernel.org> | 2008-09-03 03:01:09 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2008-10-09 02:56:05 -0400 |
commit | cf771cb5a7b716f3f9e532fd42a1e3a0a75adec5 (patch) | |
tree | c16cf6adc4d2e51eaee77088ecf126b721f8f3c7 /block | |
parent | 310a2c1012934f590192377f65940cad4aa72b15 (diff) |
block: make variable and argument names more consistent
In hd_struct, @partno is used to denote partition number and a number
of other places use @part to denote hd_struct. Functions use @part
and @index instead. This causes confusion and makes it difficult to
use consistent variable names for hd_struct. Always use @partno if a
variable represents partition number.
Also, print out functions use @f or @part for seq_file argument. Use
@seqf uniformly instead.
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 | 54 | ||||
-rw-r--r-- | block/ioctl.c | 15 |
2 files changed, 33 insertions, 36 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 |
46 | void blkdev_show(struct seq_file *f, off_t offset) | 46 | void 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 | ||
158 | EXPORT_SYMBOL(blk_unregister_region); | 158 | EXPORT_SYMBOL(blk_unregister_region); |
159 | 159 | ||
160 | static struct kobject *exact_match(dev_t devt, int *part, void *data) | 160 | static 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 | */ |
220 | struct gendisk *get_gendisk(dev_t devt, int *part) | 220 | struct 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 | ||
339 | static int show_partition(struct seq_file *part, void *v) | 339 | static 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 | ||
391 | static struct kobject *base_probe(dev_t devt, int *part, void *data) | 380 | static 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 |
567 | static 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 | */ | ||
563 | static 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) | |||
655 | EXPORT_SYMBOL_GPL(genhd_media_change_notify); | 651 | EXPORT_SYMBOL_GPL(genhd_media_change_notify); |
656 | #endif /* 0 */ | 652 | #endif /* 0 */ |
657 | 653 | ||
658 | dev_t blk_lookup_devt(const char *name, int part) | 654 | dev_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 | ||
778 | EXPORT_SYMBOL(bdev_read_only); | 774 | EXPORT_SYMBOL(bdev_read_only); |
779 | 775 | ||
780 | int invalidate_partition(struct gendisk *disk, int index) | 776 | int 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); |
diff --git a/block/ioctl.c b/block/ioctl.c index eb046aeede8a..d77f5e280a6e 100644 --- a/block/ioctl.c +++ b/block/ioctl.c | |||
@@ -15,7 +15,7 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user | |||
15 | struct blkpg_ioctl_arg a; | 15 | struct blkpg_ioctl_arg a; |
16 | struct blkpg_partition p; | 16 | struct blkpg_partition p; |
17 | long long start, length; | 17 | long long start, length; |
18 | int part; | 18 | int partno; |
19 | int i; | 19 | int i; |
20 | int err; | 20 | int err; |
21 | 21 | ||
@@ -28,8 +28,8 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user | |||
28 | disk = bdev->bd_disk; | 28 | disk = bdev->bd_disk; |
29 | if (bdev != bdev->bd_contains) | 29 | if (bdev != bdev->bd_contains) |
30 | return -EINVAL; | 30 | return -EINVAL; |
31 | part = p.pno; | 31 | partno = p.pno; |
32 | if (part <= 0 || part >= disk->minors) | 32 | if (partno <= 0 || partno >= disk->minors) |
33 | return -EINVAL; | 33 | return -EINVAL; |
34 | switch (a.op) { | 34 | switch (a.op) { |
35 | case BLKPG_ADD_PARTITION: | 35 | case BLKPG_ADD_PARTITION: |
@@ -59,13 +59,14 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user | |||
59 | } | 59 | } |
60 | } | 60 | } |
61 | /* all seems OK */ | 61 | /* all seems OK */ |
62 | err = add_partition(disk, part, start, length, ADDPART_FLAG_NONE); | 62 | err = add_partition(disk, partno, start, length, |
63 | ADDPART_FLAG_NONE); | ||
63 | mutex_unlock(&bdev->bd_mutex); | 64 | mutex_unlock(&bdev->bd_mutex); |
64 | return err; | 65 | return err; |
65 | case BLKPG_DEL_PARTITION: | 66 | case BLKPG_DEL_PARTITION: |
66 | if (!disk->part[part-1]) | 67 | if (!disk->part[partno - 1]) |
67 | return -ENXIO; | 68 | return -ENXIO; |
68 | bdevp = bdget_disk(disk, part); | 69 | bdevp = bdget_disk(disk, partno); |
69 | if (!bdevp) | 70 | if (!bdevp) |
70 | return -ENOMEM; | 71 | return -ENOMEM; |
71 | mutex_lock(&bdevp->bd_mutex); | 72 | mutex_lock(&bdevp->bd_mutex); |
@@ -79,7 +80,7 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user | |||
79 | invalidate_bdev(bdevp); | 80 | invalidate_bdev(bdevp); |
80 | 81 | ||
81 | mutex_lock_nested(&bdev->bd_mutex, 1); | 82 | mutex_lock_nested(&bdev->bd_mutex, 1); |
82 | delete_partition(disk, part); | 83 | delete_partition(disk, partno); |
83 | mutex_unlock(&bdev->bd_mutex); | 84 | mutex_unlock(&bdev->bd_mutex); |
84 | mutex_unlock(&bdevp->bd_mutex); | 85 | mutex_unlock(&bdevp->bd_mutex); |
85 | bdput(bdevp); | 86 | bdput(bdevp); |