diff options
author | Jens Axboe <jaxboe@fusionio.com> | 2010-11-16 04:09:42 -0500 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2010-11-16 04:09:42 -0500 |
commit | a02056349cdea2252cd2b21643ebf025e83a29f2 (patch) | |
tree | b7c889d6cbe8e7188d07d99a5c9da858c53a5b6c /fs/partitions/check.c | |
parent | 34db1d595ef6f183fbc1e42cda45a3dfa0035258 (diff) | |
parent | e53beacd23d9cb47590da6a7a7f6d417b941a994 (diff) |
Merge branch 'v2.6.37-rc2' into for-2.6.38/core
Diffstat (limited to 'fs/partitions/check.c')
-rw-r--r-- | fs/partitions/check.c | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/fs/partitions/check.c b/fs/partitions/check.c index 861ae84fcee5..12213f7ce7a2 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c | |||
@@ -361,6 +361,7 @@ static void part_release(struct device *dev) | |||
361 | { | 361 | { |
362 | struct hd_struct *p = dev_to_part(dev); | 362 | struct hd_struct *p = dev_to_part(dev); |
363 | free_part_stats(p); | 363 | free_part_stats(p); |
364 | free_part_info(p); | ||
364 | kfree(p); | 365 | kfree(p); |
365 | } | 366 | } |
366 | 367 | ||
@@ -410,7 +411,8 @@ static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH, | |||
410 | whole_disk_show, NULL); | 411 | whole_disk_show, NULL); |
411 | 412 | ||
412 | struct hd_struct *add_partition(struct gendisk *disk, int partno, | 413 | struct hd_struct *add_partition(struct gendisk *disk, int partno, |
413 | sector_t start, sector_t len, int flags) | 414 | sector_t start, sector_t len, int flags, |
415 | struct partition_meta_info *info) | ||
414 | { | 416 | { |
415 | struct hd_struct *p; | 417 | struct hd_struct *p; |
416 | dev_t devt = MKDEV(0, 0); | 418 | dev_t devt = MKDEV(0, 0); |
@@ -447,6 +449,14 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno, | |||
447 | p->partno = partno; | 449 | p->partno = partno; |
448 | p->policy = get_disk_ro(disk); | 450 | p->policy = get_disk_ro(disk); |
449 | 451 | ||
452 | if (info) { | ||
453 | struct partition_meta_info *pinfo = alloc_part_info(disk); | ||
454 | if (!pinfo) | ||
455 | goto out_free_stats; | ||
456 | memcpy(pinfo, info, sizeof(*info)); | ||
457 | p->info = pinfo; | ||
458 | } | ||
459 | |||
450 | dname = dev_name(ddev); | 460 | dname = dev_name(ddev); |
451 | if (isdigit(dname[strlen(dname) - 1])) | 461 | if (isdigit(dname[strlen(dname) - 1])) |
452 | dev_set_name(pdev, "%sp%d", dname, partno); | 462 | dev_set_name(pdev, "%sp%d", dname, partno); |
@@ -460,7 +470,7 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno, | |||
460 | 470 | ||
461 | err = blk_alloc_devt(p, &devt); | 471 | err = blk_alloc_devt(p, &devt); |
462 | if (err) | 472 | if (err) |
463 | goto out_free_stats; | 473 | goto out_free_info; |
464 | pdev->devt = devt; | 474 | pdev->devt = devt; |
465 | 475 | ||
466 | /* delay uevent until 'holders' subdir is created */ | 476 | /* delay uevent until 'holders' subdir is created */ |
@@ -490,6 +500,8 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno, | |||
490 | 500 | ||
491 | return p; | 501 | return p; |
492 | 502 | ||
503 | out_free_info: | ||
504 | free_part_info(p); | ||
493 | out_free_stats: | 505 | out_free_stats: |
494 | free_part_stats(p); | 506 | free_part_stats(p); |
495 | out_free: | 507 | out_free: |
@@ -522,14 +534,14 @@ void register_disk(struct gendisk *disk) | |||
522 | 534 | ||
523 | if (device_add(ddev)) | 535 | if (device_add(ddev)) |
524 | return; | 536 | return; |
525 | #ifndef CONFIG_SYSFS_DEPRECATED | 537 | if (!sysfs_deprecated) { |
526 | err = sysfs_create_link(block_depr, &ddev->kobj, | 538 | err = sysfs_create_link(block_depr, &ddev->kobj, |
527 | kobject_name(&ddev->kobj)); | 539 | kobject_name(&ddev->kobj)); |
528 | if (err) { | 540 | if (err) { |
529 | device_del(ddev); | 541 | device_del(ddev); |
530 | return; | 542 | return; |
543 | } | ||
531 | } | 544 | } |
532 | #endif | ||
533 | disk->part0.holder_dir = kobject_create_and_add("holders", &ddev->kobj); | 545 | disk->part0.holder_dir = kobject_create_and_add("holders", &ddev->kobj); |
534 | disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj); | 546 | disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj); |
535 | 547 | ||
@@ -651,6 +663,7 @@ rescan: | |||
651 | /* add partitions */ | 663 | /* add partitions */ |
652 | for (p = 1; p < state->limit; p++) { | 664 | for (p = 1; p < state->limit; p++) { |
653 | sector_t size, from; | 665 | sector_t size, from; |
666 | struct partition_meta_info *info = NULL; | ||
654 | 667 | ||
655 | size = state->parts[p].size; | 668 | size = state->parts[p].size; |
656 | if (!size) | 669 | if (!size) |
@@ -684,8 +697,12 @@ rescan: | |||
684 | size = get_capacity(disk) - from; | 697 | size = get_capacity(disk) - from; |
685 | } | 698 | } |
686 | } | 699 | } |
700 | |||
701 | if (state->parts[p].has_info) | ||
702 | info = &state->parts[p].info; | ||
687 | part = add_partition(disk, p, from, size, | 703 | part = add_partition(disk, p, from, size, |
688 | state->parts[p].flags); | 704 | state->parts[p].flags, |
705 | &state->parts[p].info); | ||
689 | if (IS_ERR(part)) { | 706 | if (IS_ERR(part)) { |
690 | printk(KERN_ERR " %s: p%d could not be added: %ld\n", | 707 | printk(KERN_ERR " %s: p%d could not be added: %ld\n", |
691 | disk->disk_name, p, -PTR_ERR(part)); | 708 | disk->disk_name, p, -PTR_ERR(part)); |
@@ -746,8 +763,7 @@ void del_gendisk(struct gendisk *disk) | |||
746 | kobject_put(disk->part0.holder_dir); | 763 | kobject_put(disk->part0.holder_dir); |
747 | kobject_put(disk->slave_dir); | 764 | kobject_put(disk->slave_dir); |
748 | disk->driverfs_dev = NULL; | 765 | disk->driverfs_dev = NULL; |
749 | #ifndef CONFIG_SYSFS_DEPRECATED | 766 | if (!sysfs_deprecated) |
750 | sysfs_remove_link(block_depr, dev_name(disk_to_dev(disk))); | 767 | sysfs_remove_link(block_depr, dev_name(disk_to_dev(disk))); |
751 | #endif | ||
752 | device_del(disk_to_dev(disk)); | 768 | device_del(disk_to_dev(disk)); |
753 | } | 769 | } |