Skip to content

Commit 2249c3a

Browse files
committed
src: rework nvme_io_mgmt_send commands
libnvme changed the API for the nvme_io_mgmt_send commands. Update the callsite accordingly Signed-off-by: Dennis Maisenbacher <[email protected]>
1 parent f595a36 commit 2249c3a

1 file changed

Lines changed: 14 additions & 22 deletions

File tree

nvme.c

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,16 +2088,17 @@ static int io_mgmt_send(int argc, char **argv, struct command *acmd, struct plug
20882088
const char *desc = "I/O Management Send";
20892089
const char *data = "optional file for data (default stdin)";
20902090

2091-
_cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;
20922091
_cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL;
2092+
_cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;
2093+
_cleanup_fd_ int dfd = STDIN_FILENO;
20932094
_cleanup_free_ void *buf = NULL;
2095+
struct nvme_passthru_cmd cmd;
20942096
int err = -1;
2095-
_cleanup_fd_ int dfd = STDIN_FILENO;
20962097

20972098
struct config {
2099+
__u32 nsid;
20982100
__u16 mos;
20992101
__u8 mo;
2100-
__u32 namespace_id;
21012102
char *file;
21022103
__u32 data_len;
21032104
};
@@ -2107,18 +2108,18 @@ static int io_mgmt_send(int argc, char **argv, struct command *acmd, struct plug
21072108
};
21082109

21092110
NVME_ARGS(opts,
2110-
OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired),
2111-
OPT_SHRT("mos", 's', &cfg.mos, mos),
2112-
OPT_BYTE("mo", 'm', &cfg.mo, mo),
2113-
OPT_FILE("data", 'd', &cfg.file, data),
2114-
OPT_UINT("data-len", 'l', &cfg.data_len, buf_len));
2111+
OPT_UINT("namespace-id", 'n', &cfg.nsid, namespace_id_desired),
2112+
OPT_SHRT("mos", 's', &cfg.mos, mos),
2113+
OPT_BYTE("mo", 'm', &cfg.mo, mo),
2114+
OPT_FILE("data", 'd', &cfg.file, data),
2115+
OPT_UINT("data-len", 'l', &cfg.data_len, buf_len));
21152116

21162117
err = parse_and_open(&ctx, &hdl, argc, argv, desc, opts);
21172118
if (err)
21182119
return err;
21192120

2120-
if (!cfg.namespace_id) {
2121-
err = nvme_get_nsid(hdl, &cfg.namespace_id);
2121+
if (!cfg.nsid) {
2122+
err = nvme_get_nsid(hdl, &cfg.nsid);
21222123
if (err < 0) {
21232124
nvme_show_perror("get-namespace-id");
21242125
return err;
@@ -2145,20 +2146,11 @@ static int io_mgmt_send(int argc, char **argv, struct command *acmd, struct plug
21452146
return err;
21462147
}
21472148

2148-
struct nvme_io_mgmt_send_args args = {
2149-
.args_size = sizeof(args),
2150-
.nsid = cfg.namespace_id,
2151-
.mos = cfg.mos,
2152-
.mo = cfg.mo,
2153-
.data_len = cfg.data_len,
2154-
.data = buf,
2155-
.timeout = nvme_cfg.timeout,
2156-
};
2157-
2158-
err = nvme_io_mgmt_send(hdl, &args);
2149+
nvme_init_io_mgmt_send(&cmd, cfg.nsid, cfg.mo, cfg.mos, buf, cfg.data_len);
2150+
err = nvme_submit_io_passthru(hdl, &cmd, NULL);
21592151
if (!err)
21602152
printf("io-mgmt-send: Success, mos:%u mo:%u nsid:%d\n",
2161-
cfg.mos, cfg.mo, cfg.namespace_id);
2153+
cfg.mos, cfg.mo, cfg.nsid);
21622154
else if (err > 0)
21632155
nvme_show_status(err);
21642156
else

0 commit comments

Comments
 (0)