linux-nvdimm.lists.01.org archive mirror
 help / color / mirror / Atom feed
From: Joao Martins <joao.m.martins@oracle.com>
To: linux-nvdimm@lists.01.org
Cc: Dan Williams <dan.j.williams@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>
Subject: [PATCH ndctl v1 03/10] daxctl: add resize support in reconfigure-device
Date: Fri,  3 Apr 2020 21:58:53 +0100	[thread overview]
Message-ID: <20200403205900.18035-4-joao.m.martins@oracle.com> (raw)
In-Reply-To: <20200403205900.18035-1-joao.m.martins@oracle.com>

Add the ability to change the size of an inactive dax
device. Uses of this includes adjusting existing devices
or enterily freeing the region device to make the space
available.

	$ daxctl disable-device dax0.0
	disabled 1 device
	$ daxctl reconfigure-device -s 0 dax0.0
	reconfigured 1 device
	$ daxctl reconfigure-device -s 4G dax0.0
	reconfigured 1 device

@size (-s) and @mode (-m) are mutually exclusive as the latter relates
to assigning memory to System-RAM through kmem as opposed
to reconfiguring dynamic dax devices.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 daxctl/device.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/daxctl/device.c b/daxctl/device.c
index 705f1f8ff7f6..b483d2777ecb 100644
--- a/daxctl/device.c
+++ b/daxctl/device.c
@@ -34,6 +34,7 @@ enum dev_mode {
 };
 
 static enum dev_mode reconfig_mode = DAXCTL_DEV_MODE_UNKNOWN;
+static long long size = -1;
 static unsigned long flags;
 
 enum memory_zone {
@@ -66,6 +67,7 @@ OPT_BOOLEAN('\0', "no-movable", &param.no_movable, \
 
 static const struct option reconfig_options[] = {
 	BASE_OPTIONS(),
+	CREATE_OPTIONS(),
 	RECONFIG_OPTIONS(),
 	ZONE_OPTIONS(),
 	OPT_END(),
@@ -135,12 +137,14 @@ static const char *parse_device_options(int argc, const char **argv,
 	/* Handle action-specific options */
 	switch (action) {
 	case ACTION_RECONFIG:
-		if (!param.mode) {
-			fprintf(stderr, "error: a 'mode' option is required\n");
+		if (!param.size && !param.mode) {
+			fprintf(stderr, "error: a 'mode' or 'size' option is required\n");
 			usage_with_options(u, reconfig_options);
 			rc = -EINVAL;
 		}
-		if (strcmp(param.mode, "system-ram") == 0) {
+		if (param.size) {
+			size = __parse_size64(param.size, &units);
+		} else if (strcmp(param.mode, "system-ram") == 0) {
 			reconfig_mode = DAXCTL_DEV_MODE_RAM;
 			if (param.no_movable)
 				mem_zone = MEM_ZONE_NORMAL;
@@ -309,6 +313,17 @@ static int dev_offline_memory(struct daxctl_dev *dev)
 	return 0;
 }
 
+static int dev_resize(struct daxctl_dev *dev, unsigned long long val)
+{
+	int rc;
+
+	rc = daxctl_dev_set_size(dev, val);
+	if (rc < 0)
+		return rc;
+
+	return 0;
+}
+
 static int disable_devdax_device(struct daxctl_dev *dev)
 {
 	struct daxctl_memory *mem = daxctl_dev_get_memory(dev);
@@ -418,6 +433,11 @@ static int do_reconfig(struct daxctl_dev *dev, enum dev_mode mode,
 	struct json_object *jdev;
 	int rc = 0;
 
+	if (size >= 0) {
+		rc = dev_resize(dev, size);
+		return rc;
+	}
+
 	switch (mode) {
 	case DAXCTL_DEV_MODE_RAM:
 		rc = reconfig_mode_system_ram(dev);
-- 
2.17.1
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

  parent reply	other threads:[~2020-04-03 20:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-03 20:58 [PATCH ndctl v1 00/10] daxctl: Support for sub-dividing soft-reserved regions Joao Martins
2020-04-03 20:58 ` [PATCH ndctl v1 01/10] daxctl: Cleanup whitespace Joao Martins
2020-04-03 20:58 ` [PATCH ndctl v1 02/10] libdaxctl: add daxctl_dev_set_size() Joao Martins
2020-04-03 20:58 ` Joao Martins [this message]
2020-04-03 20:58 ` [PATCH ndctl v1 04/10] daxctl: add command to disable devdax device Joao Martins
2020-04-03 20:58 ` [PATCH ndctl v1 05/10] daxctl: add command to enable " Joao Martins
2020-04-03 20:58 ` [PATCH ndctl v1 06/10] libdaxctl: add daxctl_region_create_dev() Joao Martins
2020-04-03 20:58 ` [PATCH ndctl v1 07/10] daxctl: add command to create device Joao Martins
2020-04-03 20:58 ` [PATCH ndctl v1 08/10] libdaxctl: add daxctl_region_destroy_dev() Joao Martins
2020-04-03 20:58 ` [PATCH ndctl v1 09/10] daxctl: add command to destroy device Joao Martins
2020-04-03 20:59 ` [PATCH ndctl v1 10/10] daxctl/test: Add tests for dynamic dax regions Joao Martins
2020-07-12 15:04   ` Dan Williams
2020-07-13  9:46     ` Joao Martins

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=20200403205900.18035-4-joao.m.martins@oracle.com \
    --to=joao.m.martins@oracle.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    --cc=vishal.l.verma@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).