diff options
Diffstat (limited to 'block/genhd.c')
-rw-r--r-- | block/genhd.c | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/block/genhd.c b/block/genhd.c index c13cc77291af..e0ce23ac2ece 100644 --- a/block/genhd.c +++ b/block/genhd.c | |||
@@ -190,7 +190,6 @@ void add_disk(struct gendisk *disk) | |||
190 | disk->minors, NULL, exact_match, exact_lock, disk); | 190 | disk->minors, NULL, exact_match, exact_lock, disk); |
191 | register_disk(disk); | 191 | register_disk(disk); |
192 | blk_register_queue(disk); | 192 | blk_register_queue(disk); |
193 | blk_register_filter(disk); | ||
194 | 193 | ||
195 | bdi = &disk->queue->backing_dev_info; | 194 | bdi = &disk->queue->backing_dev_info; |
196 | bdi_register_dev(bdi, MKDEV(disk->major, disk->first_minor)); | 195 | bdi_register_dev(bdi, MKDEV(disk->major, disk->first_minor)); |
@@ -203,7 +202,6 @@ EXPORT_SYMBOL(del_gendisk); /* in partitions/check.c */ | |||
203 | 202 | ||
204 | void unlink_gendisk(struct gendisk *disk) | 203 | void unlink_gendisk(struct gendisk *disk) |
205 | { | 204 | { |
206 | blk_unregister_filter(disk); | ||
207 | sysfs_remove_link(&disk->dev.kobj, "bdi"); | 205 | sysfs_remove_link(&disk->dev.kobj, "bdi"); |
208 | bdi_unregister(&disk->queue->backing_dev_info); | 206 | bdi_unregister(&disk->queue->backing_dev_info); |
209 | blk_unregister_queue(disk); | 207 | blk_unregister_queue(disk); |
@@ -293,27 +291,30 @@ void __init printk_all_partitions(void) | |||
293 | /* iterator */ | 291 | /* iterator */ |
294 | static int find_start(struct device *dev, void *data) | 292 | static int find_start(struct device *dev, void *data) |
295 | { | 293 | { |
296 | loff_t k = *(loff_t *)data; | 294 | loff_t *k = data; |
297 | 295 | ||
298 | if (dev->type != &disk_type) | 296 | if (dev->type != &disk_type) |
299 | return 0; | 297 | return 0; |
300 | if (!k--) | 298 | if (!*k) |
301 | return 1; | 299 | return 1; |
300 | (*k)--; | ||
302 | return 0; | 301 | return 0; |
303 | } | 302 | } |
304 | 303 | ||
305 | static void *part_start(struct seq_file *part, loff_t *pos) | 304 | static void *part_start(struct seq_file *part, loff_t *pos) |
306 | { | 305 | { |
307 | struct device *dev; | 306 | struct device *dev; |
308 | loff_t n = *pos; | 307 | loff_t k = *pos; |
309 | 308 | ||
310 | if (!n) | 309 | if (!k) |
311 | seq_puts(part, "major minor #blocks name\n\n"); | 310 | part->private = (void *)1LU; /* tell show to print header */ |
312 | 311 | ||
313 | mutex_lock(&block_class_lock); | 312 | mutex_lock(&block_class_lock); |
314 | dev = class_find_device(&block_class, NULL, (void *)pos, find_start); | 313 | dev = class_find_device(&block_class, NULL, &k, find_start); |
315 | if (dev) | 314 | if (dev) { |
315 | put_device(dev); | ||
316 | return dev_to_disk(dev); | 316 | return dev_to_disk(dev); |
317 | } | ||
317 | return NULL; | 318 | return NULL; |
318 | } | 319 | } |
319 | 320 | ||
@@ -330,8 +331,10 @@ static void *part_next(struct seq_file *part, void *v, loff_t *pos) | |||
330 | struct device *dev; | 331 | struct device *dev; |
331 | ++*pos; | 332 | ++*pos; |
332 | dev = class_find_device(&block_class, &gp->dev, NULL, find_next); | 333 | dev = class_find_device(&block_class, &gp->dev, NULL, find_next); |
333 | if (dev) | 334 | if (dev) { |
335 | put_device(dev); | ||
334 | return dev_to_disk(dev); | 336 | return dev_to_disk(dev); |
337 | } | ||
335 | return NULL; | 338 | return NULL; |
336 | } | 339 | } |
337 | 340 | ||
@@ -346,6 +349,17 @@ static int show_partition(struct seq_file *part, void *v) | |||
346 | int n; | 349 | int n; |
347 | char buf[BDEVNAME_SIZE]; | 350 | char buf[BDEVNAME_SIZE]; |
348 | 351 | ||
352 | /* | ||
353 | * Print header if start told us to do. This is to preserve | ||
354 | * the original behavior of not printing header if no | ||
355 | * partition exists. This hackery will be removed later with | ||
356 | * class iteration clean up. | ||
357 | */ | ||
358 | if (part->private) { | ||
359 | seq_puts(part, "major minor #blocks name\n\n"); | ||
360 | part->private = NULL; | ||
361 | } | ||
362 | |||
349 | /* Don't show non-partitionable removeable devices or empty devices */ | 363 | /* Don't show non-partitionable removeable devices or empty devices */ |
350 | if (!get_capacity(sgp) || | 364 | if (!get_capacity(sgp) || |
351 | (sgp->minors == 1 && (sgp->flags & GENHD_FL_REMOVABLE))) | 365 | (sgp->minors == 1 && (sgp->flags & GENHD_FL_REMOVABLE))) |
@@ -568,11 +582,14 @@ static struct device_type disk_type = { | |||
568 | static void *diskstats_start(struct seq_file *part, loff_t *pos) | 582 | static void *diskstats_start(struct seq_file *part, loff_t *pos) |
569 | { | 583 | { |
570 | struct device *dev; | 584 | struct device *dev; |
585 | loff_t k = *pos; | ||
571 | 586 | ||
572 | mutex_lock(&block_class_lock); | 587 | mutex_lock(&block_class_lock); |
573 | dev = class_find_device(&block_class, NULL, (void *)pos, find_start); | 588 | dev = class_find_device(&block_class, NULL, &k, find_start); |
574 | if (dev) | 589 | if (dev) { |
590 | put_device(dev); | ||
575 | return dev_to_disk(dev); | 591 | return dev_to_disk(dev); |
592 | } | ||
576 | return NULL; | 593 | return NULL; |
577 | } | 594 | } |
578 | 595 | ||
@@ -583,8 +600,10 @@ static void *diskstats_next(struct seq_file *part, void *v, loff_t *pos) | |||
583 | 600 | ||
584 | ++*pos; | 601 | ++*pos; |
585 | dev = class_find_device(&block_class, &gp->dev, NULL, find_next); | 602 | dev = class_find_device(&block_class, &gp->dev, NULL, find_next); |
586 | if (dev) | 603 | if (dev) { |
604 | put_device(dev); | ||
587 | return dev_to_disk(dev); | 605 | return dev_to_disk(dev); |
606 | } | ||
588 | return NULL; | 607 | return NULL; |
589 | } | 608 | } |
590 | 609 | ||
@@ -712,10 +731,12 @@ dev_t blk_lookup_devt(const char *name, int part) | |||
712 | mutex_lock(&block_class_lock); | 731 | mutex_lock(&block_class_lock); |
713 | find.name = name; | 732 | find.name = name; |
714 | find.part = part; | 733 | find.part = part; |
715 | dev = class_find_device(&block_class, NULL, (void *)&find, match_id); | 734 | dev = class_find_device(&block_class, NULL, &find, match_id); |
716 | if (dev) | 735 | if (dev) { |
736 | put_device(dev); | ||
717 | devt = MKDEV(MAJOR(dev->devt), | 737 | devt = MKDEV(MAJOR(dev->devt), |
718 | MINOR(dev->devt) + part); | 738 | MINOR(dev->devt) + part); |
739 | } | ||
719 | mutex_unlock(&block_class_lock); | 740 | mutex_unlock(&block_class_lock); |
720 | 741 | ||
721 | return devt; | 742 | return devt; |