From aedfb32c007ba2dddf770080843a65e20b613020 Mon Sep 17 00:00:00 2001 From: Minwoo Im Date: Tue, 14 Oct 2025 08:45:03 +0900 Subject: [PATCH 1/3] options: add support more POSIX errnos Added more error numbers(errno) after ERANGE to support various errno string to options like `--ignore_error=ETIMEDOUT`. unvme-cli libunvmed ioengine returns ETIMEDOUT if a command is timed out. To mask this situation with `--ignore_error=` option, errno after ERANGE should be supported in `str2errr()`. Signed-off-by: Minwoo Im --- options.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/options.c b/options.c index 77b42cdbb5..3ff2982a89 100644 --- a/options.c +++ b/options.c @@ -522,12 +522,40 @@ static int str2error(char *str) "EXDEV", "ENODEV", "ENOTDIR", "EISDIR", "EINVAL", "ENFILE", "EMFILE", "ENOTTY", "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE", - "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" }; + "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE", + "EDEADLK", "ENAMETOOLONG", "ENOLCK", "ENOSYS", "ENOTEMPTY", + "ELOOP", "EWOULDBLOCK", "ENOMSG", "EIDRM", "ECHRNG", + "EL2NSYNC", "EL3HLT", "EL3RST", "ELNRNG", "EUNATCH", + "ENOCSI", "EL2HLT", "EBADE", "EBADR", "EXFULL", + "ENOANO", "EBADRQC", "EBADSLT", "EDEADLOCK", "EBFONT", + "ENOSTR", "ENODATA", "ETIME", "ENOSR", "ENONET", + "ENOPKG", "EREMOTE", "ENOLINK", "EADV", "ESRMNT", + "ECOMM", "EPROTO", "EMULTIHOP", "EDOTDOT", "EBADMSG", + "EOVERFLOW", "ENOTUNIQ", "EBADFD", "EREMCHG", "ELIBACC", + "ELIBBAD", "ELIBSCN", "ELIBMAX", "ELIBEXEC", "EILSEQ", + "ERESTART", "ESTRPIPE", "EUSERS", "ENOTSOCK", "EDESTADDRREQ", + "EMSGSIZE", "EPROTOTYPE", "ENOPROTOOPT", "EPROTONOSUPPORT", "ESOCKTNOSUPPORT", + "EOPNOTSUPP", "EPFNOSUPPORT", "EAFNOSUPPORT", "EADDRINUSE", "EADDRNOTAVAIL", + "ENETDOWN", "ENETUNREACH", "ENETRESET", "ECONNABORTED", "ECONNRESET", + "ENOBUFS", "EISCONN", "ENOTCONN", "ESHUTDOWN", "ETOOMANYREFS", + "ETIMEDOUT", "ECONNREFUSED", "EHOSTDOWN", "EHOSTUNREACH", "EALREADY", + "EINPROGRESS", "ESTALE", "EUCLEAN", "ENOTNAM", "ENAVAIL", + "EISNAM", "EREMOTEIO", "EDQUOT", "ENOMEDIUM", "EMEDIUMTYPE", + "ECANCELED", "ENOKEY", "EKEYEXPIRED", "EKEYREVOKED", "EKEYREJECTED", + "EOWNERDEAD", "ENOTRECOVERABLE", "ERFKILL", "EHWPOISON" }; int i = 0, num = sizeof(err) / sizeof(char *); + int retval; while (i < num) { - if (!strcmp(err[i], str)) - return i + 1; + if (!strcmp(err[i], str)) { + retval = i + 1; + /* Handle errno aliases that should map to actual errno values */ + if (!strcmp(str, "EWOULDBLOCK")) + retval = EAGAIN; + else if (!strcmp(str, "EDEADLOCK")) + retval = EDEADLK; + return retval; + } i++; } return 0; From 90c300653cef2c2ea7da38ad015ab14659458de4 Mon Sep 17 00:00:00 2001 From: Minwoo Im Date: Tue, 14 Oct 2025 08:45:10 +0900 Subject: [PATCH 2/3] options: add supoprt negative errno to `--ignore_error` Some of ioengines (e.g., io_uring_cmd) returns negative errno to represent system error as negative errno instead of positive values for NVMe-specific error status. To masking expected situations with --ignore_error= option, added support for negative value of errno syntax. Signed-off-by: Minwoo Im --- options.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/options.c b/options.c index 3ff2982a89..183e60dd6e 100644 --- a/options.c +++ b/options.c @@ -592,6 +592,8 @@ static int ignore_error_type(struct thread_data *td, enum error_type_bit etype, } if (fname[0] == 'E') { error[i] = str2error(fname); + } else if (fname[0] == '-' && fname[1] == 'E') { + error[i] = -str2error(fname + 1); } else { int base = 10; if (!strncmp(fname, "0x", 2) || From d38c0caf79c30e43cf20a2da27c3f0b96ad5ca5a Mon Sep 17 00:00:00 2001 From: Minwoo Im Date: Tue, 14 Oct 2025 09:55:14 +0900 Subject: [PATCH 3/3] io_u: check non-fatal error with IO_U_F_DEVICE_ERROR IO_U_F_DEVICE_ERROR has been introduced in Commit ebe67b667f25 ("io_uring: Add IO_U_F_DEVICE_ERROR to identify error types") to parse two different types of errors can happen: (1) device error(e.g., NVMe-specific error status code) and (2) system error(e.g., EINVAL). `--ignore_error=` option let user mask expected situation, but if user wants to mask system error rather than device error, no way to represent the system error except for such as -EINVAL. Even if user put -EINVAL to the option, it will be checked as a positive value since @io_u->error will be set with abs() in io_uring_cmd ioengine. This patch flips the given @io_u->error positive value to a negative value if the given @io_u->flags represents system error by IO_U_F_DEVICE_ERROR. Signed-off-by: Minwoo Im --- io_u.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/io_u.c b/io_u.c index ab1bf7c9a4..ef9648dcdd 100644 --- a/io_u.c +++ b/io_u.c @@ -2196,7 +2196,16 @@ static void io_completed(struct thread_data *td, struct io_u **io_u_ptr, } } else if (io_u->error) { error: - icd->error = io_u->error; + if (io_u->flags & IO_U_F_DEVICE_ERROR) + icd->error = io_u->error; + else { + /* + * If @io_u has system error(non-device erorr), it must + * have been negative value. + */ + icd->error = -io_u->error; + } + io_u_log_error(td, io_u); } if (icd->error) {