Skip to content

Commit 42f3398

Browse files
committed
nvme: add command line argument to disable retries
Allow the user to disable the retry logic. There are use cases in testing where the simple retry logic should not be applied, e.g. sending out admin passthru commands while a reset is issued. The admin passthru commands should just fail in this case. Signed-off-by: Daniel Wagner <[email protected]>
1 parent da51887 commit 42f3398

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

logging.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ int nvme_submit_passthru(int fd, unsigned long ioctl_cmd,
120120
if (!nvme_cfg.dry_run) {
121121
retry:
122122
err = ioctl(fd, ioctl_cmd, cmd);
123-
if (err && (errno == EAGAIN ||
124-
(errno == EINTR && !nvme_sigint_received))) {
123+
if ((err && (errno == EAGAIN ||
124+
(errno == EINTR && !nvme_sigint_received))) &&
125+
!nvme_cfg.no_retries) {
125126
nvme_log_retry(errno);
126127
goto retry;
127128
}
@@ -153,8 +154,9 @@ int nvme_submit_passthru64(int fd, unsigned long ioctl_cmd,
153154
if (!nvme_cfg.dry_run) {
154155
retry:
155156
err = ioctl(fd, ioctl_cmd, cmd);
156-
if (err && (errno == EAGAIN ||
157-
(errno == EINTR && !nvme_sigint_received))) {
157+
if ((err && (errno == EAGAIN ||
158+
(errno == EINTR && !nvme_sigint_received))) &&
159+
!nvme_cfg.no_retries) {
158160
nvme_log_retry(errno);
159161
goto retry;
160162
}

nvme.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ struct nvme_config {
7979
int verbose;
8080
__u32 timeout;
8181
bool dry_run;
82+
bool no_retries;
8283
unsigned int output_format_ver;
8384
};
8485

@@ -93,6 +94,8 @@ struct nvme_config {
9394
##__VA_ARGS__, \
9495
OPT_UINT("timeout", 't', &nvme_cfg.timeout, timeout), \
9596
OPT_FLAG("dry-run", 0, &nvme_cfg.dry_run, dry_run), \
97+
OPT_FLAG("no-retries", 0, &nvme_cfg.no_retries, \
98+
"disable retry logic on errors\n"), \
9699
OPT_UINT("output-format-version", 0, &nvme_cfg.output_format_ver, \
97100
"output format version: 1|2"), \
98101
OPT_END() \

0 commit comments

Comments
 (0)