Skip to contentSkip to conversation

stop allocating unnecessary major numbers

PATCH Applied NeilBrown 1 participant 3 messages Jun 2, 2016

Subsystems (2)
lore
Share & tools
lore

NeilBrown

author
#0 lore raw

cover stop allocating unnecessary major numbers

Hi Andrew,
I sent these out to maintainer in March and got generally positive responses but these two didn't get upstreamed, so I assume that means it falls to your lot to handle them.

Thanks,
NeilBrown

---

NeilBrown (2):
memstick: don't allocate unused major for ms_block
NVMe: don't allocate unused nvme_major

 drivers/memstick/core/ms_block.c |   17 ++---------------
 drivers/nvme/host/core.c         |   15 +--------------
 2 files changed, 3 insertions(+), 29 deletions(-)

--
Signature

author
#1 lore raw

PATCH 1/2 memstick: don't allocate unused major for ms_block

When alloc_disk(0) is used the ->major number is completely ignored. All devices are allocated with a major of BLOCK_EXT_MAJOR.

So remove registration and deregistration of 'major'.

Signed-off-by NeilBrown <neilb at suse.com>
---
 drivers/memstick/core/ms_block.c |   17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)
drivers/memstick/core/ms_block.c +2 -15
index 3cd68152ddf8..1efc9103bfd8 100644
@@ -2340,23 +2340,11 @@ static struct memstick_driver msb_driver = {
 	.resume   = msb_resume
 };
 
-static int major;
-
 static int __init msb_init(void)
 {
-	int rc = register_blkdev(0, DRIVER_NAME);
-
-	if (rc < 0) {
-		pr_err("failed to register major (error %d)\n", rc);
-		return rc;
-	}
-
-	major = rc;
-	rc = memstick_register_driver(&msb_driver);
-	if (rc) {
-		unregister_blkdev(major, DRIVER_NAME);
+	int rc = memstick_register_driver(&msb_driver);
+	if (rc)
 		pr_err("failed to register memstick driver (error %d)\n", rc);
-	}
 
 	return rc;
 }
@@ -2364,7 +2352,6 @@ static int __init msb_init(void)
 static void __exit msb_exit(void)
 {
 	memstick_unregister_driver(&msb_driver);
-	unregister_blkdev(major, DRIVER_NAME);
 	idr_destroy(&msb_disk_idr);
 }
 
author
#2 lore raw

PATCH 2/2 NVMe: don't allocate unused nvme_major

In reply to NeilBrown

When alloc_disk(0) is used, the ->major number is ignored. All device numbers are allocated with a major of BLOCK_EXT_MAJOR.

So remove all references to nvme_major.

Reviewed-by Keith Busch <keith.busch at intel.com>
Signed-off-by NeilBrown <neilb at suse.com>
---
 drivers/nvme/host/core.c |   15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/nvme/host/core.c +1 -14
index 1a51584a382b..238b8863f9ab 100644
@@ -47,9 +47,6 @@ unsigned char shutdown_timeout = 5;
 module_param(shutdown_timeout, byte, 0644);
 MODULE_PARM_DESC(shutdown_timeout, "timeout in seconds for controller shutdown");
 
-static int nvme_major;
-module_param(nvme_major, int, 0);
-
 static int nvme_char_major;
 module_param(nvme_char_major, int, 0);
 
@@ -1445,8 +1442,6 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
 	blk_queue_logical_block_size(ns->queue, 1 << ns->lba_shift);
 	nvme_set_queue_limits(ctrl, ns->queue);
 
-	disk->major = nvme_major;
-	disk->first_minor = 0;
 	disk->fops = &nvme_fops;
 	disk->private_data = ns;
 	disk->queue = ns->queue;
@@ -1848,16 +1843,10 @@ int __init nvme_core_init(void)
 {
 	int result;
 
-	result = register_blkdev(nvme_major, "nvme");
-	if (result < 0)
-		return result;
-	else if (result > 0)
-		nvme_major = result;
-
 	result = __register_chrdev(nvme_char_major, 0, NVME_MINORS, "nvme",
 							&nvme_dev_fops);
 	if (result < 0)
-		goto unregister_blkdev;
+		return result;
 	else if (result > 0)
 		nvme_char_major = result;
 
@@ -1871,8 +1860,6 @@ int __init nvme_core_init(void)
 
  unregister_chrdev:
 	__unregister_chrdev(nvme_char_major, 0, NVME_MINORS, "nvme");
- unregister_blkdev:
-	unregister_blkdev(nvme_major, "nvme");
 	return result;
 }