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 05/10] daxctl: add command to enable devdax device
Date: Fri, 3 Apr 2020 21:58:55 +0100 [thread overview]
Message-ID: <20200403205900.18035-6-joao.m.martins@oracle.com> (raw)
In-Reply-To: <20200403205900.18035-1-joao.m.martins@oracle.com>
Add a 'enable-device' command, required prior to
reconfiguration of the dax device.
Mimics the same functionality as seen in
ndctl-enable-namespace.
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
daxctl/builtin.h | 1 +
daxctl/daxctl.c | 1 +
daxctl/device.c | 40 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 42 insertions(+)
diff --git a/daxctl/builtin.h b/daxctl/builtin.h
index c9848953bbd8..8f344f86ad20 100644
--- a/daxctl/builtin.h
+++ b/daxctl/builtin.h
@@ -8,6 +8,7 @@ int cmd_list(int argc, const char **argv, struct daxctl_ctx *ctx);
int cmd_migrate(int argc, const char **argv, struct daxctl_ctx *ctx);
int cmd_reconfig_device(int argc, const char **argv, struct daxctl_ctx *ctx);
int cmd_disable_device(int argc, const char **argv, struct daxctl_ctx *ctx);
+int cmd_enable_device(int argc, const char **argv, struct daxctl_ctx *ctx);
int cmd_online_memory(int argc, const char **argv, struct daxctl_ctx *ctx);
int cmd_offline_memory(int argc, const char **argv, struct daxctl_ctx *ctx);
#endif /* _DAXCTL_BUILTIN_H_ */
diff --git a/daxctl/daxctl.c b/daxctl/daxctl.c
index 1707a9ff0791..a4699b3780bd 100644
--- a/daxctl/daxctl.c
+++ b/daxctl/daxctl.c
@@ -75,6 +75,7 @@ static struct cmd_struct commands[] = {
{ "online-memory", .d_fn = cmd_online_memory },
{ "offline-memory", .d_fn = cmd_offline_memory },
{ "disable-device", .d_fn = cmd_disable_device },
+ { "enable-device", .d_fn = cmd_enable_device },
};
int main(int argc, const char **argv)
diff --git a/daxctl/device.c b/daxctl/device.c
index 7a49852f78f4..596b6efca34d 100644
--- a/daxctl/device.c
+++ b/daxctl/device.c
@@ -48,6 +48,7 @@ enum device_action {
ACTION_ONLINE,
ACTION_OFFLINE,
ACTION_DISABLE,
+ ACTION_ENABLE,
};
#define BASE_OPTIONS() \
@@ -90,6 +91,11 @@ static const struct option disable_options[] = {
OPT_END(),
};
+static const struct option enable_options[] = {
+ BASE_OPTIONS(),
+ OPT_END(),
+};
+
static const char *parse_device_options(int argc, const char **argv,
enum device_action action, const struct option *options,
const char *usage, struct daxctl_ctx *ctx)
@@ -119,6 +125,9 @@ static const char *parse_device_options(int argc, const char **argv,
case ACTION_DISABLE:
action_string = "disable";
break;
+ case ACTION_ENABLE:
+ action_string = "enable";
+ break;
default:
action_string = "<>";
break;
@@ -172,6 +181,7 @@ static const char *parse_device_options(int argc, const char **argv,
/* fall through */
case ACTION_OFFLINE:
case ACTION_DISABLE:
+ case ACTION_ENABLE:
/* nothing special */
break;
}
@@ -515,6 +525,14 @@ static int do_xble(struct daxctl_dev *dev, enum device_action action)
}
switch (action) {
+ case ACTION_ENABLE:
+ rc = daxctl_dev_enable_devdax(dev);
+ if (rc) {
+ fprintf(stderr, "%s: enable failed: %s\n",
+ daxctl_dev_get_devname(dev), strerror(-rc));
+ return rc;
+ }
+ break;
case ACTION_DISABLE:
rc = daxctl_dev_disable(dev);
if (rc) {
@@ -564,6 +582,11 @@ static int do_xaction_device(const char *device, enum device_action action,
if (rc == 0)
(*processed)++;
break;
+ case ACTION_ENABLE:
+ rc = do_xble(dev, action);
+ if (rc == 0)
+ (*processed)++;
+ break;
case ACTION_DISABLE:
rc = do_xble(dev, action);
if (rc == 0)
@@ -621,6 +644,23 @@ int cmd_disable_device(int argc, const char **argv, struct daxctl_ctx *ctx)
return rc;
}
+int cmd_enable_device(int argc, const char **argv, struct daxctl_ctx *ctx)
+{
+ char *usage = "daxctl enable-device <device>";
+ const char *device = parse_device_options(argc, argv, ACTION_DISABLE,
+ enable_options, usage, ctx);
+ int processed, rc;
+
+ rc = do_xaction_device(device, ACTION_ENABLE, ctx, &processed);
+ if (rc < 0)
+ fprintf(stderr, "error enabling device: %s\n",
+ strerror(-rc));
+
+ fprintf(stderr, "enabled %d device%s\n", processed,
+ processed == 1 ? "" : "s");
+ return rc;
+}
+
int cmd_online_memory(int argc, const char **argv, struct daxctl_ctx *ctx)
{
char *usage = "daxctl online-memory <device> [<options>]";
--
2.17.1
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org
next prev 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 ` [PATCH ndctl v1 03/10] daxctl: add resize support in reconfigure-device Joao Martins
2020-04-03 20:58 ` [PATCH ndctl v1 04/10] daxctl: add command to disable devdax device Joao Martins
2020-04-03 20:58 ` Joao Martins [this message]
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-6-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).