[PATCH v5 10/21] pmem: Dynamically allocate partition numbers

From: Dan Williams
Date: Mon Jun 01 2015 - 20:18:09 EST


From: Ross Zwisler <ross.zwisler@xxxxxxxxxxxxxxx>

Dynamically allocate minor numbers for partitions instead of statically
preallocating them.

It gives us a simpler minors scheme, and makes it so we get a consistent
major when moving past partition 16. Here's what happens with the
current code:

pmem0 249:0 0 63.5G 0 rom
ââpmem0p1 249:1 0 1G 0 part
ââpmem0p2 249:2 0 1G 0 part
ââpmem0p3 249:3 0 1G 0 part
ââpmem0p4 249:4 0 1G 0 part
ââpmem0p5 249:5 0 1G 0 part
ââpmem0p6 249:6 0 1G 0 part
ââpmem0p7 249:7 0 1G 0 part
ââpmem0p8 249:8 0 1G 0 part
ââpmem0p9 249:9 0 1G 0 part
ââpmem0p10 249:10 0 1G 0 part
ââpmem0p11 249:11 0 1G 0 part
ââpmem0p12 249:12 0 1G 0 part
ââpmem0p13 249:13 0 1G 0 part
ââpmem0p14 249:14 0 1G 0 part
ââpmem0p15 249:15 0 1G 0 part
ââpmem0p16 259:0 0 1G 0 part
ââpmem0p17 259:1 0 1G 0 part
ââpmem0p18 259:2 0 1G 0 part

Signed-off-by: Ross Zwisler <ross.zwisler@xxxxxxxxxxxxxxx>
Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx>
---
drivers/nvdimm/pmem.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index cf5d53eda9e5..0842d27ffc8d 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -26,8 +26,6 @@
#include <linux/nd.h>
#include "nd.h"

-#define PMEM_MINORS 16
-
struct pmem_device {
struct request_queue *pmem_queue;
struct gendisk *pmem_disk;
@@ -156,12 +154,12 @@ static struct pmem_device *pmem_alloc(struct device *dev, struct resource *res,
blk_queue_max_hw_sectors(pmem->pmem_queue, 1024);
blk_queue_bounce_limit(pmem->pmem_queue, BLK_BOUNCE_ANY);

- disk = alloc_disk(PMEM_MINORS);
+ disk = alloc_disk(0);
if (!disk)
goto out_free_queue;

disk->major = pmem_major;
- disk->first_minor = PMEM_MINORS * id;
+ disk->first_minor = 0;
disk->fops = &pmem_fops;
disk->private_data = pmem;
disk->queue = pmem->pmem_queue;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/