aboutsummaryrefslogtreecommitdiffstats
path: root/fs/partitions/check.c
diff options
context:
space:
mode:
authorWill Drewry <wad@chromium.org>2010-08-31 16:47:05 -0400
committerJens Axboe <jaxboe@fusionio.com>2010-09-15 10:13:18 -0400
commit6d1d8050b4bc89d0165d29b58e894aeba2564a97 (patch)
treeb5c5b730bd7b80fe9041c031a6fcf08f42fff0d5 /fs/partitions/check.c
parent144177991ca624841ddbd1e7edff958fc0f6d1fe (diff)
block, partition: add partition_meta_info to hd_struct
I'm reposting this patch series as v4 since there have been no additional comments, and I cleaned up one extra bit of unneeded code (in 3/3). The patches are against Linus's tree: 2bfc96a127bc1cc94d26bfaa40159966064f9c8c (2.6.36-rc3). Would this patchset be suitable for inclusion in an mm branch? This changes adds a partition_meta_info struct which itself contains a union of structures that provide partition table specific metadata. This change leaves the union empty. The subsequent patch includes an implementation for CONFIG_EFI_PARTITION-based metadata. Signed-off-by: Will Drewry <wad@chromium.org> Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'fs/partitions/check.c')
-rw-r--r--fs/partitions/check.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 79fbf3f390f0..6dfbee03ccc6 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -352,6 +352,7 @@ static void part_release(struct device *dev)
352{ 352{
353 struct hd_struct *p = dev_to_part(dev); 353 struct hd_struct *p = dev_to_part(dev);
354 free_part_stats(p); 354 free_part_stats(p);
355 free_part_info(p);
355 kfree(p); 356 kfree(p);
356} 357}
357 358
@@ -401,7 +402,8 @@ static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH,
401 whole_disk_show, NULL); 402 whole_disk_show, NULL);
402 403
403struct hd_struct *add_partition(struct gendisk *disk, int partno, 404struct hd_struct *add_partition(struct gendisk *disk, int partno,
404 sector_t start, sector_t len, int flags) 405 sector_t start, sector_t len, int flags,
406 struct partition_meta_info *info)
405{ 407{
406 struct hd_struct *p; 408 struct hd_struct *p;
407 dev_t devt = MKDEV(0, 0); 409 dev_t devt = MKDEV(0, 0);
@@ -438,6 +440,14 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
438 p->partno = partno; 440 p->partno = partno;
439 p->policy = get_disk_ro(disk); 441 p->policy = get_disk_ro(disk);
440 442
443 if (info) {
444 struct partition_meta_info *pinfo = alloc_part_info(disk);
445 if (!pinfo)
446 goto out_free_stats;
447 memcpy(pinfo, info, sizeof(*info));
448 p->info = pinfo;
449 }
450
441 dname = dev_name(ddev); 451 dname = dev_name(ddev);
442 if (isdigit(dname[strlen(dname) - 1])) 452 if (isdigit(dname[strlen(dname) - 1]))
443 dev_set_name(pdev, "%sp%d", dname, partno); 453 dev_set_name(pdev, "%sp%d", dname, partno);
@@ -451,7 +461,7 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
451 461
452 err = blk_alloc_devt(p, &devt); 462 err = blk_alloc_devt(p, &devt);
453 if (err) 463 if (err)
454 goto out_free_stats; 464 goto out_free_info;
455 pdev->devt = devt; 465 pdev->devt = devt;
456 466
457 /* delay uevent until 'holders' subdir is created */ 467 /* delay uevent until 'holders' subdir is created */
@@ -481,6 +491,8 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
481 491
482 return p; 492 return p;
483 493
494out_free_info:
495 free_part_info(p);
484out_free_stats: 496out_free_stats:
485 free_part_stats(p); 497 free_part_stats(p);
486out_free: 498out_free:
@@ -642,6 +654,7 @@ rescan:
642 /* add partitions */ 654 /* add partitions */
643 for (p = 1; p < state->limit; p++) { 655 for (p = 1; p < state->limit; p++) {
644 sector_t size, from; 656 sector_t size, from;
657 struct partition_meta_info *info = NULL;
645 658
646 size = state->parts[p].size; 659 size = state->parts[p].size;
647 if (!size) 660 if (!size)
@@ -675,8 +688,12 @@ rescan:
675 size = get_capacity(disk) - from; 688 size = get_capacity(disk) - from;
676 } 689 }
677 } 690 }
691
692 if (state->parts[p].has_info)
693 info = &state->parts[p].info;
678 part = add_partition(disk, p, from, size, 694 part = add_partition(disk, p, from, size,
679 state->parts[p].flags); 695 state->parts[p].flags,
696 &state->parts[p].info);
680 if (IS_ERR(part)) { 697 if (IS_ERR(part)) {
681 printk(KERN_ERR " %s: p%d could not be added: %ld\n", 698 printk(KERN_ERR " %s: p%d could not be added: %ld\n",
682 disk->disk_name, p, -PTR_ERR(part)); 699 disk->disk_name, p, -PTR_ERR(part));