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

2015-05-27 Thread Dan Williams
From: Ross Zwisler 

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:00 63.5G  0 rom
 ├─pmem0p1  249:101G  0 part
 ├─pmem0p2  249:201G  0 part
 ├─pmem0p3  249:301G  0 part
 ├─pmem0p4  249:401G  0 part
 ├─pmem0p5  249:501G  0 part
 ├─pmem0p6  249:601G  0 part
 ├─pmem0p7  249:701G  0 part
 ├─pmem0p8  249:801G  0 part
 ├─pmem0p9  249:901G  0 part
 ├─pmem0p10 249:10   01G  0 part
 ├─pmem0p11 249:11   01G  0 part
 ├─pmem0p12 249:12   01G  0 part
 ├─pmem0p13 249:13   01G  0 part
 ├─pmem0p14 249:14   01G  0 part
 ├─pmem0p15 249:15   01G  0 part
 ├─pmem0p16 259:001G  0 part
 ├─pmem0p17 259:101G  0 part
 └─pmem0p18 259:201G  0 part

Signed-off-by: Ross Zwisler 
Signed-off-by: Dan Williams 
---
 drivers/block/nd/pmem.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/block/nd/pmem.c b/drivers/block/nd/pmem.c
index cf5d53eda9e5..0842d27ffc8d 100644
--- a/drivers/block/nd/pmem.c
+++ b/drivers/block/nd/pmem.c
@@ -26,8 +26,6 @@
 #include 
 #include "nd.h"
 
-#define PMEM_MINORS16
-
 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  = _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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2015-05-27 Thread Dan Williams
From: Ross Zwisler ross.zwis...@linux.intel.com

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:00 63.5G  0 rom
 ├─pmem0p1  249:101G  0 part
 ├─pmem0p2  249:201G  0 part
 ├─pmem0p3  249:301G  0 part
 ├─pmem0p4  249:401G  0 part
 ├─pmem0p5  249:501G  0 part
 ├─pmem0p6  249:601G  0 part
 ├─pmem0p7  249:701G  0 part
 ├─pmem0p8  249:801G  0 part
 ├─pmem0p9  249:901G  0 part
 ├─pmem0p10 249:10   01G  0 part
 ├─pmem0p11 249:11   01G  0 part
 ├─pmem0p12 249:12   01G  0 part
 ├─pmem0p13 249:13   01G  0 part
 ├─pmem0p14 249:14   01G  0 part
 ├─pmem0p15 249:15   01G  0 part
 ├─pmem0p16 259:001G  0 part
 ├─pmem0p17 259:101G  0 part
 └─pmem0p18 259:201G  0 part

Signed-off-by: Ross Zwisler ross.zwis...@linux.intel.com
Signed-off-by: Dan Williams dan.j.willi...@intel.com
---
 drivers/block/nd/pmem.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/block/nd/pmem.c b/drivers/block/nd/pmem.c
index cf5d53eda9e5..0842d27ffc8d 100644
--- a/drivers/block/nd/pmem.c
+++ b/drivers/block/nd/pmem.c
@@ -26,8 +26,6 @@
 #include linux/nd.h
 #include nd.h
 
-#define PMEM_MINORS16
-
 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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/