Skip to content

Commit bd8eff3

Browse files
Christoph Hellwigaxboe
Christoph Hellwig
authored andcommitted
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: Christoph Hellwig <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent e49fbbb commit bd8eff3

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

block/genhd.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,13 @@ static ssize_t disk_badblocks_store(struct device *dev,
10311031
return badblocks_store(disk->bb, page, len, 0);
10321032
}
10331033

1034+
static void request_gendisk_module(dev_t devt)
1035+
{
1036+
if (request_module("block-major-%d-%d", MAJOR(devt), MINOR(devt)) > 0)
1037+
/* Make old-style 2.4 aliases work */
1038+
request_module("block-major-%d", MAJOR(devt));
1039+
}
1040+
10341041
static struct gendisk *lookup_gendisk(dev_t dev, int *partno)
10351042
{
10361043
struct kobject *kobj;
@@ -1055,6 +1062,14 @@ static struct gendisk *lookup_gendisk(dev_t dev, int *partno)
10551062
probe = p->probe;
10561063
best = p->range - 1;
10571064
*partno = dev - p->dev;
1065+
1066+
if (!probe) {
1067+
mutex_unlock(&bdev_map_lock);
1068+
module_put(owner);
1069+
request_gendisk_module(dev);
1070+
goto retry;
1071+
}
1072+
10581073
if (p->lock && p->lock(dev, data) < 0) {
10591074
module_put(owner);
10601075
continue;
@@ -1293,15 +1308,6 @@ static const struct seq_operations partitions_op = {
12931308
};
12941309
#endif
12951310

1296-
1297-
static struct kobject *base_probe(dev_t devt, int *partno, void *data)
1298-
{
1299-
if (request_module("block-major-%d-%d", MAJOR(devt), MINOR(devt)) > 0)
1300-
/* Make old-style 2.4 aliases work */
1301-
request_module("block-major-%d", MAJOR(devt));
1302-
return NULL;
1303-
}
1304-
13051311
static void bdev_map_init(void)
13061312
{
13071313
struct bdev_map *base;
@@ -1313,7 +1319,6 @@ static void bdev_map_init(void)
13131319

13141320
base->dev = 1;
13151321
base->range = ~0 ;
1316-
base->probe = base_probe;
13171322
for (i = 0; i < 255; i++)
13181323
bdev_map[i] = base;
13191324
}

0 commit comments

Comments
 (0)