diff options
author | Tejun Heo <tj@kernel.org> | 2008-08-25 06:56:17 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2008-10-09 02:56:08 -0400 |
commit | 3e1a7ff8a0a7b948f2684930166954f9e8e776fe (patch) | |
tree | 0a8642f5cdbc6ddfdd66dc7241c915e57b3cb7ff /block/genhd.c | |
parent | 689d6fac40b41c7bf154f362deaf442548e4dc81 (diff) |
block: allow disk to have extended device number
Now that disk and partition handlings are mostly unified, it's easy to
allow disk to have extended device number. This patch makes
add_disk() use extended device number if disk->minors is zero. Both
sd and ide-disk are updated to use this.
* sd_format_disk_name() is implemented which can generically determine
the drive name. This removes disk number restriction stemming from
limited device names.
* If sd index goes over SD_MAX_DISKS (which can be increased now BTW),
sd simply doesn't initialize minors letting block layer choose
extended device number.
* If CONFIG_DEBUG_EXT_DEVT is set, both sd and ide-disk always set
minors to 0 and use extended device numbers.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block/genhd.c')
-rw-r--r-- | block/genhd.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/block/genhd.c b/block/genhd.c index eedab5b4685b..d9de3e482d1e 100644 --- a/block/genhd.c +++ b/block/genhd.c | |||
@@ -478,14 +478,37 @@ static int exact_lock(dev_t devt, void *data) | |||
478 | * | 478 | * |
479 | * This function registers the partitioning information in @disk | 479 | * This function registers the partitioning information in @disk |
480 | * with the kernel. | 480 | * with the kernel. |
481 | * | ||
482 | * FIXME: error handling | ||
481 | */ | 483 | */ |
482 | void add_disk(struct gendisk *disk) | 484 | void add_disk(struct gendisk *disk) |
483 | { | 485 | { |
484 | struct backing_dev_info *bdi; | 486 | struct backing_dev_info *bdi; |
487 | dev_t devt; | ||
485 | int retval; | 488 | int retval; |
486 | 489 | ||
490 | /* minors == 0 indicates to use ext devt from part0 and should | ||
491 | * be accompanied with EXT_DEVT flag. Make sure all | ||
492 | * parameters make sense. | ||
493 | */ | ||
494 | WARN_ON(disk->minors && !(disk->major || disk->first_minor)); | ||
495 | WARN_ON(!disk->minors && !(disk->flags & GENHD_FL_EXT_DEVT)); | ||
496 | |||
487 | disk->flags |= GENHD_FL_UP; | 497 | disk->flags |= GENHD_FL_UP; |
488 | disk_to_dev(disk)->devt = MKDEV(disk->major, disk->first_minor); | 498 | |
499 | retval = blk_alloc_devt(&disk->part0, &devt); | ||
500 | if (retval) { | ||
501 | WARN_ON(1); | ||
502 | return; | ||
503 | } | ||
504 | disk_to_dev(disk)->devt = devt; | ||
505 | |||
506 | /* ->major and ->first_minor aren't supposed to be | ||
507 | * dereferenced from here on, but set them just in case. | ||
508 | */ | ||
509 | disk->major = MAJOR(devt); | ||
510 | disk->first_minor = MINOR(devt); | ||
511 | |||
489 | blk_register_region(disk_devt(disk), disk->minors, NULL, | 512 | blk_register_region(disk_devt(disk), disk->minors, NULL, |
490 | exact_match, exact_lock, disk); | 513 | exact_match, exact_lock, disk); |
491 | register_disk(disk); | 514 | register_disk(disk); |