Skip to content

Commit 6cfc467

Browse files
MaisenbacherDigaw
authored andcommitted
nvme: fix timeout ioctl arguments
By default, set the timeout to NVME_DEFAULT_IOCTL_TIMEOUT. This argument can be overwritten by the corresponding command line flag. Timeout values of `120000` ms are assumed to be the historical default value NVME_IOCTL_TIMEOUT, see 18de3a6 ("Convert to libnvme"). Reported-by: Daniel Wagner <[email protected]> Signed-off-by: Dennis Maisenbacher <[email protected]>
1 parent 80ad62b commit 6cfc467

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

nvme.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ static const char *pmrmscu = "PMRMSCU=0xe18 register offset";
261261
struct nvme_config nvme_cfg = {
262262
.output_format = "normal",
263263
.output_format_ver = 1,
264+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
264265
};
265266

266267
static void *mmap_registers(struct nvme_dev *dev, bool writable);
@@ -2990,8 +2991,6 @@ static int delete_ns(int argc, char **argv, struct command *cmd, struct plugin *
29902991
.namespace_id = 0,
29912992
};
29922993

2993-
nvme_cfg.timeout = 120000;
2994-
29952994
NVME_ARGS(opts,
29962995
OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id));
29972996

@@ -3304,8 +3303,6 @@ static int create_ns(int argc, char **argv, struct command *cmd, struct plugin *
33043303
.phndls = "",
33053304
};
33063305

3307-
nvme_cfg.timeout = 120000;
3308-
33093306
NVME_ARGS(opts,
33103307
OPT_SUFFIX("nsze", 's', &cfg.nsze, nsze),
33113308
OPT_SUFFIX("ncap", 'c', &cfg.ncap, ncap),
@@ -6464,6 +6461,7 @@ static int format_cmd(int argc, char **argv, struct command *cmd, struct plugin
64646461
_cleanup_free_ struct nvme_id_ctrl *ctrl = NULL;
64656462
_cleanup_free_ struct nvme_id_ns *ns = NULL;
64666463
_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
6464+
__u32 timeout_ms = 600000;
64676465
__u8 prev_lbaf = 0;
64686466
int block_size;
64696467
int err, i;
@@ -6493,7 +6491,8 @@ static int format_cmd(int argc, char **argv, struct command *cmd, struct plugin
64936491
.bs = 0,
64946492
};
64956493

6496-
nvme_cfg.timeout = 600000;
6494+
if (nvme_cfg.timeout != NVME_DEFAULT_IOCTL_TIMEOUT)
6495+
timeout_ms = nvme_cfg.timeout;
64976496

64986497
NVME_ARGS(opts,
64996498
OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired),
@@ -6659,7 +6658,7 @@ static int format_cmd(int argc, char **argv, struct command *cmd, struct plugin
66596658
.pi = cfg.pi,
66606659
.pil = cfg.pil,
66616660
.ses = cfg.ses,
6662-
.timeout = nvme_cfg.timeout,
6661+
.timeout = timeout_ms,
66636662
.result = NULL,
66646663
};
66656664
err = nvme_cli_format_nvm(dev, &args);
@@ -10482,7 +10481,7 @@ static int get_dispersed_ns_psub(struct nvme_dev *dev, __u32 nsid,
1048210481
struct nvme_get_log_args args = {
1048310482
.args_size = sizeof(args),
1048410483
.fd = dev_fd(dev),
10485-
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
10484+
.timeout = nvme_cfg.timeout,
1048610485
.lid = NVME_LOG_LID_DISPERSED_NS_PARTICIPATING_NSS,
1048710486
.nsid = nsid,
1048810487
.lpo = header_len,
@@ -10612,7 +10611,7 @@ static int get_reachability_groups(struct nvme_dev *dev, bool rgo, bool rae,
1061210611
struct nvme_get_log_args args = {
1061310612
.args_size = sizeof(args),
1061410613
.fd = dev_fd(dev),
10615-
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
10614+
.timeout = nvme_cfg.timeout,
1061610615
.lid = NVME_LOG_LID_REACHABILITY_GROUPS,
1061710616
.nsid = NVME_NSID_ALL,
1061810617
.lsp = rgo,
@@ -10727,7 +10726,7 @@ static int get_reachability_associations(struct nvme_dev *dev, bool rao, bool ra
1072710726
struct nvme_get_log_args args = {
1072810727
.args_size = sizeof(args),
1072910728
.fd = dev_fd(dev),
10730-
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
10729+
.timeout = nvme_cfg.timeout,
1073110730
.lid = NVME_LOG_LID_REACHABILITY_ASSOCIATIONS,
1073210731
.nsid = NVME_NSID_ALL,
1073310732
.lsp = rao,
@@ -10812,7 +10811,7 @@ static int get_host_discovery(struct nvme_dev *dev, bool allhoste, bool rae,
1081210811
struct nvme_get_log_args args = {
1081310812
.args_size = sizeof(args),
1081410813
.fd = dev_fd(dev),
10815-
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
10814+
.timeout = nvme_cfg.timeout,
1081610815
.lid = NVME_LOG_LID_HOST_DISCOVER,
1081710816
.nsid = NVME_NSID_ALL,
1081810817
.lsp = allhoste,
@@ -10895,7 +10894,7 @@ static int get_ave_discovery(struct nvme_dev *dev, bool rae, struct nvme_ave_dis
1089510894
struct nvme_get_log_args args = {
1089610895
.args_size = sizeof(args),
1089710896
.fd = dev_fd(dev),
10898-
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
10897+
.timeout = nvme_cfg.timeout,
1089910898
.lid = NVME_LOG_LID_AVE_DISCOVER,
1090010899
.nsid = NVME_NSID_ALL,
1090110900
.rae = rae,
@@ -10973,7 +10972,7 @@ static int get_pull_model_ddc_req(struct nvme_dev *dev,
1097310972
struct nvme_get_log_args args = {
1097410973
.args_size = sizeof(args),
1097510974
.fd = dev_fd(dev),
10976-
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
10975+
.timeout = nvme_cfg.timeout,
1097710976
.lid = NVME_LOG_LID_PULL_MODEL_DDC_REQ,
1097810977
.nsid = NVME_NSID_ALL,
1097910978
.rae = rae,

0 commit comments

Comments
 (0)