Thread (75 messages) 75 messages, 8 authors, 2021-06-07

Re: [dm-devel] [PATCH 01/26] block: refactor device number setup in __device_add_disk

From: Christoph Hellwig <hch@lst.de>
Date: 2021-05-24 07:20:20
Also in: dm-devel, linux-bcache, linux-block, linux-m68k, linux-mmc, linux-nvme, linux-raid, linuxppc-dev, nvdimm

On Fri, May 21, 2021 at 05:16:46PM +0000, Luis Chamberlain wrote:
quoted
-	/* 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 ...
quoted
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help