Skip to contentSkip to conversation

devlink: add support for DEVLINK_CMD_REGION_NEW

iproute2 Jacob Keller 2 participants 3 messages Apr 28, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Add support to request that a new snapshot be taken immediately for a devlink region. To avoid confusion, the desired snapshot id must be provided.

Note that if a region does not support snapshots on demand, the kernel will reject the request with -EOPNOTSUP.

---
 devlink/devlink.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
devlink/devlink.c +20 -0
index 67e6e64181f9..c750ee1ec6d3 100644
@@ -6362,10 +6362,27 @@ static int cmd_region_read(struct dl *dl)
 	return err;
 }
 
+static int cmd_region_snapshot_new(struct dl *dl)
+{
+	struct nlmsghdr *nlh;
+	int err;
+
+	nlh = mnlg_msg_prepare(dl->nlg, DEVLINK_CMD_REGION_NEW,
+			NLM_F_REQUEST | NLM_F_ACK);
+
+	err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE_REGION |
+				DL_OPT_REGION_SNAPSHOT_ID, 0);
+	if (err)
+		return err;
+
+	return _mnlg_socket_sndrcv(dl->nlg, nlh, NULL, NULL);
+}
+
 static void cmd_region_help(void)
 {
 	pr_err("Usage: devlink region show [ DEV/REGION ]\n");
 	pr_err("       devlink region del DEV/REGION snapshot SNAPSHOT_ID\n");
+	pr_err("       devlink region new DEV/REGION [snapshot SNAPSHOT_ID]\n");
 	pr_err("       devlink region dump DEV/REGION [ snapshot SNAPSHOT_ID ]\n");
 	pr_err("       devlink region read DEV/REGION [ snapshot SNAPSHOT_ID ] address ADDRESS length LENGTH\n");
 }
@@ -6389,6 +6406,9 @@ static int cmd_region(struct dl *dl)
 	} else if (dl_argv_match(dl, "read")) {
 		dl_arg_inc(dl);
 		return cmd_region_read(dl);
+	} else if (dl_argv_match(dl, "new")) {
+		dl_arg_inc(dl);
+		return cmd_region_snapshot_new(dl);
 	}
 	pr_err("Command \"%s\" not found\n", dl_argv(dl));
 	return -ENOENT;
Signature · 1 line
2.25.2
#1 lore raw
Quoted 31 lines · Tue, Apr 28, 2020 at 04:05:12AM CEST, [email protected] wrote:

Add support to request that a new snapshot be taken immediately for a devlink region. To avoid confusion, the desired snapshot id must be provided.

Note that if a region does not support snapshots on demand, the kernel will reject the request with -EOPNOTSUP.

---
devlink/devlink.c | 20 ++++++++++++++++++++

1 file changed, 20 insertions(+)
devlink/devlink.c +11 -0
index 67e6e64181f9..c750ee1ec6d3 100644
@@ -6362,10 +6362,27 @@ static int cmd_region_read(struct dl *dl)
 	return err;
 }
 
+static int cmd_region_snapshot_new(struct dl *dl)
+{
+	struct nlmsghdr *nlh;
+	int err;
+
+	nlh = mnlg_msg_prepare(dl->nlg, DEVLINK_CMD_REGION_NEW,
+			NLM_F_REQUEST | NLM_F_ACK);
+
+	err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE_REGION |
+				DL_OPT_REGION_SNAPSHOT_ID, 0);
+	if (err)

devlink/devlink.c static int cmd_region_read(struct dl *dl) · line 6385

Quoted 10 lines
devlink/devlink.c +6 -0
+		return err;
+
+	return _mnlg_socket_sndrcv(dl->nlg, nlh, NULL, NULL);
+}
+
 static void cmd_region_help(void)
 {
 	pr_err("Usage: devlink region show [ DEV/REGION ]\n");
 	pr_err("       devlink region del DEV/REGION snapshot SNAPSHOT_ID\n");
+	pr_err("       devlink region new DEV/REGION [snapshot SNAPSHOT_ID]\n");

Same as for "del", snapshot id is mandatory. You should not have it in "[]".

Quoted 16 lines
devlink/devlink.c +3 -0
 	pr_err("       devlink region dump DEV/REGION [ snapshot SNAPSHOT_ID ]\n");
 	pr_err("       devlink region read DEV/REGION [ snapshot SNAPSHOT_ID ] address ADDRESS length LENGTH\n");
 }
