From: Boaz Harrosh <boaz@plexistor.com>
To: Ross Zwisler <ross.zwisler@linux.intel.com>,
Jens Axboe <axboe@fb.com>,
Matthew Wilcox <matthew.r.wilcox@intel.com>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
linux-nvdimm@lists.01.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH 4/9] SQUASHME: pmem: Support of multiple memory regions
Date: Tue, 09 Sep 2014 18:44:55 +0300 [thread overview]
Message-ID: <540F2077.5000809@plexistor.com> (raw)
In-Reply-To: <540F1EC6.4000504@plexistor.com>
From: Boaz Harrosh <boaz@plexistor.com>
After the last patch this is easy.
The API to pmem module is changed. We now have a single string
parameter named "map" of the form:
map=mapS[,mapS...]
where mapS=nn[KMG]$ss[KMG],
or mapS=nn[KMG]@ss[KMG],
nn=size, ss=offset
Just like the Kernel command line map && memmap parameters,
so anything you did at grub just copy/paste to here.
The "@" form is exactly the same as the "$" form only that
at bash prompt we need to escape the "$" with \$ so also
support the '@' char for convenience.
For each specified mapS there will be a device created.
So needless to say that all the previous prd_XXX params are
removed as well as the Kconfig defaults.
Signed-off-by: Boaz Harrosh <boaz@plexistor.com>
---
drivers/block/Kconfig | 28 -----------------------
drivers/block/pmem.c | 62 ++++++++++++++++++++++++++++++++++++---------------
2 files changed, 44 insertions(+), 46 deletions(-)
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 2d50125..5da8cbf 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -416,34 +416,6 @@ config BLK_DEV_PMEM
Most normal users won't need this functionality, and can thus say N
here.
-config BLK_DEV_PMEM_START
- int "Offset in GiB of where to start claiming space"
- default "0"
- depends on BLK_DEV_PMEM
- help
- Starting offset in GiB that PMEM should use when claiming memory. This
- memory needs to be reserved from the OS at boot time using the
- "memmap" kernel parameter.
-
- If you provide PMEM with volatile memory it will act as a volatile
- RAM disk and your data will not be persistent.
-
-config BLK_DEV_PMEM_COUNT
- int "Default number of PMEM disks"
- default "4"
- depends on BLK_DEV_PMEM
- help
- Number of equal sized block devices that PMEM should create.
-
-config BLK_DEV_PMEM_SIZE
- int "Size in GiB of space to claim"
- depends on BLK_DEV_PMEM
- default "0"
- help
- Amount of memory in GiB that PMEM should use when creating block
- devices. This memory needs to be reserved from the OS at
- boot time using the "memmap" kernel parameter.
-
config CDROM_PKTCDVD
tristate "Packet writing on CD/DVD media"
depends on !UML
diff --git a/drivers/block/pmem.c b/drivers/block/pmem.c
index d5c5c52..e07a373 100644
--- a/drivers/block/pmem.c
+++ b/drivers/block/pmem.c
@@ -212,17 +212,11 @@ static const struct block_device_operations pmem_fops = {
};
/* Kernel module stuff */
-static int pmem_start_gb = CONFIG_BLK_DEV_PMEM_START;
-module_param(pmem_start_gb, int, S_IRUGO);
-MODULE_PARM_DESC(pmem_start_gb, "Offset in GB of where to start claiming space");
-
-static int pmem_size_gb = CONFIG_BLK_DEV_PMEM_SIZE;
-module_param(pmem_size_gb, int, S_IRUGO);
-MODULE_PARM_DESC(pmem_size_gb, "Total size in GB of space to claim for all disks");
-
-static int pmem_count = CONFIG_BLK_DEV_PMEM_COUNT;
-module_param(pmem_count, int, S_IRUGO);
-MODULE_PARM_DESC(pmem_count, "Number of pmem devices to evenly split allocated space");
+static char *map;
+module_param(map, charp, S_IRUGO);
+MODULE_PARM_DESC(map,
+ "pmem device mapping: map=mapS[,mapS...] where:\n"
+ "mapS=nn[KMG]$ss[KMG] or mapS=nn[KMG]@ss[KMG], nn=size, ss=offset.");
static LIST_HEAD(pmem_devices);
static int pmem_major;
@@ -272,6 +266,13 @@ static struct pmem_device *pmem_alloc(phys_addr_t phys_addr, size_t disk_size,
struct gendisk *disk;
int err;
+ if (unlikely((phys_addr & ~PAGE_MASK) || (disk_size & ~PAGE_MASK))) {
+ pr_err("phys_addr=0x%llx disk_size=0x%zx must be 4k aligned\n",
+ phys_addr, disk_size);
+ err = -EINVAL;
+ goto out;
+ }
+
pmem = kzalloc(sizeof(*pmem), GFP_KERNEL);
if (unlikely(!pmem)) {
err = -ENOMEM;
@@ -344,16 +345,32 @@ static void pmem_del_one(struct pmem_device *pmem)
pmem_free(pmem);
}
+static int pmem_parse_map_one(char *map, phys_addr_t *start, size_t *size)
+{
+ char *p = map;
+
+ *size = (size_t)memparse(p, &p);
+ if ((p == map) || ((*p != '$') && (*p != '@')))
+ return -EINVAL;
+
+ if (!*(++p))
+ return -EINVAL;
+
+ *start = (phys_addr_t)memparse(p, &p);
+
+ return *p == '\0' ? 0 : -EINVAL;
+}
+
static int __init pmem_init(void)
{
int result, i;
struct pmem_device *pmem, *next;
- phys_addr_t phys_addr;
- size_t total_size, disk_size;
+ char *p, *pmem_map = map;
- phys_addr = (phys_addr_t) pmem_start_gb * 1024 * 1024 * 1024;
- total_size = (size_t) pmem_size_gb * 1024 * 1024 * 1024;
- disk_size = total_size / pmem_count;
+ if (!pmem_map) {
+ pr_err("pmem: must specify map=nn@ss parameter.\n");
+ return -EINVAL;
+ }
result = register_blkdev(0, "pmem");
if (result < 0)
@@ -361,14 +378,23 @@ static int __init pmem_init(void)
else
pmem_major = result;
- for (i = 0; i < pmem_count; i++) {
+ i = 0;
+ while ((p = strsep(&pmem_map, ",")) != NULL) {
+ phys_addr_t phys_addr;
+ size_t disk_size;
+
+ if (!*p)
+ continue;
+ result = pmem_parse_map_one(p, &phys_addr, &disk_size);
+ if (result)
+ goto out_free;
pmem = pmem_alloc(phys_addr, disk_size, i);
if (IS_ERR(pmem)) {
result = PTR_ERR(pmem);
goto out_free;
}
list_add_tail(&pmem->pmem_list, &pmem_devices);
- phys_addr += disk_size;
+ ++i;
}
list_for_each_entry(pmem, &pmem_devices, pmem_list)
--
1.9.3
next prev parent reply other threads:[~2014-09-09 15:44 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-27 21:11 [PATCH 0/4] Add persistent memory driver Ross Zwisler
2014-08-27 21:11 ` [PATCH 1/4] pmem: Initial version of " Ross Zwisler
2014-09-09 16:23 ` [PATCH v2] " Boaz Harrosh
2014-09-09 16:53 ` [Linux-nvdimm] " Dan Williams
2014-09-10 13:23 ` Boaz Harrosh
2014-09-10 17:03 ` Dan Williams
2014-09-10 17:47 ` Boaz Harrosh
2014-09-10 23:01 ` Dan Williams
2014-09-11 10:45 ` Boaz Harrosh
2014-09-11 16:31 ` Dan Williams
2014-09-14 11:18 ` Boaz Harrosh
2014-09-16 13:54 ` Jeff Moyer
2014-09-16 16:24 ` Boaz Harrosh
2014-09-19 16:27 ` Dan Williams
2014-09-21 9:27 ` Boaz Harrosh
2014-11-02 3:22 ` [PATCH 1/4] " Elliott, Robert (Server Storage)
2014-11-03 15:50 ` Jeff Moyer
2014-11-03 16:19 ` Wilcox, Matthew R
2014-11-04 10:37 ` Boaz Harrosh
2014-11-04 16:26 ` Elliott, Robert (Server Storage)
2014-11-04 16:41 ` Ross Zwisler
2014-11-04 17:06 ` Boaz Harrosh
2014-08-27 21:12 ` [PATCH 2/4] pmem: Add support for getgeo() Ross Zwisler
2014-11-02 3:27 ` Elliott, Robert (Server Storage)
2014-11-03 16:36 ` Wilcox, Matthew R
2014-08-27 21:12 ` [PATCH 3/4] pmem: Add support for rw_page() Ross Zwisler
2014-08-27 21:12 ` [PATCH 4/4] pmem: Add support for direct_access() Ross Zwisler
2014-09-09 15:37 ` [PATCH 0/9] pmem: Fixes and farther development (mm: add_persistent_memory) Boaz Harrosh
2014-09-09 15:40 ` [PATCH 1/9] SQUASHME: pmem: Remove unused #include headers Boaz Harrosh
2014-09-09 22:29 ` Ross Zwisler
2014-09-10 11:36 ` Boaz Harrosh
2014-09-10 19:16 ` [Linux-nvdimm] " Matthew Wilcox
2014-09-11 11:35 ` Boaz Harrosh
2014-09-11 19:34 ` Matthew Wilcox
2014-09-09 15:41 ` [PATCH 2/9] SQUASHME: pmem: Request from fdisk 4k alignment Boaz Harrosh
2014-09-11 18:39 ` Ross Zwisler
2014-09-14 11:25 ` Boaz Harrosh
2014-09-09 15:43 ` [PATCH 3/9] SQUASHME: pmem: Let each device manage private memory region Boaz Harrosh
2014-09-11 20:35 ` Ross Zwisler
2014-09-09 15:44 ` Boaz Harrosh [this message]
2014-09-09 15:45 ` [PATCH 5/9] mm: Let sparse_{add,remove}_one_section receive a node_id Boaz Harrosh
2014-09-09 18:36 ` Dave Hansen
2014-09-10 10:07 ` Boaz Harrosh
2014-09-10 16:10 ` Dave Hansen
2014-09-10 17:25 ` Boaz Harrosh
2014-09-10 18:28 ` Dave Hansen
2014-09-11 8:39 ` Boaz Harrosh
2014-09-11 17:07 ` Dave Hansen
2014-09-14 9:36 ` Boaz Harrosh
2014-09-09 15:47 ` [PATCH 6/9] mm: New add_persistent_memory/remove_persistent_memory Boaz Harrosh
2014-09-09 15:48 ` [PATCH 7/9] pmem: Add support for page structs Boaz Harrosh
2014-09-09 15:49 ` [PATCH 8/9] SQUASHME: pmem: Fixs to getgeo Boaz Harrosh
2014-09-09 15:51 ` [PATCH 9/9] pmem: KISS, remove register_blkdev Boaz Harrosh
2014-09-10 16:50 ` [PATCH] SQUASHME pmem: Micro optimization for pmem_direct_access Boaz Harrosh
2014-09-10 22:32 ` Ross Zwisler
2014-09-11 11:42 ` Boaz Harrosh
2014-09-14 14:58 ` [PATCH v2] SQUASHME pmem: Micro optimize the hotpath Boaz Harrosh
2014-09-14 16:02 ` [PATCH] SQUASHME: pmem: no need to copy a page at a time Boaz Harrosh
2014-09-15 0:23 ` Wilcox, Matthew R
2014-09-15 8:47 ` Boaz Harrosh
2014-09-10 17:50 ` [PATCH] SQUASHME: pmem: Add MODULE_ALIAS Boaz Harrosh
2014-09-10 19:22 ` Ross Zwisler
2014-09-11 11:44 ` Boaz Harrosh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=540F2077.5000809@plexistor.com \
--to=boaz@plexistor.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@fb.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvdimm@lists.01.org \
--cc=matthew.r.wilcox@intel.com \
--cc=ross.zwisler@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).