summaryrefslogtreecommitdiff
path: root/fs/partitions
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2008-08-25 19:47:22 +0900
committerJens Axboe <jens.axboe@oracle.com>2008-10-09 08:56:06 +0200
commitbcce3de1be61e424deef35d1e86e86a35c4b6e65 (patch)
treecfdefb52bc37c61dfac160951a9beb86d5cd9ba0 /fs/partitions
parentc9959059161ddd7bf4670cf47367033d6b2f79c4 (diff)
downloadlinux-3.10-bcce3de1be61e424deef35d1e86e86a35c4b6e65.tar.gz
linux-3.10-bcce3de1be61e424deef35d1e86e86a35c4b6e65.tar.bz2
linux-3.10-bcce3de1be61e424deef35d1e86e86a35c4b6e65.zip
block: implement extended dev numbers
Implement extended device numbers. A block driver can tell block layer that it wants to use extended device numbers. After the usual minor space is used up, block layer automatically allocates devt's from EXT_BLOCK_MAJOR. Currently only one major number is allocated for this but as the allocation is strictly on-demand, ~1mil minor space under it should suffice unless the system actually has more than ~1mil partitions and if that ever happens adding more majors to the extended devt area is easy. Due to internal implementation issues, the first partition can't be allocated on the extended area. In other words, genhd->minors should at least be 1. This limitation will be lifted by later changes. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'fs/partitions')
-rw-r--r--fs/partitions/check.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index c442f0aadac..0d4b7f28f13 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -333,6 +333,7 @@ void delete_partition(struct gendisk *disk, int partno)
if (!part)
return;
+ blk_free_devt(part_devt(part));
rcu_assign_pointer(disk->__part[partno-1], NULL);
kobject_put(part->holder_dir);
device_del(&part->dev);
@@ -352,6 +353,7 @@ int add_partition(struct gendisk *disk, int partno,
sector_t start, sector_t len, int flags)
{
struct hd_struct *p;
+ dev_t devt = MKDEV(0, 0);
int err;
if (disk->__part[partno - 1])
@@ -378,11 +380,15 @@ int add_partition(struct gendisk *disk, int partno,
"%s%d", disk->dev.bus_id, partno);
device_initialize(&p->dev);
- p->dev.devt = MKDEV(disk->major, disk->first_minor + partno);
p->dev.class = &block_class;
p->dev.type = &part_type;
p->dev.parent = &disk->dev;
+ err = blk_alloc_devt(p, &devt);
+ if (err)
+ goto out_put;
+ p->dev.devt = devt;
+
/* delay uevent until 'holders' subdir is created */
p->dev.uevent_suppress = 1;
err = device_add(&p->dev);
@@ -419,6 +425,7 @@ out_del:
device_del(&p->dev);
out_put:
put_device(&p->dev);
+ blk_free_devt(devt);
return err;
}