Skip to content

Commit 5a7ee36

Browse files
kurz-migaw
authored andcommitted
src: rework nvme_dev_self_test command
libnvme changed the API for the nvme_dev_self_test command. Update the callsite accordingly. Signed-off-by: Markus Kurz <[email protected]>
1 parent 2a2534a commit 5a7ee36

1 file changed

Lines changed: 10 additions & 15 deletions

File tree

nvme.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4576,13 +4576,13 @@ static int wait_self_test(struct nvme_transport_handle *hdl)
45764576
return 0;
45774577
}
45784578

4579-
static void abort_self_test(struct nvme_transport_handle *hdl, struct nvme_dev_self_test_args *args)
4579+
static void abort_self_test(struct nvme_transport_handle *hdl, __u32 nsid)
45804580
{
4581+
struct nvme_passthru_cmd cmd;
45814582
int err;
45824583

4583-
args->stc = NVME_DST_STC_ABORT;
4584-
4585-
err = nvme_dev_self_test(hdl, args);
4584+
nvme_init_dev_self_test(&cmd, nsid, NVME_DST_STC_ABORT);
4585+
err = nvme_submit_admin_passthru(hdl, &cmd, NULL);
45864586
if (!err)
45874587
printf("Aborting device self-test operation\n");
45884588
else if (err > 0)
@@ -4607,10 +4607,11 @@ static int device_self_test(int argc, char **argv, struct command *acmd, struct
46074607
"fh Abort the device self-test operation";
46084608
const char *wait = "Wait for the test to finish";
46094609

4610-
_cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;
46114610
_cleanup_nvme_transport_handle_ struct nvme_transport_handle *hdl = NULL;
4612-
int err;
4611+
_cleanup_nvme_global_ctx_ struct nvme_global_ctx *ctx = NULL;
4612+
struct nvme_passthru_cmd cmd;
46134613
nvme_print_flags_t flags;
4614+
int err;
46144615

46154616
struct config {
46164617
__u32 namespace_id;
@@ -4667,14 +4668,8 @@ static int device_self_test(int argc, char **argv, struct command *acmd, struct
46674668
goto check_abort;
46684669
}
46694670

4670-
struct nvme_dev_self_test_args args = {
4671-
.args_size = sizeof(args),
4672-
.nsid = cfg.namespace_id,
4673-
.stc = cfg.stc,
4674-
.timeout = nvme_cfg.timeout,
4675-
.result = NULL,
4676-
};
4677-
err = nvme_dev_self_test(hdl, &args);
4671+
nvme_init_dev_self_test(&cmd, cfg.namespace_id, cfg.stc);
4672+
err = nvme_submit_admin_passthru(hdl, &cmd, NULL);
46784673
if (!err) {
46794674
if (cfg.stc == NVME_ST_CODE_ABORT)
46804675
printf("Aborting device self-test operation\n");
@@ -4695,7 +4690,7 @@ static int device_self_test(int argc, char **argv, struct command *acmd, struct
46954690

46964691
check_abort:
46974692
if (err == -EINTR)
4698-
abort_self_test(hdl, &args);
4693+
abort_self_test(hdl, cfg.namespace_id);
46994694

47004695
return err;
47014696
}

0 commit comments

Comments
 (0)