Commit bd8eff3b authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block: rework requesting modules for unclaimed devices

Instead of reusing the ranges in bdev_map, add a new helper that is
called if no ranges was found.  This is a first step to unpeel and
eventually remove the complex ranges structure.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent e49fbbbf
......@@ -1031,6 +1031,13 @@ static ssize_t disk_badblocks_store(struct device *dev,
return badblocks_store(disk->bb, page, len, 0);
}
static void request_gendisk_module(dev_t devt)
{
if (request_module("block-major-%d-%d", MAJOR(devt), MINOR(devt)) > 0)
/* Make old-style 2.4 aliases work */
request_module("block-major-%d", MAJOR(devt));
}
static struct gendisk *lookup_gendisk(dev_t dev, int *partno)
{
struct kobject *kobj;
......@@ -1055,6 +1062,14 @@ static struct gendisk *lookup_gendisk(dev_t dev, int *partno)
probe = p->probe;
best = p->range - 1;
*partno = dev - p->dev;
if (!probe) {
mutex_unlock(&bdev_map_lock);
module_put(owner);
request_gendisk_module(dev);
goto retry;
}
if (p->lock && p->lock(dev, data) < 0) {
module_put(owner);
continue;
......@@ -1293,15 +1308,6 @@ static const struct seq_operations partitions_op = {
};
#endif
static struct kobject *base_probe(dev_t devt, int *partno, void *data)
{
if (request_module("block-major-%d-%d", MAJOR(devt), MINOR(devt)) > 0)
/* Make old-style 2.4 aliases work */
request_module("block-major-%d", MAJOR(devt));
return NULL;
}
static void bdev_map_init(void)
{
struct bdev_map *base;
......@@ -1313,7 +1319,6 @@ static void bdev_map_init(void)
base->dev = 1;
base->range = ~0 ;
base->probe = base_probe;
for (i = 0; i < 255; i++)
bdev_map[i] = base;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment