aboutsummaryrefslogtreecommitdiffstats
path: root/fs/partitions/check.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2010-12-08 14:57:36 -0500
committerJens Axboe <jaxboe@fusionio.com>2010-12-16 11:53:38 -0500
commitd2bf1b6723ed0eab378363649d15b7893bf14e91 (patch)
tree4a4144b09ab747ad661605aa761753d9a805e77f /fs/partitions/check.c
parentdddd9dc340ae1a41d90e084529ca979c77c4ecfe (diff)
block: move register_disk() and del_gendisk() to block/genhd.c
There's no reason for register_disk() and del_gendisk() to be in fs/partitions/check.c. Move both to genhd.c. While at it, collapse unlink_gendisk(), which was artificially in a separate function due to genhd.c / check.c split, into del_gendisk(). Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'fs/partitions/check.c')
-rw-r--r--fs/partitions/check.c89
1 files changed, 0 insertions, 89 deletions
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index bdf8d3cc95a4..9a48d65d9855 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -516,65 +516,6 @@ out_put:
516 return ERR_PTR(err); 516 return ERR_PTR(err);
517} 517}
518 518
519/* Not exported, helper to add_disk(). */
520void register_disk(struct gendisk *disk)
521{
522 struct device *ddev = disk_to_dev(disk);
523 struct block_device *bdev;
524 struct disk_part_iter piter;
525 struct hd_struct *part;
526 int err;
527
528 ddev->parent = disk->driverfs_dev;
529
530 dev_set_name(ddev, disk->disk_name);
531
532 /* delay uevents, until we scanned partition table */
533 dev_set_uevent_suppress(ddev, 1);
534
535 if (device_add(ddev))
536 return;
537 if (!sysfs_deprecated) {
538 err = sysfs_create_link(block_depr, &ddev->kobj,
539 kobject_name(&ddev->kobj));
540 if (err) {
541 device_del(ddev);
542 return;
543 }
544 }
545 disk->part0.holder_dir = kobject_create_and_add("holders", &ddev->kobj);
546 disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj);
547
548 /* No minors to use for partitions */
549 if (!disk_partitionable(disk))
550 goto exit;
551
552 /* No such device (e.g., media were just removed) */
553 if (!get_capacity(disk))
554 goto exit;
555
556 bdev = bdget_disk(disk, 0);
557 if (!bdev)
558 goto exit;
559
560 bdev->bd_invalidated = 1;
561 err = blkdev_get(bdev, FMODE_READ, NULL);
562 if (err < 0)
563 goto exit;
564 blkdev_put(bdev, FMODE_READ);
565
566exit:
567 /* announce disk after possible partitions are created */
568 dev_set_uevent_suppress(ddev, 0);
569 kobject_uevent(&ddev->kobj, KOBJ_ADD);
570
571 /* announce possible partitions */
572 disk_part_iter_init(&piter, disk, 0);
573 while ((part = disk_part_iter_next(&piter)))
574 kobject_uevent(&part_to_dev(part)->kobj, KOBJ_ADD);
575 disk_part_iter_exit(&piter);
576}
577
578static bool disk_unlock_native_capacity(struct gendisk *disk) 519static bool disk_unlock_native_capacity(struct gendisk *disk)
579{ 520{
580 const struct block_device_operations *bdops = disk->fops; 521 const struct block_device_operations *bdops = disk->fops;
@@ -737,33 +678,3 @@ fail:
737} 678}
738 679
739EXPORT_SYMBOL(read_dev_sector); 680EXPORT_SYMBOL(read_dev_sector);
740
741void del_gendisk(struct gendisk *disk)
742{
743 struct disk_part_iter piter;
744 struct hd_struct *part;
745
746 /* invalidate stuff */
747 disk_part_iter_init(&piter, disk,
748 DISK_PITER_INCL_EMPTY | DISK_PITER_REVERSE);
749 while ((part = disk_part_iter_next(&piter))) {
750 invalidate_partition(disk, part->partno);
751 delete_partition(disk, part->partno);
752 }
753 disk_part_iter_exit(&piter);
754
755 invalidate_partition(disk, 0);
756 blk_free_devt(disk_to_dev(disk)->devt);
757 set_capacity(disk, 0);
758 disk->flags &= ~GENHD_FL_UP;
759 unlink_gendisk(disk);
760 part_stat_set_all(&disk->part0, 0);
761 disk->part0.stamp = 0;
762
763 kobject_put(disk->part0.holder_dir);
764 kobject_put(disk->slave_dir);
765 disk->driverfs_dev = NULL;
766 if (!sysfs_deprecated)
767 sysfs_remove_link(block_depr, dev_name(disk_to_dev(disk)));
768 device_del(disk_to_dev(disk));
769}