@@ -6389,6 +6406,9 @@ static int cmd_region(struct dl *dl)
 	} else if (dl_argv_match(dl, "read")) {
 		dl_arg_inc(dl);
 		return cmd_region_read(dl);
+	} else if (dl_argv_match(dl, "new")) {
+		dl_arg_inc(dl);
+		return cmd_region_snapshot_new(dl);
 	}
 	pr_err("Command \"%s\" not found\n", dl_argv(dl));
 	return -ENOENT;
Signature · 1 line
2.25.2
#2 lore raw
Quoted 54 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Jiri Pirko
Sent: Monday, April 27, 2020 10:43 PM
To: Keller, Jacob E <[email protected]>
Cc: [email protected]; Jakub Kicinski <[email protected]>
Subject: Re: [iproute2] devlink: add support for DEVLINK_CMD_REGION_NEW

Quoted 31 lines · Tue, Apr 28, 2020 at 04:05:12AM CEST, [email protected] wrote:

Add support to request that a new snapshot be taken immediately for a devlink region. To avoid confusion, the desired snapshot id must be provided.

Note that if a region does not support snapshots on demand, the kernel will reject the request with -EOPNOTSUP.

---
devlink/devlink.c | 20 ++++++++++++++++++++

1 file changed, 20 insertions(+)
devlink/devlink.c +11 -0
index 67e6e64181f9..c750ee1ec6d3 100644
@@ -6362,10 +6362,27 @@ static int cmd_region_read(struct dl *dl)
 	return err;
 }
 
+static int cmd_region_snapshot_new(struct dl *dl)
+{
+	struct nlmsghdr *nlh;
+	int err;
+
+	nlh = mnlg_msg_prepare(dl->nlg, DEVLINK_CMD_REGION_NEW,
+			NLM_F_REQUEST | NLM_F_ACK);
+
+	err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE_REGION |
+				DL_OPT_REGION_SNAPSHOT_ID, 0);
+	if (err)

devlink/devlink.c static int cmd_region_read(struct dl *dl) · line 6385

Quoted 10 lines
devlink/devlink.c +6 -0
+		return err;
+
+	return _mnlg_socket_sndrcv(dl->nlg, nlh, NULL, NULL);
+}
+
 static void cmd_region_help(void)
 {
 	pr_err("Usage: devlink region show [ DEV/REGION ]\n");
 	pr_err("       devlink region del DEV/REGION snapshot SNAPSHOT_ID\n");
+	pr_err("       devlink region new DEV/REGION [snapshot

SNAPSHOT_ID]\n");

Quoted 2 lines

Same as for "del", snapshot id is mandatory. You should not have it in "[]".

Ah, right!

Quoted 19 lines

devlink/devlink.c static int cmd_region_read(struct dl *dl) · line 6386

Quoted 2 lines
devlink/devlink.c +0 -0
 	pr_err("       devlink region dump DEV/REGION [ snapshot SNAPSHOT_ID

]\n");

devlink/devlink.c static int cmd_region_read(struct dl *dl) · line 6387

Quoted 1 line
devlink/devlink.c +0 -0
 	pr_err("       devlink region read DEV/REGION [ snapshot SNAPSHOT_ID ]

address ADDRESS length LENGTH\n");

Quoted 14 lines
devlink/devlink.c +3 -1
 }
@@ -6389,6 +6406,9 @@ static int cmd_region(struct dl *dl)
 	} else if (dl_argv_match(dl, "read")) {
 		dl_arg_inc(dl);
 		return cmd_region_read(dl);
+	} else if (dl_argv_match(dl, "new")) {
+		dl_arg_inc(dl);
+		return cmd_region_snapshot_new(dl);
 	}
 	pr_err("Command \"%s\" not found\n", dl_argv(dl));
 	return -ENOENT;
--

2.25.2