On Fri, May 21, 2021 at 05:16:46PM +0000, Luis Chamberlain wrote: > > - /* in consecutive minor range? */ > > - if (bdev->bd_partno < disk->minors) { > > - *devt = MKDEV(disk->major, disk->first_minor + bdev->bd_partno); > > - return 0; > > - } > > - > > It is not obviously clear to me, why this was part of add_disk() > path, and ... > > > diff --git a/block/partitions/core.c b/block/partitions/core.c > > index dc60ecf46fe6..504297bdc8bf 100644 > > --- a/block/partitions/core.c > > +++ b/block/partitions/core.c > > @@ -379,9 +380,15 @@ static struct block_device *add_partition(struct gendisk *disk, int partno, > > pdev->type = &part_type; > > pdev->parent = ddev; > > > > - err = blk_alloc_devt(bdev, &devt); > > - if (err) > > - goto out_put; > > + /* in consecutive minor range? */ > > + if (bdev->bd_partno < disk->minors) { > > + devt = MKDEV(disk->major, disk->first_minor + bdev->bd_partno); > > + } else { > > + err = blk_alloc_ext_minor(); > > + if (err < 0) > > + goto out_put; > > + devt = MKDEV(BLOCK_EXT_MAJOR, err); > > + } > > pdev->devt = devt; > > > > /* delay uevent until 'holders' subdir is created */ > > ... and why we only add this here now. For the genhd minors == 0 (aka GENHD_FL_EXT_DEVT) implies having to allocate a dynamic dev_t, so it can be folded into another conditional.