[RFC PATCH v2 2/2] devlink: stop requiring snapshot for regions

Jacob Keller
2020-02-14T23:22:40Z

The region dump and region read commands currently require the snapshot
to work. Recent changes to the kernel have enabled optionally
supporting direct read of a region's contents without a snapshot id.

Enable this by allowing the read and dump commands to execute without
a snapshot id. On older kernels, this will return -EINVAL as the kernel
will reject such a command. On newer kernels, this will directly read
the region contents without taking a snapshot. If a region does not
support direct read, it will return -EOPNOTSUPP.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
devlink/devlink.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 71c300ba16ed..f98f2dc034ea 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -6312,8 +6312,8 @@ static int cmd_region_dump(struct dl *dl)
nlh = mnlg_msg_prepare(dl->nlg, DEVLINK_CMD_REGION_READ,
NLM_F_REQUEST | NLM_F_ACK | NLM_F_DUMP);

- err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE_REGION |
- DL_OPT_REGION_SNAPSHOT_ID, 0);
+ err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE_REGION,
+ DL_OPT_REGION_SNAPSHOT_ID);
if (err)
return err;

@@ -6334,8 +6334,8 @@ static int cmd_region_read(struct dl *dl)
NLM_F_REQUEST | NLM_F_ACK | NLM_F_DUMP);

err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE_REGION |
- DL_OPT_REGION_ADDRESS | DL_OPT_REGION_LENGTH |
- DL_OPT_REGION_SNAPSHOT_ID, 0);
+ DL_OPT_REGION_ADDRESS | DL_OPT_REGION_LENGTH,
+ DL_OPT_REGION_SNAPSHOT_ID);
if (err)
return err;

--
2.25.0.368.g28a2d05eebfb